Esempio n. 1
0
        private void AnalyType()
        {
            if (_IsExist)
            {
                return;
            }
            ContextImportUse contextiu = this.FileContext.ImportUseContext;

            string[] names = contextiu.GetArgSegementer().Cut(ArgText);
            if (names.Length != 2)
            {
                throw new CCException();
            }
            ArgZTypeName = names[0];
            ArgName      = names[1];
            if (this.MethodContext.HasParameter(ArgName))
            {
                _IsExist = true;
                CodePosition argPos = new CodePosition(ParameterRaw.ParameterToken.Line, ParameterRaw.ParameterToken.Col + ArgZTypeName.Length);
                FileContext.Errorf(argPos, "参数'{0}'重复", ArgName);
            }
            else
            {
                ZType[] ztypes = contextiu.SearchZTypesByClassNameOrDimItem(ArgZTypeName);
                ArgZType = ztypes[0];
                //_argSymbol = new SymbolArg(ArgName, ArgZType);
                //this.ProcContext.AddParameter(_argSymbol);
                //_argSymbol = new ZCParamInfo(ArgName, ArgZType);
                //ProcContext.AddParameter(_argSymbol);
                _ZCParam            = MethodContext.AddParameterName(ArgName);
                _ZCParam.ZParamType = ArgZType;
            }
        }
Esempio n. 2
0
        public ContextNestedClass CreateNestedClassContext()
        {
            if (_NestedClassContext == null)
            {
                _NestedClassContext = new ContextNestedClass(this);
                _NestedClassContext.SetClassName(this.CreateNestedClassName());
                var nestedClassInstanceName = _NestedClassContext.ClassName + "_0";

                var            packageName        = this.ClassContext.FileContext.ProjectContext.ProjectModel.ProjectPackageName;
                string         fullName           = packageName + "." + _NestedClassContext.ClassName;
                TypeAttributes typeAttrs          = TypeAttributes.NestedPrivate | TypeAttributes.Sealed;
                TypeBuilder    NestedClassBuilder = this.ClassContext.SelfCompilingType.ClassBuilder.DefineNestedType(fullName, typeAttrs);
                _NestedClassContext.SetTypeBuilder(NestedClassBuilder);

                ZCClassInfo ztype = _NestedClassContext.SelfCompilingType;
                if (NestedInstance == null)
                {
                    NestedInstance = new ZCLocalVar(nestedClassInstanceName, ztype, true)
                    {
                        IsNestedClassInstance = true
                    };
                    this.LocalManager.Add(NestedInstance);
                }

                if (!this.IsStatic())
                {
                    ZCFieldInfo zf2 = _NestedClassContext.SelfCompilingType.DefineFieldPublic
                                          (ContextNestedClass.MasterClassFieldName, this.ClassContext.SelfCompilingType);
                    _NestedClassContext.MasterClassField = zf2;
                }

                if (this.ArgList.Count > 0)
                {
                    foreach (var arg in this.ArgList)
                    {
                        ZCParamInfo zp  = this.GetParameter(arg);
                        ZCFieldInfo zf3 = _NestedClassContext.SelfCompilingType.DefineFieldPublic
                                              (arg, zp.GetZClass());
                        _NestedClassContext.MasterArgDict.Add(arg, zf3);
                    }
                }
                /* 生成内部类默认构造函数 */
                {
                    ConstructorBuilder NewBuilder = NestedClassBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, new Type[] { });
                    var il = NewBuilder.GetILGenerator();
                    il.Emit(OpCodes.Ret);
                    ZCConstructorInfo zcc = new ZCConstructorInfo(this._NestedClassContext.SelfCompilingType)
                    {
                        ConstructorBuilder = NewBuilder
                    };
                    this._NestedClassContext.SelfCompilingType.AddConstructord(zcc);
                    this._NestedClassContext.DefaultConstructorBuilder = NewBuilder;
                }
            }
            return(_NestedClassContext);
        }
Esempio n. 3
0
 public override Exp Analy()
 {
     if (this.IsAnalyed)
     {
         return(this);
     }
     VarName   = VarToken.Text;
     ArgSymbol = this.ProcContext.GetParameter(VarName);
     RetType   = ArgSymbol.ZParamType;
     IsAnalyed = true;
     return(this);
 }
Esempio n. 4
0
        private void EmitInitArg(LocalBuilder lanmbdaLocalBuilder)
        {
            if (this.ProcContext.ArgList.Count > 0)
            {
                foreach (var arg in this.ProcContext.ArgList)
                {
                    ZCParamInfo paramSymbol = this.ProcContext.GetParameter(arg);
                    ZCFieldInfo fieldSymbol = this.ProcContext.GetNestedClassContext().MasterArgDict[arg];
                    EmitHelper.LoadVar(IL, lanmbdaLocalBuilder);
                    EmitSymbolHelper.EmitLoad(IL, paramSymbol);
                    EmitSymbolHelper.EmitStorm(IL, fieldSymbol);
                }
            }

            //for (int i = 0; i < this.lambdaInfo.BodyZParams.Count; i++)
            //{
            //    ZCParamInfo paramSymbol = this.lambdaInfo.BodyZParams[i];
            //    ZCFieldInfo fieldSymbol = lambdaExp.lambdaBody.Get(paramSymbol.ZName);
            //    EmitHelper.LoadVar(IL, lanmbdaLocalBuilder);
            //    EmitSymbolHelper.EmitLoad(IL, paramSymbol);
            //    EmitSymbolHelper.EmitStorm(IL, fieldSymbol);
            //}
        }
Esempio n. 5
0
 public bool AddParameter(ZCParamInfo zcparam)//(SymbolArg argSymbol)
 {
     return(ZConstructorInfo.AddParameter(zcparam));
     //_argDefDict.Add(argSymbol.Name, argSymbol);
 }
Esempio n. 6
0
 public static void EmitLoad(ILGenerator il, ZCParamInfo zcparam)
 {
     ILGeneratorUtil.LoadArg(il, zcparam.EmitIndex);
 }
Esempio n. 7
0
 public static void EmitStorm(ILGenerator il, ZCParamInfo argsymbol)
 {
     EmitHelper.StormArg(il, argsymbol.EmitIndex);
 }
Esempio n. 8
0
 public bool AddParameter(ZCParamInfo zcparam)
 {
     return(ZMethodInfo.AddParameter(zcparam));
 }
Esempio n. 9
0
 public virtual void DefineParameter(ZCParamInfo zcparam)
 {
     zcparam.DefineParameter();
 }
Esempio n. 10
0
 protected void EmitArgExp(ZCParamInfo parameter, Exp argExp)
 {
     argExp.RequireType = parameter.ZParamType;
     argExp.Emit();
 }