Exemple #1
0
        private TypeBase ResolveTypeRef(TypeRef typeRef)
        {
            TypeBase resolvedType = PrimaryType.Unknown;
            var      name         = typeRef.TypeName;

            if (!m_types.Contains(name.Content))
            {
                m_errorManager.AddError(c_SE_TypeNameMissing, name.Span, name.Content);
            }
            else
            {
                typeRef.Type = m_types[name.Content];
                resolvedType = typeRef.Type;
            }

            return(resolvedType);
        }
Exemple #2
0
        public object GetResult(int index, CompilationErrorManager errorManager)
        {
            CodeContract.RequiresArgumentInRange(index >= 0 && index < m_acceptedHeads.Count, "index", "index is out of range");

            var head = m_acceptedHeads[index];

            if (head.Errors != null && errorManager != null)
            {
                //aggregate errors
                foreach (var error in head.Errors)
                {
                    int errorId = error.ErrorId ?? m_errorDef.OtherErrorId;

                    errorManager.AddError(errorId, error.ErrorPosition, error.ErrorArgument);
                }
            }

            return(head.TopStackValue);
        }
Exemple #3
0
        public object GetResult(int index, CompilationErrorManager errorManager)
        {
            CodeContract.RequiresArgumentInRange(index >= 0 && index < m_acceptedHeads.Count, "index", "index is out of range");

            var head = m_acceptedHeads[index];

            if (head.Errors != null && errorManager != null)
            {
                //aggregate errors
                foreach (var error in head.Errors)
                {
                    int errorId = error.ErrorId ?? m_errorDef.OtherErrorId;

                    errorManager.AddError(errorId, error.ErrorPosition, error.ErrorArgument);
                }
            }

            return head.TopStackValue;
        }
Exemple #4
0
        public override AstNode VisitClassDecl(ClassDecl ast)
        {
            var name = ast.Name.Value;

            if (m_types.Contains(name))
            {
                m_errorManager.AddError(c_SE_TypeNameDuplicates, ast.Name.Span, name);
                return(ast);
            }

            var classType = new CodeClassType()
            {
                Name = name
            };

            m_types.Add(classType);
            ast.Type = classType;

            return(ast);
        }
        private VariableInfo ResolveVariable(LexemeValue identifier)
        {
            //step1, check local parameter & variable definitions
            if (m_currentMethodParameters.Contains(identifier.Content))
            {
                return(m_currentMethodParameters[identifier.Content]);
            }
            else if (m_currentMethodVariables.Contains(identifier.Content))
            {
                return(m_currentMethodVariables[identifier.Content]);
            }
            //step2, if not static method, check fields
            if (!m_currentMethod.IsStatic)
            {
                return(ResolveField(m_currentType, identifier));
            }

            m_errorManager.AddError(c_SE_VariableDeclMissing, identifier.Span, identifier.Content);
            return(null);
        }