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); }