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); } }
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); }
public void Instantiate(AstTypeReferenceType type) { Context = type.Context; this.SetIdentifier(type.Identifier.MakeCopy()); _templateArguments = new AstTemplateArgumentMap( TypeDefinition.TemplateParameters, type.TemplateArguments); }
public override AstTypeReferenceType MakeCopy() { var typeRef = new AstTypeReferenceType(this); if (HasSymbol) { Symbol.AddNode(typeRef); } return(typeRef); }
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); }
private void SetTypeReference(AstTypeDefinitionIntrinsic type) => FunctionType.SetTypeReference(AstTypeReferenceType.From(type));
protected AstTypeReferenceExternal(AstTypeReferenceType typeOrigin) : base(typeOrigin) { }
protected AstTypeReferenceType(AstTypeReferenceType typeToCopy) : base(typeToCopy) { }