Ejemplo n.º 1
0
        protected override void VisitTypeSyntax(TypeSyntax pNode)
        {
            //TODO i need to have <T> after methods so we can define our generic types and propagate them
            foreach (var a in pNode.GenericArguments)
            {
                Visit(a);
            }

            var result = _unit.FromString(pNode, out SmallType type);

            switch (result)
            {
            //case Compiler.FindResult.NotFound:
            //    CompilerErrors.UndeclaredType(name, pNode.Span);
            //    break;

            case Compiler.FindResult.IncorrectScope:
                CompilerErrors.TypeNotInScope(SyntaxHelper.GetFullTypeName(pNode), pNode.Span);
                break;
            }

            if (type.IsGenericType)
            {
                type = _unit.MakeConcreteType(type, SyntaxHelper.SelectNodeTypes(pNode.GenericArguments));
            }
            pNode.SetType(type);

            if (pNode.Namespace != null && !_unit.HasReference(pNode.Namespace.Value))
            {
                CompilerErrors.NamespaceNotDefined(pNode.Namespace, pNode.Span);
            }
        }
Ejemplo n.º 2
0
        private bool ValidateType(NamespaceSyntax pNamespace, string pType, SyntaxNode pNode)
        {
            //Validate that all namespaces exists
            //Validate that the trait type exists
            if (pNamespace != null && !_unit.HasReference(pNamespace.Value))
            {
                CompilerErrors.NamespaceNotDefined(pNamespace, pNode.Span);
                return(false);
            }
            else if (!_unit.IsTypeDefined(pNamespace, pType))
            {
                CompilerErrors.UndeclaredType(pType, pNode.Span);
                return(false);
            }

            return(true);
        }