protected override void DoDefineContainer() { TypeSpec ut; if (underlying_type_expr != null) { ut = underlying_type_expr.ResolveAsType(this); if (!EnumSpec.IsValidUnderlyingType(ut)) { Error_UnderlyingType(underlying_type_expr.Location); ut = null; } } else { ut = null; } if (ut == null) { ut = Compiler.BuiltinTypes.Int; } ((EnumSpec)spec).UnderlyingType = ut; TypeBuilder.DefineField(UnderlyingValueField, UnderlyingType.GetMetaInfo(), FieldAttributes.Public | FieldAttributes.SpecialName | FieldAttributes.RTSpecialName); DefineBaseTypes(); }
protected override bool DoDefineMembers() { var builtin_types = Compiler.BuiltinTypes; var ctor_parameters = ParametersCompiled.CreateFullyResolved( new [] { new Parameter(new TypeExpression(builtin_types.Object, Location), "object", Parameter.Modifier.NONE, null, Location), new Parameter(new TypeExpression(builtin_types.IntPtr, Location), "method", Parameter.Modifier.NONE, null, Location) }, new [] { builtin_types.Object, builtin_types.IntPtr } ); Constructor = new Constructor(this, Constructor.ConstructorName, Modifiers.PUBLIC, null, ctor_parameters, Location); Constructor.Define(); // // Here the various methods like Invoke, BeginInvoke etc are defined // // First, call the `out of band' special method for // defining recursively any types we need: // var p = parameters; if (!p.Resolve(this)) { return(false); } // // Invoke method // // Check accessibility foreach (var partype in p.Types) { if (!IsAccessibleAs(partype)) { Report.SymbolRelatedToPreviousError(partype); Report.Error(59, Location, "Inconsistent accessibility: parameter type `{0}' is less accessible than delegate `{1}'", TypeManager.CSharpName(partype), GetSignatureForError()); } } var ret_type = ReturnType.ResolveAsType(this); if (ret_type == null) { return(false); } // // We don't have to check any others because they are all // guaranteed to be accessible - they are standard types. // if (!IsAccessibleAs(ret_type)) { Report.SymbolRelatedToPreviousError(ret_type); Report.Error(58, Location, "Inconsistent accessibility: return type `" + TypeManager.CSharpName(ret_type) + "' is less " + "accessible than delegate `" + GetSignatureForError() + "'"); return(false); } CheckProtectedModifier(); if (Compiler.Settings.StdLib && ret_type.IsSpecialRuntimeType) { Method.Error1599(Location, ret_type, Report); return(false); } TypeManager.CheckTypeVariance(ret_type, Variance.Covariant, this); var resolved_rt = new TypeExpression(ret_type, Location); InvokeBuilder = new Method(this, resolved_rt, MethodModifiers, new MemberName(InvokeMethodName), p, null); InvokeBuilder.Define(); // // Don't emit async method for compiler generated delegates (e.g. dynamic site containers) // if (!IsCompilerGenerated) { DefineAsyncMethods(Parameters.CallingConvention, resolved_rt); } return(true); }
public void Resolve(IMemberContext context) { type = Type.ResolveAsType(context); }
protected override Expression DoResolve(ResolveContext rc) { // BEN: This won't work because the returned type won't pass Mono's type checkers. // if (rc.Target == Target.JavaScript) { // this.type = rc.Module.PredefinedTypes.AsArray.Resolve(); // this.eclass = ExprClass.Value; // foreach (var elem in Elements) // elem.Resolve (rc); // return this; // } TypeExpression type; if (vectorType != null) { var elemTypeSpec = vectorType.ResolveAsType(rc); if (elemTypeSpec != null) { type = new TypeExpression( rc.Module.PredefinedTypes.AsVector.Resolve().MakeGenericType(rc, new [] { elemTypeSpec }), Location); } else { type = new TypeExpression(rc.Module.PredefinedTypes.AsArray.Resolve(), Location); } } else if (inferredArrayType != null) { type = new TypeExpression(inferredArrayType, Location); } else if (variable != null) { if (variable.TypeExpression is VarExpr) { type = new TypeExpression(rc.Module.PredefinedTypes.AsArray.Resolve(), Location); } else if (variable.Variable.Type == rc.BuiltinTypes.Dynamic) { type = new TypeExpression(rc.Module.PredefinedTypes.AsArray.Resolve(), Location); } else { type = new TypeExpression(variable.Variable.Type, variable.Variable.Location); } } else if (assign != null && assign.Target.Type != null) { if (assign.Target.Type == rc.BuiltinTypes.Dynamic) { type = new TypeExpression(rc.Module.PredefinedTypes.AsArray.Resolve(), Location); } else { type = new TypeExpression(assign.Target.Type, assign.Target.Location); } } else { type = new TypeExpression(rc.Module.PredefinedTypes.AsArray.Resolve(), Location); } TypeSpec typeSpec = type.ResolveAsType(rc.MemberContext); if (typeSpec.IsArray) { ArrayCreation arrayCreate = (ArrayCreation) new ArrayCreation(type, this).Resolve(rc); return(arrayCreate); } else { var initElems = new List <Expression>(); foreach (var e in elements) { initElems.Add(new CollectionElementInitializer(e)); } return(new NewInitialize(type, null, new CollectionOrObjectInitializers(initElems, Location), Location).Resolve(rc)); } }