コード例 #1
0
        public void Instantiate(AstTypeReferenceType type)
        {
            Ast.Guard(type.TemplateArguments.Count() == TemplateDefinition.TemplateParameters.Count(),
                      $"The number of template parameters do not match the TemplateDefinition {TemplateDefinition.Identifier.NativeFullName}");

            Context = type.Context;
            this.SetIdentifier(type.Identifier.MakeCopy());

            _templateArguments = new AstTemplateArgumentMap(
                TemplateDefinition.TemplateParameters, type.TemplateArguments);

            foreach (var field in TemplateDefinition.Fields)
            {
                var fieldDef = new AstTypeDefinitionStructField();
                fieldDef.SetIdentifier(field.Identifier.MakeCopy());
                if (field.IsTemplate)
                {
                    var templateArgument = _templateArguments.LookupArgument(field.TypeReference.Identifier);
                    Ast.Guard(templateArgument, $"No Template Argument was found for {field.TypeReference.Identifier.CanonicalFullName}");
                    fieldDef.SetTypeReference(templateArgument !.TypeReference.MakeCopy());
                }
                else
                {
                    fieldDef.SetTypeReference(field.TypeReference.MakeCopy());
                }

                this.AddField(fieldDef);
                type.Symbol.SymbolTable.Add(fieldDef);
            }
        }
コード例 #2
0
        public void SetSelfParameter(AstTypeDefinitionIntrinsic type)
        {
            Ast.Guard(!FunctionType.Parameters.Any(), "A Self parameter has to be first.");
            var parameter = new AstFunctionParameterDefinition(AstIdentifierIntrinsic.Self);

            parameter.SetTypeReference(AstTypeReferenceType.From(type));
            FunctionType.AddParameter(parameter);
        }
コード例 #3
0
        public void Instantiate(AstTypeReferenceType type)
        {
            Context = type.Context;
            this.SetIdentifier(type.Identifier.MakeCopy());

            _templateArguments = new AstTemplateArgumentMap(
                TypeDefinition.TemplateParameters, type.TemplateArguments);
        }
コード例 #4
0
        public override AstTypeReferenceType MakeCopy()
        {
            var typeRef = new AstTypeReferenceType(this);

            if (HasSymbol)
            {
                Symbol.AddNode(typeRef);
            }
            return(typeRef);
        }
コード例 #5
0
        public static AstTypeReferenceType From(AstTypeDefinition typeDef)
        {
            Ast.Guard(typeDef is not null, "TypeDefinition is null.");
            Ast.Guard(typeDef !.HasIdentifier, "TypeDefinition has no Identifier.");

            var typeRef = new AstTypeReferenceType();

            typeRef.SetIdentifier(typeDef.Identifier);
            if (typeDef.Symbol is not null)
            {
                typeRef.TrySetSymbol(typeDef.Symbol);
                typeDef.Symbol.AddNode(typeRef);
            }
            return(typeRef);
        }
コード例 #6
0
 private void SetTypeReference(AstTypeDefinitionIntrinsic type)
 => FunctionType.SetTypeReference(AstTypeReferenceType.From(type));
コード例 #7
0
 protected AstTypeReferenceExternal(AstTypeReferenceType typeOrigin)
     : base(typeOrigin)
 { }
コード例 #8
0
 protected AstTypeReferenceType(AstTypeReferenceType typeToCopy)
     : base(typeToCopy)
 {
 }