示例#1
0
        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);
            }
        }
示例#2
0
        public Symbol Add(string name, IrisType type, StorageClass storage, int location, ImportedMember importInfo = null)
        {
            Symbol symbol = new Symbol(name, type, storage, location, importInfo);

            if (storage == StorageClass.Global)
            {
                _global.Add(name, symbol);
            }
            else
            {
                _local.Add(name, symbol);
            }

            return(symbol);
        }
示例#3
0
 private int GetNextLocation(StorageClass storage, IrisType type)
 {
     if (storage == StorageClass.Global)
     {
         if (type.IsMethod)
         {
             return(_nextGlobalMethod++);
         }
         else
         {
             return(_nextGlobalVariable++);
         }
     }
     else if (storage == StorageClass.Argument)
     {
         return(_nextArgument++);
     }
     else
     {
         return(_nextLocal++);
     }
 }
 internal static ByRefType InternalCreate(IrisType elementType)
 {
     return(new ByRefType(elementType));
 }
 protected ByRefType(IrisType elementType)
     : base(elementType + "&")
 {
     _elementType = elementType;
 }
 internal static ArrayType InternalCreate(IrisType elementType)
 {
     return(new ArrayType(elementType));
 }
 protected ArrayType(IrisType elementType)
     : base(string.Format("array of {0}", elementType))
 {
     _elementType = elementType;
 }
 public static Function Create(IrisType returnType, Variable[] parameters)
 {
     return(new Function(returnType, parameters));
 }
 protected Function(IrisType returnType, Variable[] parameters)
     : base("function", parameters)
 {
     _returnType = returnType;
 }
示例#10
0
        public Symbol Add(string name, IrisType type, StorageClass storage, ImportedMember importInfo = null)
        {
            int location = GetNextLocation(storage, type);

            return(Add(name, type, storage, location, importInfo));
        }