//private List<SymbolDefField> nestedSymbolInfos; public override Exp Analy(AnalyExpContext context) { base.Analy(context); createContext(this.AnalyExpContext); var symbols = this.AnalyExpContext.Symbols; analyOutClassField(this.AnalyExpContext, false, context.ClassContext.ClassSymbol.ClassBuilder); analyFields(false); if (RetType != typeof(void)) { retSymbol = new SymbolVar("结果", RetType); retSymbol.IsAssigned = true; retSymbol.LoacalVarIndex = this.NestedMethodContext.CreateLocalVarIndex("结果"); symbols.AddSafe(retSymbol); } BodyExp = BodyExp.Analy(this.AnalyExpContext); if (FnRetType != typeof(Action)) { if (RetType != typeof(bool)) { error(BodyExp.Postion, "返回结果的类型不匹配"); return(null); } } return(this); }
public override void Generate(EmitExpContext context) { var il = NestedMethodContext.EmitContext.CurrentMethodBuilder.GetILGenerator(); EmitStmtContext stmtContext = new EmitStmtContext(NestedMethodContext.EmitContext); EmitExpContext expContext = new EmitExpContext(stmtContext); if (retSymbol != null) { retSymbol.VarBuilder = il.DeclareLocal(retSymbol.DimType); } //GenerateBodyExpHead(context); BodyExp.Generate(expContext); if (retSymbol == null) { if (BodyExp.RetType != typeof(void)) { il.Emit(OpCodes.Pop); } } else { EmitHelper.StormVar(il, retSymbol.VarBuilder); } if (RetType != typeof(void)) { il.Emit(OpCodes.Ldloc, retSymbol.VarBuilder); } il.Emit(OpCodes.Ret); generateConstructor(context); NestedType = NestedClassContext.EmitContext.CurrentTypeBuilder.CreateType(); base.GenerateConv(context); }
//private List<SymbolDefField> nestedSymbolInfos; public override Exp Analy( ) { CreateContext(); AnalyFields(); BodyExp.SetContext(NestedExpContext); BodyExp.SetIsNested(true); if (FnRetType == ZTypeManager.ZBOOL) { retSymbol = new SymbolLocalVar("$RetResult", FnRetType); } return(this); }
private void CreateContext() { NestedClassContext = new ContextClass(this.ExpContext.FileContext); NestedClassContext.ClassName = this.ExpContext.ProcContext.CreateNestedClassName(); NestedProcContext = new ContextProc(NestedClassContext); NestedProcContext.ProcName = NestedClassContext.ClassName + "$CALL"; NestedProcContext.ProcManagerContext = NestedClassContext.ProcManagerContext; NestedProcContext.ProcManagerContext.Add(NestedProcContext); NestedStmt = new StmtCall(); NestedStmt.ProcContext = NestedProcContext; NestedExpContext = new ContextExp(NestedProcContext, NestedStmt); BodyExp.SetContext(NestedExpContext); CreateEmitContext(); }
public override void Emit() { var il = NestedProcContext.EmitContext.ILout; BodyExp.Emit(); if (retSymbol == null) { if (BodyExp.RetType.SharpType != typeof(void)) { il.Emit(OpCodes.Pop); } } else { EmitHelper.StormVar(il, retSymbol.VarBuilder); } il.Emit(OpCodes.Ret); EmitConstructor(); NestedType = NestedClassContext.EmitContext.ClassBuilder.CreateType(); base.EmitConv(); }
public override Exp[] GetSubExps() { return(BodyExp.GetSubExps()); }
public override string ToString() { return(BodyExp.ToString()); }
public override void GetNestedFields(Dictionary <string, VarExp> nestedField) { BodyExp.GetNestedFields(nestedField); }