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; } }
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); }
public override Exp Analy() { if (this.IsAnalyed) { return(this); } VarName = VarToken.Text; ArgSymbol = this.ProcContext.GetParameter(VarName); RetType = ArgSymbol.ZParamType; IsAnalyed = true; return(this); }
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); //} }
public bool AddParameter(ZCParamInfo zcparam)//(SymbolArg argSymbol) { return(ZConstructorInfo.AddParameter(zcparam)); //_argDefDict.Add(argSymbol.Name, argSymbol); }
public static void EmitLoad(ILGenerator il, ZCParamInfo zcparam) { ILGeneratorUtil.LoadArg(il, zcparam.EmitIndex); }
public static void EmitStorm(ILGenerator il, ZCParamInfo argsymbol) { EmitHelper.StormArg(il, argsymbol.EmitIndex); }
public bool AddParameter(ZCParamInfo zcparam) { return(ZMethodInfo.AddParameter(zcparam)); }
public virtual void DefineParameter(ZCParamInfo zcparam) { zcparam.DefineParameter(); }
protected void EmitArgExp(ZCParamInfo parameter, Exp argExp) { argExp.RequireType = parameter.ZParamType; argExp.Emit(); }