Package org.ek9lang.compiler.support
Class SymbolFactory
java.lang.Object
org.ek9lang.compiler.support.SymbolFactory
Just a factory for all types of EK9 symbol.
Ensures that newly created symbols are initialised correctly.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
-
Constructor Summary
ConstructorDescriptionSymbolFactory
(ParsedModule parsedModule) Create a new symbol factory for use with the parsedModule. -
Method Summary
Modifier and TypeMethodDescriptionboolean
A bit of a beast this method.void
ensureTextBodyIsInSuper
(MethodSymbol textMethodSymbol) Ensures that any method in a specific text block is always added to the base text for that component.Create a new aggregate that represents an EK9 application.newCall
(EK9Parser.CallContext ctx, IScope scope) Symbol to model some type of call to a function, dynamic function, constructor, this, super etc.Create a new aggregate that represents an EK9 class.Create a new aggregate that represents an EK9 component.Create a new constant as declared in the constants section.newDict
(EK9Parser.DictContext ctx, IScope scope) Create a new EK9 Dictionary - like a Map.newDictEntry
(EK9Parser.InitValuePairContext ctx, IScope scope) Create a new entry for the Dictionary, basically a tuple.Create a new directive to be used inside the compiler.newDynamicClass
(IScopedSymbol enclosingMainTypeOrFunction, EK9Parser.DynamicClassDeclarationContext ctx) Create a new aggregate that represents an EK9 dynamic class.newDynamicFunction
(IScopedSymbol enclosingMainTypeOrFunction, EK9Parser.DynamicFunctionDeclarationContext ctx) Create a new aggregate that represents an EK9 dynamic function.newDynamicVariableCapture
(ICanCaptureVariables scope, IScope enclosingBlockScope) Create a new local scope just for variables to be defined/captured in for dynamic classes/functions.newExpressionSymbol
(ISymbol fromSymbol) Create a new expression around a symbol.newExpressionSymbol
(IToken token, String name) Create a new expression symbol place-holder.newExpressionSymbol
(IToken token, String name, Optional<ISymbol> ofType) Create a new expression symbol place-holder.newForLoop
(org.antlr.v4.runtime.ParserRuleContext ctx, IScope scope) Create a new symbol that represents an EK9 'for' loop.Create a new function symbol that represents an EK9 function.newGeneralSymbol
(IToken token, String name) Just for general symbols, like references.Create a new expression that represents the expression part of and interpolated String.Create a new constant that represents the fixed text part of an interpolated String.newList
(EK9Parser.ListContext ctx, IScope scope) Create a new EK9 List (a generic type).newLiteral
(IToken start, String name) Create a new aggregate that represents an EK9 literal value.Create a new aggregate that represents an EK9 loop variable.Create a new aggregate that represents an EK9 loop variable for a range.newMethod
(EK9Parser.MethodDeclarationContext ctx, String methodName, IScopedSymbol scopedSymbol) Create a new method with a specific name.newMethod
(EK9Parser.MethodDeclarationContext ctx, IScopedSymbol scopedSymbol) Create a new method that represents an EK9 class/component method.newOperationCall
(EK9Parser.OperationCallContext ctx, IScope scope) New call but modelled as an operator if marked as such.newOperator
(EK9Parser.OperatorDeclarationContext ctx, IAggregateSymbol aggregate) Create a new aggregate that represents an EK9 operator, uses a method for this.Create a new EK9 package aggregate.newParameterisedSymbol
(PossibleGenericSymbol genericType, List<ISymbol> typeArguments) Create a new aggregate that represents an EK9 program.Create a new aggregate that represents an EK9 record.Create a new aggregate that represents an EK9 service.Create a new aggregate that represents an EK9 service operation - a specialised method.newStream
(org.antlr.v4.runtime.ParserRuleContext ctx) Create a new symbol that represents an EK9 concept of a stream pipeline.newStreamCat
(EK9Parser.StreamCatContext ctx, IScope scope) Create a new symbol that represents an EK9 'cat' part of a stream pipeline.newStreamFor
(EK9Parser.StreamForContext ctx, IScope scope) Create a new symbol that represents an EK9 'for' part of a stream pipeline.newStreamPart
(EK9Parser.StreamPartContext ctx, IScope scope) Create a new symbol that represents an EK9 stream function part of a stream pipeline.newStreamTermination
(org.antlr.v4.runtime.ParserRuleContext ctx, String operation, IScope scope) Create a new symbol that represents an EK9 terminal part of a stream pipeline.Create a new symbol that represents an EK9 'switch' block.newText
(EK9Parser.TextDeclarationContext ctx, String forLanguage) Create a new aggregate that represents EK9 text construct.newTextBody
(EK9Parser.TextBodyDeclarationContext ctx, IScope scope) Create a new aggregate that represents an EK9 text body - this is represented by a method.Create a new aggregate that represents an EK9 trait.newTry
(EK9Parser.TryStatementExpressionContext ctx, IScope scope) Create a new symbol that represents an EK9 'try' block.Create a new aggregate that represents an EK9 type, constrained or enumeration.newVariable
(String name, IToken token, boolean nullAllowed, boolean injectionExpected) Create new variable typically when looking to create simulated variable.newVariable
(EK9Parser.IdentifierContext identifier, boolean nullAllowed, boolean injectionExpected) Create and initialise a new variable symbol.Just a declaration of a variable by itself - i.e.Create a new while or do/while scoped symbol.void
populateEnumeration
(AggregateSymbol enumerationSymbol, List<org.antlr.v4.runtime.tree.TerminalNode> identifiers) Populates the enumeration with each of the values supplied in the identifiers.
-
Field Details
-
UNINITIALISED_AT_DECLARATION
- See Also:
-
NO_REFERENCED_RESET
- See Also:
-
SUBSTITUTED
- See Also:
-
ACCESSED
- See Also:
-
DEFAULTED
- See Also:
-
EXTERN
- See Also:
-
URI_PROTO
- See Also:
-
HTTP_REQUEST
- See Also:
-
HTTP_PATH
- See Also:
-
HTTP_HEADER
- See Also:
-
HTTP_QUERY
- See Also:
-
HTTP_VERB
- See Also:
-
HTTP_ACCESS
- See Also:
-
HTTP_SOURCE
- See Also:
-
-
Constructor Details
-
SymbolFactory
Create a new symbol factory for use with the parsedModule.
-
-
Method Details
-
getAggregateFactory
-
newDirective
Create a new directive to be used inside the compiler. -
newPackage
Create a new EK9 package aggregate. -
newProgram
Create a new aggregate that represents an EK9 program. -
newClass
Create a new aggregate that represents an EK9 class. A bit tricky when it comes to parameterised (generic/template classes). -
newComponent
Create a new aggregate that represents an EK9 component. -
newTrait
Create a new aggregate that represents an EK9 trait. -
newRecord
Create a new aggregate that represents an EK9 record. -
newFunction
Create a new function symbol that represents an EK9 function. -
newText
Create a new aggregate that represents EK9 text construct. Note that this also creates a common base for all text with the same name. It ensures that all methods are added to that common base. Then we can check if all those methods on the common base are also defined in each and every concrete language text aggregate. -
newTextBody
Create a new aggregate that represents an EK9 text body - this is represented by a method. -
ensureTextBodyIsInSuper
Ensures that any method in a specific text block is always added to the base text for that component. -
newService
Create a new aggregate that represents an EK9 service. -
newServiceOperation
public ServiceOperationSymbol newServiceOperation(EK9Parser.ServiceOperationDeclarationContext ctx, IScope scope) Create a new aggregate that represents an EK9 service operation - a specialised method. -
newApplication
Create a new aggregate that represents an EK9 application. -
newDynamicClass
public AggregateWithTraitsSymbol newDynamicClass(IScopedSymbol enclosingMainTypeOrFunction, EK9Parser.DynamicClassDeclarationContext ctx) Create a new aggregate that represents an EK9 dynamic class. -
newDynamicFunction
public FunctionSymbol newDynamicFunction(IScopedSymbol enclosingMainTypeOrFunction, EK9Parser.DynamicFunctionDeclarationContext ctx) Create a new aggregate that represents an EK9 dynamic function. -
newParameterisedSymbol
public PossibleGenericSymbol newParameterisedSymbol(PossibleGenericSymbol genericType, List<ISymbol> typeArguments) -
newDynamicVariableCapture
public CaptureScope newDynamicVariableCapture(ICanCaptureVariables scope, IScope enclosingBlockScope) Create a new local scope just for variables to be defined/captured in for dynamic classes/functions. -
newOperator
public MethodSymbol newOperator(EK9Parser.OperatorDeclarationContext ctx, IAggregateSymbol aggregate) Create a new aggregate that represents an EK9 operator, uses a method for this. -
addMissingDefaultOperators
public boolean addMissingDefaultOperators(EK9Parser.DefaultOperatorContext ctx, IAggregateSymbol aggregate) A bit of a beast this method. Check if operator is not present if so add one in. But as it is used in very early phase of compilation not all types will be known. So here this method just uses the raw name of the method. -
newMethod
Create a new method that represents an EK9 class/component method. -
newMethod
public MethodSymbol newMethod(EK9Parser.MethodDeclarationContext ctx, String methodName, IScopedSymbol scopedSymbol) Create a new method with a specific name. -
newType
Create a new aggregate that represents an EK9 type, constrained or enumeration. -
populateEnumeration
public void populateEnumeration(AggregateSymbol enumerationSymbol, List<org.antlr.v4.runtime.tree.TerminalNode> identifiers) Populates the enumeration with each of the values supplied in the identifiers. This does check for duplicates and will raise errors if there are any. -
newStream
Create a new symbol that represents an EK9 concept of a stream pipeline. -
newStreamCat
Create a new symbol that represents an EK9 'cat' part of a stream pipeline. -
newStreamFor
Create a new symbol that represents an EK9 'for' part of a stream pipeline. -
newStreamPart
Create a new symbol that represents an EK9 stream function part of a stream pipeline. -
newStreamTermination
public StreamCallSymbol newStreamTermination(org.antlr.v4.runtime.ParserRuleContext ctx, String operation, IScope scope) Create a new symbol that represents an EK9 terminal part of a stream pipeline. -
newGeneralSymbol
Just for general symbols, like references. -
newExpressionSymbol
Create a new expression symbol place-holder. Really just enables the line of code to be captured and the type that the expression returns. -
newExpressionSymbol
Create a new expression symbol place-holder. Really just enables the line of code to be captured and the type that the expression returns. -
newExpressionSymbol
Create a new expression around a symbol. -
newCall
Symbol to model some type of call to a function, dynamic function, constructor, this, super etc. -
newList
Create a new EK9 List (a generic type). -
newDict
Create a new EK9 Dictionary - like a Map. -
newDictEntry
Create a new entry for the Dictionary, basically a tuple. -
newOperationCall
New call but modelled as an operator if marked as such. -
newSwitch
Create a new symbol that represents an EK9 'switch' block. -
newTry
Create a new symbol that represents an EK9 'try' block. -
newForLoop
Create a new symbol that represents an EK9 'for' loop. -
newWhileLoop
Create a new while or do/while scoped symbol. -
newLoopVariable
Create a new aggregate that represents an EK9 loop variable. -
newLoopVariable
Create a new aggregate that represents an EK9 loop variable for a range. -
newInterpolatedStringPart
Create a new constant that represents the fixed text part of an interpolated String. -
newInterpolatedExpressionPart
Create a new expression that represents the expression part of and interpolated String. -
newConstant
Create a new constant as declared in the constants section. -
newVariable
Just a declaration of a variable by itself - i.e. without an assignment. -
newVariable
Create and initialise a new variable symbol. Typically, a variable like name ← "Steve", so 'name' is the variable. -
newVariable
public VariableSymbol newVariable(String name, IToken token, boolean nullAllowed, boolean injectionExpected) Create new variable typically when looking to create simulated variable. -
newVariable
public VariableSymbol newVariable(EK9Parser.IdentifierContext identifier, boolean nullAllowed, boolean injectionExpected) -
newLiteral
Create a new aggregate that represents an EK9 literal value.
-