Example #1
0
        //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);
        }
Example #2
0
        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);
        }
Example #3
0
        //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);
        }
Example #4
0
        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();
        }
Example #5
0
        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();
        }
Example #6
0
 public override Exp[] GetSubExps()
 {
     return(BodyExp.GetSubExps());
 }
Example #7
0
 public override string ToString()
 {
     return(BodyExp.ToString());
 }
Example #8
0
 public override void GetNestedFields(Dictionary <string, VarExp> nestedField)
 {
     BodyExp.GetNestedFields(nestedField);
 }