private ILanguageExpression CompileMacroCall(GMacMacro macro, OperandsByValueAccess operands) { PushRecord(macro.ChildScope, false); foreach (var param in macro.Parameters) { CompileVariable(param); //Set the initial values of all parameters of called macro to their default var defaultAssignmentCommand = new OperandsByValueAccessAssignment( LanguageValueAccess.Create(param), GMacRootAst.CreateDefaultValue(param.SymbolType) ); CompileParameterAssignment(defaultAssignmentCommand); } foreach (var command in operands.AssignmentsList) { CompileParameterAssignment(command); } //this.Visit(macro.ProcedureBody); Visit(macro.OptimizedCompiledBody); var compiledOutputVariable = GetSymbolData(macro.OutputParameter); PopRecord(); return(LanguageValueAccess.Create(compiledOutputVariable)); }
//public override void ResetOnAcquire() //{ // base.ResetOnAcquire(); // _generatedNamespace = null; //} private void translate_Namespace() { try { Context.MarkCheckPointState(); //Read the namespace name: for example main.conformal.cga5d var qualList = GenUtils.Translate_Qualified_Identifier(RootParseNode.ChildNodes[0]); //Find the root namespace inside the root global scope of the GMacDSL (search for a namespace called 'main') GMacNamespace nameSpace; if (GMacRootAst.LookupRootNamespace(qualList.FirstItem, out nameSpace) == false) { if (GMacRootAst.RootScope.SymbolExists(qualList.FirstItem)) { CompilationLog.RaiseGeneratorError <int>("Namespace name already used", RootParseNode.ChildNodes[0]); } nameSpace = GMacRootAst.DefineRootNamespace(qualList.FirstItem); } //Starting from the created\found root namespace, repeat the previous operation for each child namespace in qual_list for (var i = 1; i < qualList.ActiveLength; i++) { GMacNamespace childNamespace; if (nameSpace.LookupNamespace(qualList[i], out childNamespace)) { nameSpace = childNamespace; } else { if (nameSpace.CanDefineChildSymbol(qualList[i]) == false) { CompilationLog.RaiseGeneratorError <int>("Symbol with same name already exists", RootParseNode.ChildNodes[0]); } nameSpace = nameSpace.DefineNamespace(qualList[i]); } } _generatedNamespace = nameSpace; _generatedNamespace.AddCodeLocation(Context.GetCodeLocation(RootParseNode)); Context.UnmarkCheckPointState(); Context.CompilationLog.ReportNormal("Translated Namespace: " + _generatedNamespace.SymbolAccessName, ProgressEventArgsResult.Success); } catch (CompilerException) { Context.RestoreToCheckPointState(); Context.CompilationLog.ReportNormal("Translate Namespace Failed", ProgressEventArgsResult.Failure); } catch (Exception e) { Context.RestoreToCheckPointState(); Context.CompilationLog.ReportError("Translate Namespace Failed With Error", e); } }