public InternalFunction(MachineInfo machineInfo, string prototype, InternalFunctionAction?action = null) { var report = new Report(new Report.TextWriterPrinter(Console.Out)); var parser = new CParser(); var tu = parser.ParseTranslationUnit("_internal.h", prototype + ";", ((_, __) => null), report); var compiler = new Compiler.CCompiler(machineInfo, report); compiler.Add(tu); var exe = compiler.Compile(); if (tu.Functions.Count == 0) { throw new Exception("Failed to parse function prototype: " + prototype); } var f = tu.Functions[0]; Name = f.Name; NameContext = f.NameContext; FunctionType = f.FunctionType; if (action != null) { Action = action; } else { Action = _ => { }; } }
public InternalFunction(string name, string nameContext, CFunctionType functionType) { Name = name; NameContext = nameContext; FunctionType = functionType; Action = _ => { }; }
public InternalFunction(MachineInfo machineInfo, string prototype, InternalFunctionAction action = null) { var report = new Report(new Report.TextWriterPrinter(Console.Out)); var parser = new CParser(); var pp = new Preprocessor(report); pp.AddCode("<Internal>", prototype + ";"); var tu = parser.ParseTranslationUnit(new Lexer(pp)); Compiler compiler = new Compiler(machineInfo, report); compiler.Add(tu); var exe = compiler.Compile(); if (tu.Functions.Count == 0) { throw new Exception("Failed to parse function prototype: " + prototype); } var f = tu.Functions[0]; Name = f.Name; NameContext = f.NameContext; FunctionType = f.FunctionType; Action = action; }
public InternalFunction(string prototype, InternalFunctionAction action = null) { var report = new Report(new TextWriterReportPrinter(Console.Out)); var parser = new CParser(); var pp = new Preprocessor(report); pp.AddCode("<Internal>", prototype + ";"); var tu = parser.ParseTranslationUnit(new Lexer(pp), report); var f = tu.Functions[0]; Name = f.Name; FunctionType = f.FunctionType; Action = action; }
public void AddInternalFunction(string prototype, InternalFunctionAction action = null) { InternalFunctions.Add(new InternalFunction(this, prototype, action)); }