public TypeEmitter(TypeModel typeModel, WellKnownSymbols wellKnownSymbols, int index) { this.typeModel = typeModel; this.wellKnownSymbols = wellKnownSymbols; this.index = index; this.writer = new IndentedTextWriter(this.stringWriter); string containingNamespace = this.typeModel.NamedTypeSymbol.ContainingNamespace.ToDisplayString(SymbolDisplayFormats.Namespace); this.namespaceName = (string.IsNullOrEmpty(containingNamespace) ? "" : containingNamespace + ".") + "RestEaseGeneratedTypes"; this.typeNamePrefix = "Implementation_" + this.index + "_"; string constructorName = this.typeNamePrefix + this.typeModel.NamedTypeSymbol.ToDisplayString(SymbolDisplayFormats.ConstructorName); // They might have given the type a name like '@event', or it might have a type parameter like '@event'. // Therefore we need to escape the type parameters, but strip a leading @ from the class name this.typeName = this.typeNamePrefix + this.typeModel.NamedTypeSymbol.ToDisplayString(SymbolDisplayFormats.TypeNameWithConstraints).TrimStart('@'); this.qualifiedTypeName = "global::" + this.namespaceName + "." + this.typeName; this.requesterFieldName = this.GenerateFieldName("requester"); if (this.typeModel.HeaderAttributes.Count > 0) { this.classHeadersFieldName = this.GenerateFieldName("classHeaders"); } this.AddClassDeclaration(); this.AddInstanceCtor(constructorName); this.AddStaticCtor(constructorName); }
public LookupResult LookupFunction(Spanned <string> identifier) { string name = identifier.Value; BuiltInFunction?builtInFunction = WellKnownSymbols.LookupBuiltInFunction(name); if (builtInFunction.HasValue) { return(new LookupResult(builtInFunction.Value)); } FunctionSymbol?function = _module.LookupFunction(name); if (function is not null) { return(new LookupResult(function)); } ReportUnresolvedIdentifier(identifier); return(LookupResult.Empty); }
public LookupResult LookupNonInvocableSymbol(NameExpression name) { if (name.Sigil == SigilKind.Dollar || _compilation.TryGetVariableToken(name.Name, out _)) { return(new LookupResult(LookupResultVariant.Variable, name.Name)); } if (name.Sigil == SigilKind.Hash) { return(new LookupResult(LookupResultVariant.Flag, name.Name)); } BuiltInConstant?builtInConstant = WellKnownSymbols.LookupBuiltInConstant(name.Name); if (builtInConstant.HasValue) { return(new LookupResult(builtInConstant.Value)); } return(LookupResult.Empty); }
public MethodEmitter( MethodModel methodModel, IndentedTextWriter writer, WellKnownSymbols wellKnownSymbols, string qualifiedTypeName, string requesterFieldName, string?classHeadersFieldName, string methodInfoFieldName) { this.methodModel = methodModel; this.writer = writer; this.wellKnownSymbols = wellKnownSymbols; this.qualifiedTypeName = qualifiedTypeName; this.requesterFieldName = requesterFieldName; this.classHeadersFieldName = classHeadersFieldName; this.methodInfoFieldName = this.wellKnownSymbols.HasExpression ? methodInfoFieldName : null; this.requestInfoLocalName = this.GenerateRequestInfoLocalName(); this.EmitMethodInfoField(); this.EmitMethodDeclaration(); }
public Emitter(Compilation compilation, WellKnownSymbols wellKnownSymbols) { this.compilation = compilation; this.wellKnownSymbols = wellKnownSymbols; }
public Emitter(WellKnownSymbols wellKnownSymbols) { this.wellKnownSymbols = wellKnownSymbols; }