コード例 #1
0
        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 = _ => { };
            }
        }
コード例 #2
0
 public InternalFunction(string name, string nameContext, CFunctionType functionType)
 {
     Name         = name;
     NameContext  = nameContext;
     FunctionType = functionType;
     Action       = _ => { };
 }
コード例 #3
0
        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;
        }
コード例 #4
0
ファイル: InternalFunction.cs プロジェクト: arlm/CLanguage
        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;
        }
コード例 #5
0
ファイル: MachineInfo.cs プロジェクト: thurday/CLanguage
 public void AddInternalFunction(string prototype, InternalFunctionAction action = null)
 {
     InternalFunctions.Add(new InternalFunction(this, prototype, action));
 }