public override bool Compile(out int blockId, ProtoCore.DSASM.CodeBlock parentBlock, ProtoCore.LanguageCodeBlock langBlock, ProtoCore.CompileTime.Context callContext, ProtoCore.DebugServices.EventSink sink, ProtoCore.AST.Node codeBlockNode, ProtoCore.AssociativeGraph.GraphNode graphNode = null) { Validity.Assert(langBlock != null); blockId = ProtoCore.DSASM.Constants.kInvalidIndex; bool buildSucceeded = false; bool isLanguageSignValid = isLanguageSignValid = core.Langverify.Verify(langBlock); if (isLanguageSignValid) { try { ProtoImperative.CodeGen codegen = new ProtoImperative.CodeGen(core, callContext, parentBlock); codegen.context = callContext; codegen.codeBlock.EventSink = sink; blockId = codegen.Emit(codeBlockNode as ProtoCore.AST.ImperativeAST.CodeBlockNode, graphNode); } catch (ProtoCore.BuildHaltException) { } buildSucceeded = core.BuildStatus.BuildSucceeded; } return buildSucceeded; }
public override bool Compile(ProtoLanguage.CompileStateTracker compileState, out int blockId, ProtoCore.DSASM.CodeBlock parentBlock, ProtoCore.LanguageCodeBlock langBlock, ProtoCore.CompileTime.Context callContext, ProtoCore.DebugServices.EventSink sink, ProtoCore.AST.Node codeBlockNode, ProtoCore.AssociativeGraph.GraphNode graphNode = null) { Debug.Assert(langBlock != null); blockId = ProtoCore.DSASM.Constants.kInvalidIndex; bool buildSucceeded = false; bool isLanguageSignValid = isLanguageSignValid = compileState.Langverify.Verify(langBlock); if (isLanguageSignValid) { try { ProtoImperative.CodeGen codegen = new ProtoImperative.CodeGen(compileState, parentBlock); codegen.context = callContext; codegen.codeBlock.EventSink = sink; blockId = codegen.Emit(codeBlockNode as ProtoCore.AST.ImperativeAST.CodeBlockNode, graphNode); } catch (ProtoCore.BuildHaltException e) { #if DEBUG //core.BuildStatus.LogSemanticError(e.errorMsg); #endif } int errors = 0; int warnings = 0; buildSucceeded = compileState.BuildStatus.GetBuildResult(out errors, out warnings); } return(buildSucceeded); }
public override bool Compile(ProtoLanguage.CompileStateTracker compileState, out int blockId, ProtoCore.DSASM.CodeBlock parentBlock, ProtoCore.LanguageCodeBlock langBlock, ProtoCore.CompileTime.Context callContext, ProtoCore.DebugServices.EventSink sink, ProtoCore.AST.Node codeBlockNode, ProtoCore.AssociativeGraph.GraphNode graphNode = null) { Debug.Assert(langBlock != null); blockId = ProtoCore.DSASM.Constants.kInvalidIndex; bool buildSucceeded = false; bool isLanguageSignValid = isLanguageSignValid = compileState.Langverify.Verify(langBlock); if (isLanguageSignValid) { try { ProtoImperative.CodeGen codegen = new ProtoImperative.CodeGen(compileState, parentBlock); codegen.context = callContext; codegen.codeBlock.EventSink = sink; blockId = codegen.Emit(codeBlockNode as ProtoCore.AST.ImperativeAST.CodeBlockNode, graphNode); } catch (ProtoCore.BuildHaltException e) { #if DEBUG //core.BuildStatus.LogSemanticError(e.errorMsg); #endif } int errors = 0; int warnings = 0; buildSucceeded = compileState.BuildStatus.GetBuildResult(out errors, out warnings); } return buildSucceeded; }
public override bool Compile(out int blockId, ProtoCore.DSASM.CodeBlock parentBlock, ProtoCore.LanguageCodeBlock langBlock, ProtoCore.CompileTime.Context callContext, ProtoCore.DebugServices.EventSink sink, ProtoCore.AST.Node codeBlockNode, ProtoCore.AssociativeGraph.GraphNode graphNode = null) { Validity.Assert(langBlock != null); blockId = ProtoCore.DSASM.Constants.kInvalidIndex; bool buildSucceeded = false; bool isLanguageSignValid = isLanguageSignValid = core.Langverify.Verify(langBlock); if (isLanguageSignValid) { try { ProtoImperative.CodeGen codegen = new ProtoImperative.CodeGen(core, callContext, parentBlock); codegen.context = callContext; codegen.codeBlock.EventSink = sink; blockId = codegen.Emit(codeBlockNode as ProtoCore.AST.ImperativeAST.CodeBlockNode, graphNode); } catch (ProtoCore.BuildHaltException) { } buildSucceeded = core.BuildStatus.BuildSucceeded; } return(buildSucceeded); }
static public void LoadAndExecute(string pathFilename, ProtoCore.Core core) { ProtoImperative.AST.GenAST genast = new ProtoImperative.AST.GenAST(); ProtoImperative.AST.CodeBlockNode codeblock = genast.GenerateAST(pathFilename, core); ProtoImperative.CodeGen codegen = new ProtoImperative.CodeGen(core); codegen.Emit(codeblock); //core.executable = codegen.executable; ProtoCore.DSASM.Interpreter interpreter = new ProtoCore.DSASM.Interpreter(core); interpreter.Run(); }
public static void LoadAndExecute(string pathFilename, ProtoCore.Core core) { ProtoImperative.AST.GenAST genast = new ProtoImperative.AST.GenAST(); ProtoImperative.AST.CodeBlockNode codeblock = genast.GenerateAST(pathFilename, core); ProtoImperative.CodeGen codegen = new ProtoImperative.CodeGen(core); codegen.Emit(codeblock); //core.executable = codegen.executable; ProtoCore.DSASM.Interpreter interpreter = new ProtoCore.DSASM.Interpreter(core); interpreter.Run(); }
public override bool Compile(out int blockId, ProtoCore.DSASM.CodeBlock parentBlock, ProtoCore.LanguageCodeBlock langBlock, ProtoCore.CompileTime.Context callContext, ProtoCore.DebugServices.EventSink sink, ProtoCore.AST.Node codeBlockNode, ProtoCore.AssociativeGraph.GraphNode graphNode = null) { Debug.Assert(langBlock != null); blockId = ProtoCore.DSASM.Constants.kInvalidIndex; bool buildSucceeded = false; bool isLanguageSignValid = isLanguageSignValid = core.Langverify.Verify(langBlock); if (isLanguageSignValid) { try { ProtoImperative.CodeGen codegen = new ProtoImperative.CodeGen(core, parentBlock); //(Fuqiang, Ayush) : The below code is to parse an Imperative code block. An imoerative code block should // never need to be parsed at this stage, as it would be parsed by the Assoc parser. //System.IO.MemoryStream memstream = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(langBlock.body)); //ProtoCore.DesignScriptParser.Scanner s = new ProtoCore.DesignScriptParser.Scanner(memstream); //ProtoCore.DesignScriptParser.Parser p = new ProtoCore.DesignScriptParser.Parser(s, core); //System.IO.StringWriter parseErrors = new System.IO.StringWriter(); //p.errors.errorStream = parseErrors; //p.Parse(); //if (parseErrors.ToString() != String.Empty) //{ // core.BuildStatus.LogSyntaxError(parseErrors.ToString()); //} //core.BuildStatus.errorCount += p.errors.count; codegen.context = callContext; codegen.codeBlock.EventSink = sink; blockId = codegen.Emit(codeBlockNode as ProtoCore.AST.ImperativeAST.CodeBlockNode, graphNode); } catch (ProtoCore.BuildHaltException e) { #if DEBUG //core.BuildStatus.LogSemanticError(e.errorMsg); #endif } int errors = 0; int warnings = 0; buildSucceeded = core.BuildStatus.GetBuildResult(out errors, out warnings); } return(buildSucceeded); }
public override bool Compile(out int blockId, ProtoCore.DSASM.CodeBlock parentBlock, ProtoCore.LanguageCodeBlock langBlock, ProtoCore.CompileTime.Context callContext, ProtoCore.DebugServices.EventSink sink, ProtoCore.AST.Node codeBlockNode, ProtoCore.AssociativeGraph.GraphNode graphNode = null) { Debug.Assert(langBlock != null); blockId = ProtoCore.DSASM.Constants.kInvalidIndex; bool buildSucceeded = false; bool isLanguageSignValid = isLanguageSignValid = core.Langverify.Verify(langBlock); if (isLanguageSignValid) { try { ProtoImperative.CodeGen codegen = new ProtoImperative.CodeGen(core, parentBlock); //(Fuqiang, Ayush) : The below code is to parse an Imperative code block. An imoerative code block should // never need to be parsed at this stage, as it would be parsed by the Assoc parser. //System.IO.MemoryStream memstream = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(langBlock.body)); //ProtoCore.DesignScriptParser.Scanner s = new ProtoCore.DesignScriptParser.Scanner(memstream); //ProtoCore.DesignScriptParser.Parser p = new ProtoCore.DesignScriptParser.Parser(s, core); //System.IO.StringWriter parseErrors = new System.IO.StringWriter(); //p.errors.errorStream = parseErrors; //p.Parse(); //if (parseErrors.ToString() != String.Empty) //{ // core.BuildStatus.LogSyntaxError(parseErrors.ToString()); //} //core.BuildStatus.errorCount += p.errors.count; codegen.context = callContext; codegen.codeBlock.EventSink = sink; blockId = codegen.Emit(codeBlockNode as ProtoCore.AST.ImperativeAST.CodeBlockNode, graphNode); } catch (ProtoCore.BuildHaltException e) { #if DEBUG //core.BuildStatus.LogSemanticError(e.errorMsg); #endif } int errors = 0; int warnings = 0; buildSucceeded = core.BuildStatus.GetBuildResult(out errors, out warnings); } return buildSucceeded; }