protected ImportedMember(ImportedModule module, StringHandle nameHandle, ImportedType declaringType)
        {
            Module        = module;
            DeclaringType = declaringType;

            _nameHandle = nameHandle;
        }
        protected ImportedMember(ImportedModule module, StringHandle nameHandle, ImportedType declaringType)
        {
            Module = module;
            DeclaringType = declaringType;

            _nameHandle = nameHandle;
        }
 private void AddAssembly(ImportedModule module)
 {
     MetadataReader mdReader = module.Reader;
     AssemblyDefinition assemblyDef = mdReader.GetAssemblyDefinition();
     string name = mdReader.GetString(assemblyDef.Name);
     if (!_importedAssemblyNames.Contains(name))
         _importedAssemblyNames.Add(name);
 }
        private void AddAssembly(ImportedModule module)
        {
            MetadataReader     mdReader    = module.Reader;
            AssemblyDefinition assemblyDef = mdReader.GetAssemblyDefinition();
            string             name        = mdReader.GetString(assemblyDef.Name);

            if (!_importedAssemblyNames.Contains(name))
            {
                _importedAssemblyNames.Add(name);
            }
        }
        public ImportedModule ImportModule(IntPtr metadataPtr, uint blockSize)
        {
            ImportedModule module;
            if (!_modulePtrMap.TryGetValue(metadataPtr, out module))
            {
                module = new ImportedModule(metadataPtr, blockSize);
                _modulePtrMap.Add(metadataPtr, module);
                AddAssembly(module);
            }

            return module;
        }
        public ImportedModule ImportModule(IntPtr metadataPtr, uint blockSize)
        {
            ImportedModule module;

            if (!_modulePtrMap.TryGetValue(metadataPtr, out module))
            {
                module = new ImportedModule(metadataPtr, blockSize);
                _modulePtrMap.Add(metadataPtr, module);
                AddAssembly(module);
            }

            return(module);
        }
 internal ImportedField(ImportedModule module, FieldDefinition fieldDef, ImportedType declaringType)
     : base(module, fieldDef.Name, declaringType)
 {
     _fieldDef = fieldDef;
 }
 internal ImportedMethod(ImportedModule module, MethodDefinition methodDef, ImportedType declaringType)
     : base(module, methodDef.Name, declaringType)
 {
     _methodDef = methodDef;
     _signature = methodDef.DecodeSignature(Module.IrisTypeProvider);
 }
 internal ImportedType(ImportedModule module, TypeDefinition typeDef)
     : base(module, typeDef.Name, null)
 {
     _typeDef = typeDef;
 }
        public ImportedModule ImportMscorlib()
        {
            if (_mscorlib != null)
                return _mscorlib;

            DkmClrAppDomain currentAppDomain = InstructionAddress.ModuleInstance.AppDomain;
            if (currentAppDomain.IsUnloaded)
                return null;

            foreach (DkmClrModuleInstance moduleInstance in currentAppDomain.GetClrModuleInstances())
            {
                if (!moduleInstance.IsUnloaded && moduleInstance.ClrFlags.HasFlag(DkmClrModuleFlags.RuntimeModule))
                {
                    _mscorlib = ImportModule(moduleInstance);
                    return _mscorlib;
                }
            }

            return null;
        }
 internal ImportedType(ImportedModule module, TypeDefinition typeDef)
     : base(module, typeDef.Name, null)
 {
     _typeDef = typeDef;
 }
        protected void ImportMethod(
            FilePosition fp,
            string symbolName,
            ImportedModule module,
            string declaringTypeName,
            string methodName,
            bool instance,
            IrisType returnType,
            IrisType[] paramTypes)
        {
            ImportedType declaringType = module.TryGetTypeByName(declaringTypeName);
            if (declaringType == null)
            {
                CompileErrors.Add(fp, String.Format("Cannot find imported type '{0}'.", declaringTypeName));
                return;
            }

            ImportedMethod importedMethod = declaringType.TryFindMethod(methodName, instance, returnType, paramTypes);
            if (importedMethod == null)
            {
                CompileErrors.Add(fp, String.Format("Cannot find imported function or procedure '{0}.{1}'.", declaringTypeName, methodName));
                return;
            }

            Method method = importedMethod.ConvertToIrisMethod();
            bool containsInvalidType = method.ReturnType == IrisType.Invalid;
            foreach (Variable param in method.GetParameters())
            {
                if (containsInvalidType)
                    break;

                if (param.Type == IrisType.Invalid)
                    containsInvalidType = true;
            }

            if (containsInvalidType)
                CompileErrors.Add(fp, String.Format("The function or procedure '{0}.{1}' contains types that are not supported by the language.", declaringTypeName, methodName));
            else
                SymbolTable.Add(symbolName, method, StorageClass.Global, importedMethod);
        }
        protected void ImportGlobalField(
            FilePosition fp,
            string symbolName,
            ImportedModule module,
            string declaringTypeName,
            string fieldName)
        {
            ImportedType declaringType = module.TryGetTypeByName(declaringTypeName);
            if (declaringType == null)
            {
                CompileErrors.Add(fp, String.Format("Cannot find imported type '{0}'.", declaringTypeName));
                return;
            }

            ImportedField field = declaringType.TryGetPublicStaticField(fieldName);
            if (field == null)
            {
                CompileErrors.Add(fp, String.Format("Cannot find imported field '{0}.{1}'.", declaringTypeName, fieldName));
                return;
            }

            IrisType fieldType = field.FieldType;
            if (fieldType == IrisType.Invalid)
            {
                CompileErrors.Add(fp, String.Format("Type of field '{0}.{1}' is not supported by the language.", declaringTypeName, fieldName));
                return;
            }

            SymbolTable.Add(symbolName, field.FieldType, StorageClass.Global, field);
        }
 internal ImportedMethod(ImportedModule module, MethodDefinition methodDef, ImportedType declaringType)
     : base(module, methodDef.Name, declaringType)
 {
     _methodDef = methodDef;
     _signature = SignatureDecoder.DecodeMethodSignature(_methodDef.Signature, Module.IrisTypeProvider);
 }
 internal ImportedField(ImportedModule module, FieldDefinition fieldDef, ImportedType declaringType)
     : base(module, fieldDef.Name, declaringType)
 {
     _fieldDef = fieldDef;
 }