예제 #1
0
 public CCI.TypeNode BaseDefn(CCI.TypeNode typeDefn)
 {
     if (typeDefn.BaseType == null)
         return null;
     else
         return Applicand(typeDefn.BaseType);
 }
예제 #2
0
 public int TypeArity(CCI.Method methodDefn)
 {
     if (methodDefn.TemplateParameters != null)
         return methodDefn.TemplateParameters.Count;
     else
         return 0;
 }
예제 #3
0
 public MetadataNamedArgument(ISymbol entity, Cci.ITypeReference type, Cci.IMetadataExpression value)
 {
     // entity must be one of INamedEntity or IFieldDefinition or IPropertyDefinition
     this.entity = entity;
     this.type = type;
     this.value = value;
 }
예제 #4
0
 public MethodBody(
     byte[] ilBits,
     ushort maxStack,
     Cci.IMethodDefinition parent,
     ImmutableArray<LocalDefinition> locals,
     SequencePointList sequencePoints,
     DebugDocumentProvider debugDocumentProvider,
     ImmutableArray<Cci.ExceptionHandlerRegion> exceptionHandlers,
     ImmutableArray<LocalScope> localScopes,
     Cci.CustomDebugInfoKind customDebugInfoKind,
     bool hasDynamicLocalVariables,
     ImmutableArray<NamespaceScope> namespaceScopes = default(ImmutableArray<NamespaceScope>),
     string iteratorClassName = null,
     ImmutableArray<LocalScope> iteratorScopes = default(ImmutableArray<LocalScope>),
     Cci.AsyncMethodBodyDebugInfo asyncMethodDebugInfo = null)
 {
     this.ilBits = ilBits;
     this.asyncMethodDebugInfo = asyncMethodDebugInfo;
     this.maxStack = maxStack;
     this.parent = parent;
     this.locals = locals;
     this.sequencePoints = sequencePoints;
     this.debugDocumentProvider = debugDocumentProvider;
     this.exceptionHandlers = exceptionHandlers;
     this.localScopes = localScopes;
     this.customDebugInfoKind = customDebugInfoKind;
     this.hasDynamicLocalVariables = hasDynamicLocalVariables;
     this.namespaceScopes = namespaceScopes.IsDefault ? ImmutableArray<NamespaceScope>.Empty : namespaceScopes;
     this.iteratorClassName = iteratorClassName;
     this.iteratorScopes = iteratorScopes.IsDefault ? ImmutableArray<LocalScope>.Empty : iteratorScopes;
 }
예제 #5
0
 // For constructors:
 //   For value types: First arg is pointer to instance, constructor must write to it.
 //   For ref types:   Imported function is not passed the existing instance, so don't include as argument.
 // For instance methods:
 //   'this' passed as first argument.
 // For static methods:
 //   Arity is same as parameter count.
 public int Arity(CCI.Method method)
 {
     var extra = method.IsStatic || (method is CCI.InstanceInitializer && !method.DeclaringType.IsValueType)
                     ? 0
                     : 1;
     return extra + (method.Parameters == null ? 0 : method.Parameters.Count);
 }
예제 #6
0
        void Cci.IReference.Dispatch(Cci.MetadataVisitor visitor)
        {
            Debug.Assert(this.IsDefinitionOrDistinct());

            if (!this.IsDefinition)
            {
                if (this.IsGenericMethod)
                {
                    Debug.Assert(((Cci.IMethodReference)this).AsGenericMethodInstanceReference != null);
                    visitor.Visit((Cci.IGenericMethodInstanceReference)this);
                }
                else
                {
                    Debug.Assert(((Cci.IMethodReference)this).AsSpecializedMethodReference != null);
                    visitor.Visit((Cci.ISpecializedMethodReference)this);
                }
            }
            else
            {
                PEModuleBuilder moduleBeingBuilt = (PEModuleBuilder)visitor.Context.Module;
                if (object.ReferenceEquals(this.ContainingModule, moduleBeingBuilt.SourceModule))
                {
                    Debug.Assert(((Cci.IMethodReference)this).GetResolvedMethod(visitor.Context) != null);
                    visitor.Visit((Cci.IMethodDefinition)this);
                } 
                else
                {
                    visitor.Visit((Cci.IMethodReference)this);
                }
            }
        }
예제 #7
0
        public PermissionSetAttributeWithFileReference(Cci.ICustomAttribute sourceAttribute, string resolvedPermissionSetFilePath)
        {
            Debug.Assert(!String.IsNullOrEmpty(resolvedPermissionSetFilePath));
            Debug.Assert(PathUtilities.IsAbsolute(resolvedPermissionSetFilePath));

            this.sourceAttribute = sourceAttribute;
            this.resolvedPermissionSetFilePath = resolvedPermissionSetFilePath;
        }
        public ExpandedVarargsMethodReference(Cci.IMethodReference underlyingMethod, ImmutableArray<Cci.IParameterTypeInformation> argListParams)
        {
            Debug.Assert(underlyingMethod.AcceptsExtraArguments);
            Debug.Assert(!argListParams.IsEmpty);

            this.underlyingMethod = underlyingMethod;
            this.argListParams = argListParams;
        }
 // used by DllImportAttribute
 public void SetDllImport(int attributeIndex, string moduleName, string entryPointName, Cci.PInvokeAttributes flags, bool preserveSig)
 {
     VerifySealed(expected: false);
     Debug.Assert(attributeIndex >= 0);
     platformInvokeInfo = new DllImportData(moduleName, entryPointName, flags);
     this.dllImportIndex = attributeIndex;
     this.dllImportPreserveSig = preserveSig;
     SetDataStored();
 }
예제 #10
0
        internal LocalScope(uint begin, uint end, Cci.IMethodDefinition parent, IEnumerable<Cci.ILocalDefinition> constantSymbols, IEnumerable<Cci.ILocalDefinition> localSymbols)
        {
            //we should not create 0-length scopes as they are useless.
            //however we will allow the case of "begin == end" as that is how edge inclusive scopes of length 1 are represented.
            System.Diagnostics.Debug.Assert(begin <= end);

            this.offset = begin;
            this.length = end - begin;
            this.parent = parent;
            this.constantSymbols = constantSymbols;
            this.localSymbols = localSymbols;
        }
예제 #11
0
        public PEAssemblyBuilder(
            SourceAssemblySymbol sourceAssembly,
            Cci.ModulePropertiesForSerialization serializationProperties,
            IEnumerable<ResourceDescription> manifestResources,
            OutputKind outputKind,
            EmitOptions emitOptions)
            :base(sourceAssembly.DeclaringCompilation, (SourceModuleSymbol)sourceAssembly.Modules[0], serializationProperties, manifestResources, outputKind, emitOptions)
        {
            _sourceAssembly = sourceAssembly;
            _metadataName = (emitOptions.OutputNameOverride == null) ? sourceAssembly.MetadataName : FileNameUtilities.ChangeExtension(emitOptions.OutputNameOverride, extension: null);

            AssemblyOrModuleSymbolToModuleRefMap.Add(sourceAssembly, this);
        }
예제 #12
0
 public static MessageContext Type(MessageContext parent, CCI.TypeNode type)
 {
     var loc = default(Location);
     if (type.SourceContext.Document != null)
         loc = type.SourceContext.ToLocation();
     else if (type.Name != null && type.Name.SourceContext.Document != null)
         loc = type.Name.SourceContext.ToLocation();
     return new MessageContext
         (parent,
          loc,
          sb =>
          {
              sb.Append("Type ");
              sb.Append(type.FullName);
          });
 }
예제 #13
0
 public int TypeArity(CCI.TypeNode type)
 {
     var n = 0;
     do
     {
         if (type.TemplateParameters != null)
         {
             n += type.TemplateParameters.Count;
             type = type.Template;
         }
         else
             type = type.DeclaringType;
     }
     while (type != null);
     return n;
 }
예제 #14
0
        public static MessageContext Member(MessageContext parent, CCI.Member member)
        {
            var loc = default(Location);
            if (member.SourceContext.Document != null)
                loc = member.SourceContext.ToLocation();
            else if (member.Name != null && member.Name.SourceContext.Document != null)
                loc = member.Name.SourceContext.ToLocation();

            return new MessageContext
                (parent,
                 loc,
                 sb =>
                 {
                     sb.Append("Member ");
                     sb.Append(member.FullName);
                 });
        }
예제 #15
0
 public static MessageContext Method(MessageContext parent, CCI.Method method)
 {
     var loc = default(Location);
     if (method.SourceContext.Document != null)
         loc = method.SourceContext.ToLocation();
     else if (method.Name != null && method.Name.SourceContext.Document != null)
         loc = method.Name.SourceContext.ToLocation();
     else if (method.Instructions != null && method.Instructions.Count > 1 &&
              method.Instructions[1].SourceContext.Document != null)
         loc = method.Instructions[1].SourceContext.ToLocation();
     return new MessageContext
         (parent,
          loc,
          sb =>
          {
              sb.Append("Method ");
              sb.Append(method.FullName);
          });
 }
예제 #16
0
 private void CheckTypeDefn(CCI.AssemblyNode expectedContainingAssembly, CCI.TypeNode typeDefn)
 {
     if (typeDefn.DeclaringModule == null || typeDefn.DeclaringModule.ContainingAssembly == null ||
         typeDefn.DeclaringModule.ContainingAssembly != expectedContainingAssembly || typeDefn.Name == null)
     {
         var refName = expectedContainingAssembly.StrongName;
         var refInfo = default(Info);
         var refFilename = "<unknown>";
         if (strongNameToInfo.TryGetValue(refName, out refInfo))
             refFilename = refInfo.FileName;
         env.Log(new UnresolvableReferenceMessage(refName, refFilename, "<unknown>"));
         throw new ExitException();
     }
     foreach (var member in typeDefn.Members)
     {
         var nestedTypeDefn = member as CCI.TypeNode;
         if (nestedTypeDefn != null)
             CheckTypeDefn(expectedContainingAssembly, nestedTypeDefn);
     }
 }
예제 #17
0
        protected PEModuleBuilder(
            PhpCompilation compilation,
            SourceModuleSymbol sourceModule,
            Cci.ModulePropertiesForSerialization serializationProperties,
            IEnumerable<ResourceDescription> manifestResources,
            OutputKind outputKind,
            EmitOptions emitOptions)
        {
            Debug.Assert(sourceModule != null);
            Debug.Assert(serializationProperties != null);

            _compilation = compilation;
            _sourceModule = sourceModule;
            _serializationProperties = serializationProperties;
            this.ManifestResources = manifestResources;
            _outputKind = outputKind;
            _emitOptions = emitOptions;
            this.CompilationState = new CommonModuleCompilationState();
            _debugDocuments = new ConcurrentDictionary<string, Cci.DebugSourceDocument>(compilation.IsCaseSensitive ? StringComparer.Ordinal : StringComparer.OrdinalIgnoreCase);
            _synthesized = new SynthesizedManager(this);

            AssemblyOrModuleSymbolToModuleRefMap.Add(sourceModule, this);
        }
예제 #18
0
 void Cci.IMetadataExpression.Dispatch(Cci.MetadataVisitor visitor)
 {
     visitor.Visit(this);
 }
예제 #19
0
 public HexPropertyMetadataNamedArgument(Cci.ITypeReference type, Cci.IMetadataExpression value)
 {
     this.type = type;
     this.value = value;
 }
예제 #20
0
 void Cci.IReference.Dispatch(Cci.MetadataVisitor visitor)
 {
     visitor.Visit(this);
 }
 void Cci.IReference.Dispatch(Cci.MetadataVisitor visitor)
 {
     if (((Cci.IMethodReference)this).AsGenericMethodInstanceReference != null)
     {
         visitor.Visit((Cci.IGenericMethodInstanceReference)this);
     }
     else if (((Cci.IMethodReference)this).AsSpecializedMethodReference != null)
     {
         visitor.Visit((Cci.ISpecializedMethodReference)this);
     }
     else
     {
         visitor.Visit((Cci.IMethodReference)this);
     }
 }
예제 #22
0
 /// <summary>
 /// Acquires an element referencer method for a given array type
 /// </summary>
 public ArrayMethod GetArrayAddress(Cci.IArrayTypeReference arrayType)
 {
     return GetArrayMethod(arrayType, ArrayMethodKind.ADDRESS);
 }
 public override void Dispatch(Cci.MetadataVisitor visitor)
 {
     visitor.Visit((Cci.ISpecializedNestedTypeReference)this);
 }
예제 #24
0
파일: Looker.cs 프로젝트: hesam/SketchSharp
 public Looker(Scope scope, Cci.ErrorHandler errorHandler, TrivialHashtable scopeFor, TrivialHashtable ambiguousTypes, TrivialHashtable referencedLabels)
   : base(scope, errorHandler, scopeFor, new TypeSystem(new ErrorHandler(errorHandler.Errors)), ambiguousTypes, referencedLabels){
   this.alreadyReported[StandardIds.Var.UniqueIdKey] = true;
 }
예제 #25
0
파일: Looker.cs 프로젝트: hesam/SketchSharp
 public Looker(Scope scope, Cci.ErrorHandler errorHandler, TrivialHashtable scopeFor)
   : this(scope, errorHandler, scopeFor, null, null){
   this.alreadyReported[StandardIds.Var.UniqueIdKey] = true;
 }
예제 #26
0
 public void Dispatch(Cci.MetadataVisitor visitor)
 {
     visitor.Visit((Cci.IMethodReference)this);
 }
예제 #27
0
        void Cci.IReference.Dispatch(Cci.MetadataVisitor visitor)
        {
            throw ExceptionUtilities.Unreachable;
            //We've not yet discovered a scenario in which we need this.
            //If you're hitting this exception, uncomment the code below
            //and add a unit test.
#if false
            Debug.Assert(this.IsDefinition);

            SymbolKind kind = this.ContainingSymbol.Kind;

            if (((Module)visitor.Context).SourceModule == this.ContainingModule)
            {
                if (kind == SymbolKind.NamedType)
                {
                    visitor.Visit((IGenericTypeParameter)this);
                }
                else if (kind == SymbolKind.Method)
                {
                    visitor.Visit((IGenericMethodParameter)this);
                }
                else
                {
                    throw new NotSupportedException();
                }
            }
            else
            {
                if (kind == SymbolKind.NamedType)
                {
                    visitor.Visit((IGenericTypeParameterReference)this);
                }
                else if (kind == SymbolKind.Method)
                {
                    visitor.Visit((IGenericMethodParameterReference)this);
                }
                else
                {
                    throw new NotSupportedException();
                }
            }
#endif
        }
예제 #28
0
 /// <summary>
 /// Acquires an array constructor for a given array type
 /// </summary>
 public ArrayMethod GetArrayConstructor(Cci.IArrayTypeReference arrayType)
 {
     return GetArrayMethod(arrayType, ArrayMethodKind.CTOR);
 }
예제 #29
0
 internal DllImportData(string moduleName, string entryPointName, Cci.PInvokeAttributes flags)
 {
     this.moduleName = moduleName;
     this.entryPointName = entryPointName;
     this.flags = flags;
 }
예제 #30
0
 /// <summary>
 /// Acquires an element setter method for a given array type
 /// </summary>
 public ArrayMethod GetArraySet(Cci.IArrayTypeReference arrayType)
 {
     return GetArrayMethod(arrayType, ArrayMethodKind.SET);
 }