public RuntimeBinderContext (DynamicContext ctx, Compiler.TypeSpec callingType)
		{
			this.ctx = ctx;
			this.module = ctx.Module;
			this.callingTypeImported = callingType;
		}
Esempio n. 2
0
 // Obsolete
 public static bool IsEnumType(TypeSpec t)
 {
     return(t.IsEnum);
 }
Esempio n. 3
0
		public RuntimeBinderContext (DynamicContext ctx, Compiler.TypeSpec currentType)
		{
			this.ctx = ctx.CompilerContext;
			this.currentType = currentType;
		}
Esempio n. 4
0
 /// <summary>
 ///   Returns the C# name of a type if possible, or the full type name otherwise
 /// </summary>
 static public string CSharpName(TypeSpec t)
 {
     return(t.GetSignatureForError());
 }
Esempio n. 5
0
 // Obsolete
 public static bool IsDelegateType(TypeSpec t)
 {
     return(t.IsDelegate);
 }
Esempio n. 6
0
        public static TypeSpec Resolve(ModuleContainer module, MemberKind kind, string ns, string name, int arity, bool reportErrors)
        {
            Namespace type_ns = module.GlobalRootNamespace.GetNamespace(ns, true);
            var       found   = type_ns.GetAllTypes(name);

            if (found == null)
            {
                if (reportErrors)
                {
                    module.Compiler.Report.Error(518, "The predefined type `{0}.{1}' is not defined or imported", ns, name);
                }

                return(null);
            }

            TypeSpec best_match = null;

            foreach (var candidate in found)
            {
                if (candidate.Kind != kind)
                {
                    if (candidate.Kind == MemberKind.Struct && kind == MemberKind.Void && candidate.MemberDefinition is TypeContainer)
                    {
                        // Void is declared as struct but we keep it internally as
                        // special kind, the swap will be done by caller
                    }
                    else
                    {
                        continue;
                    }
                }

                if (candidate.Arity != arity)
                {
                    continue;
                }

                if ((candidate.Modifiers & Modifiers.INTERNAL) != 0 && !candidate.MemberDefinition.IsInternalAsPublic(module.DeclaringAssembly))
                {
                    continue;
                }

                if (best_match == null)
                {
                    best_match = candidate;
                    continue;
                }

                var other_match = best_match;
                if (!best_match.MemberDefinition.IsImported &&
                    module.Compiler.BuiltinTypes.Object.MemberDefinition.DeclaringAssembly == candidate.MemberDefinition.DeclaringAssembly)
                {
                    best_match = candidate;
                }

                string location;
                if (best_match.MemberDefinition is MemberCore)
                {
                    location = ((MemberCore)best_match.MemberDefinition).Location.Name;
                }
                else
                {
                    var assembly = (ImportedAssemblyDefinition)best_match.MemberDefinition.DeclaringAssembly;
                    location = Path.GetFileName(assembly.Location);
                }

                module.Compiler.Report.SymbolRelatedToPreviousError(other_match);
                module.Compiler.Report.SymbolRelatedToPreviousError(candidate);

                module.Compiler.Report.Warning(1685, 1,
                                               "The predefined type `{0}.{1}' is defined multiple times. Using definition from `{2}'",
                                               ns, name, location);

                break;
            }

            if (best_match == null && reportErrors)
            {
                Location loc;
                if (found[0].MemberDefinition is MemberCore)
                {
                    loc = ((MemberCore)found[0].MemberDefinition).Location;
                }
                else
                {
                    loc = Location.Null;
                    module.Compiler.Report.SymbolRelatedToPreviousError(found[0]);
                }

                module.Compiler.Report.Error(520, loc, "The predefined type `{0}.{1}' is not declared correctly", ns, name);
            }

            return(best_match);
        }
Esempio n. 7
0
 public PredefinedMember(ModuleContainer module, TypeSpec type, MemberFilter filter)
 {
     this.module         = module;
     this.declaring_type = type;
     this.filter         = filter;
 }
Esempio n. 8
0
 /// <summary>
 ///   Check whether `type' and `parent' are both instantiations of the same
 ///   generic type.  Note that we do not check the type parameters here.
 /// </summary>
 public static bool IsInstantiationOfSameGenericType(TypeSpec type, TypeSpec parent)
 {
     return(type == parent || type.MemberDefinition == parent.MemberDefinition);
 }
Esempio n. 9
0
 public static TypeSpec[] GetTypeArguments(TypeSpec t)
 {
     // TODO: return empty array !!
     return(t.TypeArguments);
 }
Esempio n. 10
0
 public static bool IsGenericType(TypeSpec type)
 {
     return(type.IsGeneric);
 }
Esempio n. 11
0
 // This method always return false for non-generic compiler,
 // while Type.IsGenericParameter is returned if it is supported.
 public static bool IsGenericParameter(TypeSpec type)
 {
     return(type.IsGenericParameter);
 }
Esempio n. 12
0
 public ExtensionMethodCandidates LookupExtensionMethod(TypeSpec extensionType, string name, int arity)
 {
     return(MemberContext.LookupExtensionMethod(extensionType, name, arity));
 }