private void EmitLanguageBlockNode(ImperativeNode node, ref ProtoCore.Type inferedType) { if (IsParsingGlobal() || IsParsingGlobalFunctionBody()) { LanguageBlockNode langblock = node as LanguageBlockNode; //(Fuqiang, Ayush) : Throwing an assert stops NUnit. Negative tests expect to catch a // CompilerException, so we throw that instead. //Debug.Assert(ProtoCore.Language.kInvalid != langblock.codeblock.language); if (ProtoCore.Language.kInvalid == langblock.codeblock.language) { throw new ProtoCore.Exceptions.CompileErrorsOccured("Invalid language block"); } ProtoCore.CompileTime.Context context = new ProtoCore.CompileTime.Context(); int blockId = ProtoCore.DSASM.Constants.kInvalidIndex; if (globalProcIndex != ProtoCore.DSASM.Constants.kInvalidIndex && compileState.ProcNode == null) compileState.ProcNode = codeBlock.procedureTable.procList[globalProcIndex]; if (langblock.codeblock.language == Language.kAssociative) { AssociativeCodeGen codegen = new AssociativeCodeGen(compileState, codeBlock); blockId = codegen.Emit(langblock.CodeBlockNode as ProtoCore.AST.AssociativeAST.CodeBlockNode); } else if (langblock.codeblock.language == Language.kImperative) { ImperativeCodeGen codegen = new ImperativeCodeGen(compileState, codeBlock); blockId = codegen.Emit(langblock.CodeBlockNode as ProtoCore.AST.ImperativeAST.CodeBlockNode); } //core.Executives[langblock.codeblock.language].Compile(out blockId, codeBlock, langblock.codeblock, context, codeBlock.EventSink, langblock.CodeBlockNode); inferedType = compileState.InferedType; ExceptionRegistration registration = compileState.ExceptionHandlingManager.ExceptionTable.GetExceptionRegistration(blockId, globalProcIndex, globalClassIndex); if (registration == null) { registration = compileState.ExceptionHandlingManager.ExceptionTable.Register(blockId, globalProcIndex, globalClassIndex); Debug.Assert(registration != null); } } }
private void EmitLanguageBlockNode(AssociativeNode node, ref ProtoCore.Type inferedType, ProtoCore.DSASM.AssociativeSubCompilePass subPass = ProtoCore.DSASM.AssociativeSubCompilePass.kNone) { if (IsParsingGlobal() || IsParsingGlobalFunctionBody() || IsParsingMemberFunctionBody()) { if (subPass == ProtoCore.DSASM.AssociativeSubCompilePass.kUnboundIdentifier) { return; } LanguageBlockNode langblock = node as LanguageBlockNode; //Debug.Assert(ProtoCore.Language.kInvalid != langblock.codeblock.language); if (ProtoCore.Language.kInvalid == langblock.codeblock.language) throw new BuildHaltException("Invalid language block type"); ProtoCore.CompileTime.Context context = new ProtoCore.CompileTime.Context(); int blockId = ProtoCore.DSASM.Constants.kInvalidIndex; // Top block signifies the auto inserted global block bool isTopBlock = null == codeBlock.parent; // Set the current class scope so the next language can refer to it core.ClassIndex = globalClassIndex; if (globalProcIndex != ProtoCore.DSASM.Constants.kInvalidIndex && core.ProcNode == null) { if (globalClassIndex != ProtoCore.DSASM.Constants.kInvalidIndex) core.ProcNode = core.ClassTable.ClassNodes[globalClassIndex].vtable.procList[globalProcIndex]; else core.ProcNode = codeBlock.procedureTable.procList[globalProcIndex]; } if (langblock.codeblock.language == Language.kAssociative) { AssociativeCodeGen codegen = new AssociativeCodeGen(core, codeBlock); blockId = codegen.Emit(langblock.CodeBlockNode as ProtoCore.AST.AssociativeAST.CodeBlockNode); } else if (langblock.codeblock.language == Language.kImperative) { ImperativeCodeGen codegen = new ImperativeCodeGen(core, codeBlock); blockId = codegen.Emit(langblock.CodeBlockNode as ProtoCore.AST.ImperativeAST.CodeBlockNode); } //core.Executives[langblock.codeblock.language].Compile(out blockId, codeBlock, langblock.codeblock, context, codeBlock.EventSink, langblock.CodeBlockNode); inferedType = core.InferedType; ExceptionRegistration registration = core.ExceptionHandlingManager.ExceptionTable.GetExceptionRegistration(blockId, globalProcIndex, globalClassIndex); if (registration == null) { registration = core.ExceptionHandlingManager.ExceptionTable.Register(blockId, globalProcIndex, globalClassIndex); Debug.Assert(registration != null); } } }