Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        private static void AppendImportedMemberName(StringBuilder builder, ImportedMember member)
        {
            ImportedType declaringType = member.DeclaringType;

            builder.Append('[');
            builder.Append(declaringType.Module.AssemblyName);
            builder.Append(']');
            builder.Append(declaringType.FullName);
            builder.Append("::");
            builder.Append(member.Name);
        }
Ejemplo n.º 3
0
 public void VerifyNoMissingSymbols()
 {
     if (ImportedType != null && !ImportMissingDone)
     {
         ImportMissingDone = true;
         var names = ImportedType.GetMembers(Runtime.ImportBindingFlags).Select(x => x.Name).Distinct().ToArray();
         foreach (var name in names)
         {
             Runtime.ImportMissingSymbol(name, this);
         }
     }
 }
        public void InitializeSymbols()
        {
            ImportedMethod currentMethod = Scope.TryImportCurrentMethod();

            if (currentMethod == null)
            {
                return; // Nothing to evaluate if we can't get the current method
            }
            // Add compiler intrinsics
            AddIntrinsics();

            // Add debugger intrinsics
            // (Not implemented yet)

            // Add globals
            ImportedType type = currentMethod.DeclaringType;

            foreach (ImportedField importedfield in type.GetFields())
            {
                IrisType irisType = importedfield.FieldType;
                if (irisType != IrisType.Invalid)
                {
                    SymbolTable.Add(importedfield.Name, irisType, StorageClass.Global, importedfield);
                }
            }

            // Add methods
            foreach (ImportedMethod importedMethod in type.GetMethods())
            {
                Method method = importedMethod.ConvertToIrisMethod();
                if (IsValidMethod(method))
                {
                    SymbolTable.Add(importedMethod.Name, method, StorageClass.Global, importedMethod);
                }
            }

            // Create symbol for query method and transition the SymbolTable to method scope
            _irisMethod = currentMethod.ConvertToIrisMethod();
            SymbolTable.OpenMethod("$.query", _irisMethod);

            // Add symbols for parameters
            foreach (Variable param in _irisMethod.GetParameters())
            {
                SymbolTable.Add(param.Name, param.Type, StorageClass.Argument);
            }

            // Add symbols for local variables
            foreach (LocalVariable local in Scope.GetLocals())
            {
                SymbolTable.Add(local.Name, local.Type, StorageClass.Local, local.Slot);
            }
        }
Ejemplo n.º 5
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);
            }
        }