Beispiel #1
0
 public static void EmitLocalVar(ContextProc procContext, bool isStatic, ILGenerator IL, List <ZCLocalVar> localList)
 {
     localList.Reverse();
     for (int i = 0; i < localList.Count; i++)
     {
         ZCLocalVar varSymbol = localList[i];
         varSymbol.VarBuilder = IL.DeclareLocal(ZTypeUtil.GetTypeOrBuilder(varSymbol.GetZType()));
         varSymbol.VarBuilder.SetLocalSymInfo(varSymbol.ZName);
     }
     for (int i = 0; i < localList.Count; i++)
     {
         ZCLocalVar varSymbol = localList[i];
         if (varSymbol.IsNestedClassInstance)
         {
             LocalBuilder       lanmbdaLocalBuilder = procContext.NestedInstance.VarBuilder;
             ConstructorBuilder newBuilder          = procContext.GetNestedClassContext().DefaultConstructorBuilder;
             IL.Emit(OpCodes.Newobj, newBuilder);
             EmitHelper.StormVar(IL, lanmbdaLocalBuilder);
             if (!isStatic)
             {
                 ZCFieldInfo masterClassField = procContext.GetNestedClassContext().MasterClassField;
                 if (masterClassField != null)
                 {
                     ILGeneratorUtil.LoadLocal(IL, lanmbdaLocalBuilder);
                 }
                 IL.Emit(OpCodes.Ldarg_0);
                 EmitSymbolHelper.EmitStorm(IL, masterClassField);
             }
         }
     }
 }
Beispiel #2
0
        public override Exp Analy( )
        {
            if (this.IsAnalyed)
            {
                return(this);
            }
            var subjType = ListSymbol.GetZType();

            ZLClassInfo zclass = subjType as ZLClassInfo;

            Property  = zclass.SharpType.GetProperty(ZLangUtil.ZListItemPropertyName);
            RetType   = ZTypeManager.GetBySharpType(Property.PropertyType) as ZType;
            IsAnalyed = true;
            return(this);
        }
Beispiel #3
0
        public bool ReplaceLocalToField(string varName)
        {
            if (this.ContainsPropertyName(varName))
            {
                return(false);
            }
            ZCLocalVar  localVar           = this.MasterProcContext.LocalManager.GetDefLocal(varName);
            ZType       ztype              = localVar.GetZType();
            Type        varSharpType       = ZTypeUtil.GetTypeOrBuilder(ztype);
            var         NestedClassBuilder = this.SelfCompilingType.ClassBuilder;
            ZCFieldInfo zf = this.SelfCompilingType.DefineFieldPublic(varName, (ZAClassInfo)ztype);

            localVar.IsReplaceToNestedFiled = true;
            this.MasterProcContext.LocalManager.DecLocalIndex(varName);
            return(true);
        }
Beispiel #4
0
        public override Stmt Analy()
        {
            TypeArgParser parser = new TypeArgParser(this.ProcContext.ClassContext);

            TypeArgParser.ParseResult result = parser.Parse(Raw.ExceptionTypeVarToken);
            if (result.ResultCount == 1)
            {
                exTypeName = result.ArgZTypes[0].ZTypeName;
                exType     = (ZLType)result.ArgZTypes[0];
                exName     = result.ArgName;
            }
            if (this.ProcContext.ContainsVarName(exName) == false)
            {
                exSymbol = new ZCLocalVar(exName, exType, true);
                //exSymbol.LoacalVarIndex =this.ProcContext.CreateLocalVarIndex(exName);
                this.ProcContext.AddLocalVar(exSymbol);
            }
            else
            {
                if (this.ProcContext.LocalManager.IsDefLocal(exName))
                {
                    exSymbol = this.ProcContext.LocalManager.GetDefLocal(exName);
                    if (exSymbol.GetZType() != exType)
                    {
                        Errorf(Raw.ExceptionTypeVarToken.Position, "变量'{0}'的类型与异常的类型不一致", exName);
                    }
                }
                else
                {
                    Errorf(Raw.ExceptionTypeVarToken.Position, "变量名称'{0}'已经使用过", exName);
                }
            }
            //CatchBody.ProcContext = this.ProcContext;
            StmtBody.Analy();
            return(this);
        }