Example #1
0
        public static bool Compile(string src, string entryFile)
        {
            ProtoLanguage.CompileOptions ops = new ProtoLanguage.CompileOptions();
            ops.RootModulePathName = entryFile;
            if (null != AutoCompletionHelper.searchPaths)
            {
                ops.IncludeDirectories.AddRange(AutoCompletionHelper.searchPaths);
            }

            compileState = new ProtoLanguage.CompileStateTracker(ops);

            compileState.CurrentDSFileName = entryFile;

            CoreCodeGen.ResetInternalStates();
            ProtoFFI.DLLFFIHandler.Register(ProtoFFI.FFILanguage.CSharp, new ProtoFFI.CSModuleHelper());

            // Register a message stream if we do have one.
            if (null != AutoCompletionHelper.MessageHandler)
            {
                compileState.BuildStatus.MessageHandler = MessageHandler;
            }

            MemoryStream ms = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(src));

            ProtoCore.DesignScriptParser.Scanner s = new ProtoCore.DesignScriptParser.Scanner(ms);
            ProtoCore.DesignScriptParser.Parser  p = new ProtoCore.DesignScriptParser.Parser(s, compileState);

            try
            {
                p.Parse();

                CoreCodeGen.arrayTypeTable = new ArrayTypeTable();
                AssociativeCodeGen codegen = new AssociativeCodeGen(compileState);
                codegen.Emit(p.root as ProtoCore.AST.AssociativeAST.CodeBlockNode);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception Caught in CodeGen");
                System.Diagnostics.Debug.WriteLine(ex.Message);
                return(false);
            }

            return(true);
        }
Example #2
0
 public static void Reset()
 {
     CoreCodeGen.ResetInternalStates();
     AutoCompletionHelper.compileState = null;
 }