Пример #1
0
 public virtual void VisitTemplateInstanceType(AstTemplateInstanceType typeTemplate)
 {
     typeTemplate.VisitChildren(this);
 }
Пример #2
0
        public override void VisitTypeReferenceType(AstTypeReferenceType type)
        {
            Ast.Guard(SymbolTable, "ResolveTypes has no SymbolTable.");
            Ast.Guard(type.Identifier, "AstTypeReference or AstIdentifier is null.");

            var success = type.TryResolveSymbol();

            if (type.IsTemplateOrGeneric && type.TypeDefinition is null)
            {
                var typeTemplate = type.TemplateDefinition;
                if (typeTemplate is null)
                {
                    typeTemplate = FindTemplateDefinition <AstTypeDefinitionTemplate>(type, AstSymbolKind.Type);
                }

                if (typeTemplate is not null)
                {
                    var symbolTable = type.Symbol.SymbolTable;

                    if (typeTemplate.IsTemplate)
                    {
                        if (typeTemplate is AstTypeDefinitionStruct structTemplate)
                        {
                            var typeDef = new AstTemplateInstanceStruct(structTemplate);
                            typeDef.Instantiate(type);
                            symbolTable.Add(typeDef);

                            Visit(typeDef);
                        }
                        else if (typeTemplate is AstTypeDefinitionIntrinsic intrinsicTemplate)
                        {
                            var typeDef = new AstTemplateInstanceType(intrinsicTemplate);
                            typeDef.Instantiate(type);
                            symbolTable.Add(typeDef);

                            Visit(typeDef);
                        }
                        else
                        {
                            throw new NotImplementedException("Template is of a Type that has not been implemented yet.");
                        }
                    }
                    if (typeTemplate.IsGeneric)
                    {
                    }
                }
                else
                {
                    _context.UndefinedType(type);
                }
            }

            if (!type.IsTemplateParameter && !type.Symbol.IsDefined)
            {
                if (!success && !type.IsExternal)
                {
                    // TODO: for now unresolved external references are ignored.
                    _context.UndefinedType(type);
                }
            }

            type !.VisitChildren(this);
        }
Пример #3
0
 public override void VisitTemplateInstanceType(AstTemplateInstanceType typeTemplate)
 {
     typeTemplate.Parent.Should().NotBeNull();
     typeTemplate.VisitChildren(this);
 }