From ca2c1aab9de292544befe1451622dd53e3f8792f Mon Sep 17 00:00:00 2001 From: Felix Schnabel Date: Sun, 11 Aug 2024 21:53:50 +0200 Subject: [PATCH 1/3] Make Names methods static --- .../org/wso2/ballerinalang/compiler/util/Names.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/util/Names.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/util/Names.java index a57fdf0b7d68..334187125cdb 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/util/Names.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/util/Names.java @@ -25,8 +25,7 @@ */ public class Names { - public static final CompilerContext.Key NAMES_KEY = - new CompilerContext.Key<>(); + public static final CompilerContext.Key NAMES_KEY = new CompilerContext.Key<>(); public static final String STRING_SIGNED32 = "Signed32"; public static final String STRING_SIGNED16 = "Signed16"; @@ -168,12 +167,12 @@ private Names(CompilerContext context) { this.context.put(NAMES_KEY, this); } - public Name fromIdNode(BLangIdentifier identifier) { + public static Name fromIdNode(BLangIdentifier identifier) { // identifier.value cannot be null return fromString(identifier.value); } - public Name originalNameFromIdNode(BLangIdentifier identifier) { + public static Name originalNameFromIdNode(BLangIdentifier identifier) { if (identifier.originalValue == null || identifier.value.equals(identifier.originalValue)) { return fromString(identifier.value); } @@ -190,11 +189,11 @@ public static Name fromString(String value) { return new Name(value); } - public Name fromTypeKind(TypeKind typeKind) { + public static Name fromTypeKind(TypeKind typeKind) { return fromString(typeKind.typeName()); } - public Name merge(Name... names) { + public static Name merge(Name... names) { StringBuilder builder = new StringBuilder(); for (Name name : names) { builder.append(name.value); From 31f34b4fe6eb46478f0b3f21b2dff7a576d42dd0 Mon Sep 17 00:00:00 2001 From: Felix Schnabel Date: Sun, 11 Aug 2024 22:17:38 +0200 Subject: [PATCH 2/3] Fix static method accessed via instance reference and remove references to `Names` variables --- .../compiler/BIRPackageSymbolEnter.java | 6 +- .../compiler/SourceDirectoryManager.java | 2 - .../ballerinalang/compiler/bir/BIRGen.java | 118 ++++++------ .../ballerinalang/compiler/bir/BIRGenEnv.java | 8 +- .../compiler/desugar/ASTBuilderUtil.java | 7 +- .../compiler/desugar/AnnotationDesugar.java | 4 +- .../compiler/desugar/ClassClosureDesugar.java | 2 - .../compiler/desugar/ClosureDesugar.java | 2 - .../desugar/DeclarativeAuthDesugar.java | 4 +- .../compiler/desugar/Desugar.java | 33 ++-- .../compiler/desugar/LargeMethodSplitter.java | 8 +- .../compiler/desugar/QueryDesugar.java | 2 - .../compiler/desugar/ServiceDesugar.java | 8 +- .../compiler/desugar/TransactionDesugar.java | 2 - .../semantics/analyzer/CodeAnalyzer.java | 8 +- .../analyzer/CompilerPluginRunner.java | 2 - .../semantics/analyzer/ConstantAnalyzer.java | 4 +- .../analyzer/ConstantTypeChecker.java | 39 ++-- .../analyzer/ConstantValueResolver.java | 8 +- .../semantics/analyzer/DataflowAnalyzer.java | 2 - .../analyzer/DocumentationAnalyzer.java | 2 - .../analyzer/EffectiveTypePopulator.java | 4 +- .../semantics/analyzer/IsolationAnalyzer.java | 6 +- .../semantics/analyzer/QueryTypeChecker.java | 14 +- .../analyzer/ReachabilityAnalyzer.java | 4 +- .../semantics/analyzer/SemanticAnalyzer.java | 30 ++- .../semantics/analyzer/SymbolEnter.java | 94 +++++----- .../semantics/analyzer/SymbolResolver.java | 16 +- .../semantics/analyzer/TypeChecker.java | 73 ++++---- .../semantics/analyzer/TypeParamAnalyzer.java | 4 +- .../semantics/analyzer/TypeResolver.java | 46 +++-- .../compiler/semantics/analyzer/Types.java | 8 +- .../compiler/semantics/model/SymbolTable.java | 4 +- .../compiler/util/ImmutableTypeCloner.java | 171 +++++++++--------- .../compiler/util/NodeUtils.java | 12 +- .../compiler/util/TypeDefBuilderHelper.java | 16 +- .../compiler/SourceDirectoryManagerTest.java | 4 - 37 files changed, 348 insertions(+), 429 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/BIRPackageSymbolEnter.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/BIRPackageSymbolEnter.java index ba939e2b7441..7887e9ae7f9e 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/BIRPackageSymbolEnter.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/BIRPackageSymbolEnter.java @@ -135,7 +135,6 @@ public class BIRPackageSymbolEnter { private final PackageCache packageCache; private final SymbolResolver symbolResolver; private final SymbolTable symTable; - private final Names names; private final TypeParamAnalyzer typeParamAnalyzer; private final Types types; private BIRTypeReader typeReader; @@ -167,7 +166,6 @@ private BIRPackageSymbolEnter(CompilerContext context) { this.packageCache = PackageCache.getInstance(context); this.symbolResolver = SymbolResolver.getInstance(context); this.symTable = SymbolTable.getInstance(context); - this.names = Names.getInstance(context); this.typeParamAnalyzer = TypeParamAnalyzer.getInstance(context); this.types = Types.getInstance(context); } @@ -1945,11 +1943,11 @@ private boolean isImmutable(long flags) { private BType getEffectiveImmutableType(BType type) { return ImmutableTypeCloner.getEffectiveImmutableType(null, types, type, type.tsymbol.pkgID, type.tsymbol.owner, - symTable, null, names); + symTable, null); } private BType getEffectiveImmutableType(BType type, PackageID pkgID, BSymbol owner) { return ImmutableTypeCloner.getEffectiveImmutableType(null, types, type, pkgID, owner, symTable, - null, names); + null); } } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/SourceDirectoryManager.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/SourceDirectoryManager.java index 9e5b9ab7a4b3..4673f6f1f0a6 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/SourceDirectoryManager.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/SourceDirectoryManager.java @@ -53,7 +53,6 @@ public class SourceDirectoryManager implements Project { new CompilerContext.Key<>(); private final CompilerOptions options; - private final Names names; private final SourceDirectory sourceDirectory; private Manifest manifest; @@ -71,7 +70,6 @@ private SourceDirectoryManager(CompilerContext context) { // This has to be further refactored with ProjectAPI Implementation context.put(PROJECT_KEY, this); - this.names = Names.getInstance(context); this.options = CompilerOptions.getInstance(context); // Check whether the compilation is initiated by the project API. diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java index 9d74da3a22a2..9186c3a0bfbf 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java @@ -237,7 +237,6 @@ public class BIRGen extends BLangNodeVisitor { public static final String DEFAULT_WORKER_NAME = "function"; private BIRGenEnv env; - private final Names names; private final SymbolTable symTable; private final BIROptimizer birOptimizer; private final Types types; @@ -271,7 +270,6 @@ public static BIRGen getInstance(CompilerContext context) { private BIRGen(CompilerContext context) { context.put(BIR_GEN, this); - this.names = Names.getInstance(context); this.symTable = SymbolTable.getInstance(context); this.birOptimizer = BIROptimizer.getInstance(context); this.unifier = new Unifier(); @@ -451,7 +449,7 @@ public void visit(BLangTypeDefinition astTypeDefinition) { } birFunc.returnVariable = new BIRVariableDcl(astTypeDefinition.pos, funcSymbol.retType, - this.env.nextLocalVarId(names), VarScope.FUNCTION, VarKind.RETURN, null); + this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.RETURN, null); birFunc.localVars.add(0, birFunc.returnVariable); typeDef.attachedFuncs.add(birFunc); @@ -512,7 +510,7 @@ public void visit(BLangClassDefinition classDefinition) { } birFunc.returnVariable = new BIRVariableDcl(classDefinition.pos, funcSymbol.retType, - this.env.nextLocalVarId(names), VarScope.FUNCTION, + this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.RETURN, null); birFunc.localVars.add(0, birFunc.returnVariable); @@ -576,7 +574,7 @@ public void visit(BLangFunction astFunc) { boolean isTypeAttachedFunction = astFunc.flagSet.contains(Flag.ATTACHED) && !typeDefs.containsKey(astFunc.receiver.getBType().tsymbol); - Name workerName = names.fromIdNode(astFunc.defaultWorkerName); + Name workerName = Names.fromIdNode(astFunc.defaultWorkerName); this.env.unlockVars.push(new BIRLockDetailsHolder()); Name funcName; @@ -591,7 +589,7 @@ public void visit(BLangFunction astFunc) { this.currentScope = new BirScope(0, null); if (astFunc.receiver != null) { BIRFunctionParameter birVarDcl = new BIRFunctionParameter(astFunc.pos, astFunc.receiver.getBType(), - this.env.nextLocalVarId(names), VarScope.FUNCTION, VarKind.ARG, astFunc.receiver.name.value, + this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.ARG, astFunc.receiver.name.value, false, false); this.env.symbolVarMap.put(astFunc.receiver.symbol, birVarDcl); birFunc.receiver = getSelf(astFunc.receiver.symbol); @@ -635,7 +633,7 @@ public void visit(BLangFunction astFunc) { // TODO: Return variable with NIL type should be written to BIR // Special %0 location for storing return values BType retType = unifier.build(astFunc.symbol.type.getReturnType()); - birFunc.returnVariable = new BIRVariableDcl(astFunc.pos, retType, this.env.nextLocalVarId(names), + birFunc.returnVariable = new BIRVariableDcl(astFunc.pos, retType, this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.RETURN, null); birFunc.localVars.add(0, birFunc.returnVariable); @@ -716,7 +714,7 @@ public void visit(BLangFunction astFunc) { } private BIRVariableDcl createBIRVarDeclForPathParam(BVarSymbol pathParamSym) { - return new BIRVariableDcl(pathParamSym.pos, pathParamSym.type, this.env.nextLocalVarId(names), + return new BIRVariableDcl(pathParamSym.pos, pathParamSym.type, this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.ARG, pathParamSym.name.value); } @@ -811,7 +809,7 @@ private boolean isWorkerSend(String chnlName, String workerName) { public void visit(BLangLambdaFunction lambdaExpr) { //fpload instruction BIRVariableDcl tempVarLambda = new BIRVariableDcl(lambdaExpr.pos, lambdaExpr.getBType(), - this.env.nextLocalVarId(names), VarScope.FUNCTION, + this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP, null); this.env.enclFunc.localVars.add(tempVarLambda); BIROperand lhsOp = new BIROperand(tempVarLambda); @@ -822,14 +820,14 @@ public void visit(BLangLambdaFunction lambdaExpr) { lambdaExpr.function.requiredParams.forEach(param -> { BIRVariableDcl birVarDcl = new BIRVariableDcl(param.pos, param.symbol.type, - this.env.nextLambdaVarId(names), VarScope.FUNCTION, VarKind.ARG, param.name.value); + this.env.nextLambdaVarId(), VarScope.FUNCTION, VarKind.ARG, param.name.value); params.add(birVarDcl); }); BLangSimpleVariable restParam = lambdaExpr.function.restParam; if (restParam != null) { BIRVariableDcl birVarDcl = new BIRVariableDcl(restParam.pos, restParam.symbol.type, - this.env.nextLambdaVarId(names), VarScope.FUNCTION, VarKind.ARG, null); + this.env.nextLambdaVarId(), VarScope.FUNCTION, VarKind.ARG, null); params.add(birVarDcl); } @@ -913,7 +911,7 @@ private void addParam(BIRFunction birFunc, BVarSymbol paramSymbol, BLangExpressi boolean isPathParam = paramSymbol.kind == SymbolKind.PATH_PARAMETER || paramSymbol.kind == SymbolKind.PATH_REST_PARAMETER; BIRFunctionParameter birVarDcl = new BIRFunctionParameter(pos, paramSymbol.type, - this.env.nextLocalVarId(names), VarScope.FUNCTION, VarKind.ARG, + this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.ARG, paramSymbol.name.value, defaultValExpr != null, isPathParam); birFunc.localVars.add(birVarDcl); @@ -930,7 +928,7 @@ private void addParam(BIRFunction birFunc, BVarSymbol paramSymbol, BLangExpressi private void addRestParam(BIRFunction birFunc, BVarSymbol paramSymbol, Location pos) { BIRFunctionParameter birVarDcl = new BIRFunctionParameter(pos, paramSymbol.type, - this.env.nextLocalVarId(names), VarScope.FUNCTION, VarKind.ARG, paramSymbol.name.value, false, + this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.ARG, paramSymbol.name.value, false, paramSymbol.kind == SymbolKind.PATH_REST_PARAMETER); birFunc.parameters.add(birVarDcl); birFunc.localVars.add(birVarDcl); @@ -948,7 +946,7 @@ private void addRequiredParam(BIRFunction birFunc, BVarSymbol paramSymbol, Locat boolean isPathParam = paramSymbol.kind == SymbolKind.PATH_PARAMETER || paramSymbol.kind == SymbolKind.PATH_REST_PARAMETER; BIRFunctionParameter birVarDcl = new BIRFunctionParameter(pos, paramSymbol.type, - this.env.nextLocalVarId(names), VarScope.FUNCTION, VarKind.ARG, paramSymbol.name.value, + this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.ARG, paramSymbol.name.value, false, isPathParam); birFunc.parameters.add(birVarDcl); birFunc.localVars.add(birVarDcl); @@ -1076,7 +1074,7 @@ public void visit(BLangSimpleVariableDef astVarDefStmt) { kind = VarKind.LOCAL; } BIRVariableDcl birVarDcl = new BIRVariableDcl(astVarDefStmt.pos, astVarDefStmt.var.symbol.type, - this.env.nextLocalVarId(names), VarScope.FUNCTION, kind, astVarDefStmt.var.name.value); + this.env.nextLocalVarId(), VarScope.FUNCTION, kind, astVarDefStmt.var.name.value); birVarDcl.startBB = this.env.enclBB; this.env.varDclsByBlock.get(this.currentBlock).add(birVarDcl); this.env.enclFunc.localVars.add(birVarDcl); @@ -1179,7 +1177,7 @@ public void visit(BLangForkJoin forkJoin) { public void visit(BLangAlternateWorkerReceive altWorkerReceive) { BIRBasicBlock thenBB = new BIRBasicBlock(this.env.nextBBId()); addToTrapStack(thenBB); - BIRVariableDcl tempVarDcl = new BIRVariableDcl(altWorkerReceive.getBType(), this.env.nextLocalVarId(names), + BIRVariableDcl tempVarDcl = new BIRVariableDcl(altWorkerReceive.getBType(), this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand lhsOp = new BIROperand(tempVarDcl); @@ -1215,7 +1213,7 @@ private List getChannelList( public void visit(BLangMultipleWorkerReceive multipleWorkerReceive) { BIRBasicBlock thenBB = new BIRBasicBlock(this.env.nextBBId()); addToTrapStack(thenBB); - BIRVariableDcl tempVarDcl = new BIRVariableDcl(multipleWorkerReceive.getBType(), this.env.nextLocalVarId(names), + BIRVariableDcl tempVarDcl = new BIRVariableDcl(multipleWorkerReceive.getBType(), this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand lhsOp = new BIROperand(tempVarDcl); @@ -1233,7 +1231,7 @@ public void visit(BLangWorkerReceive workerReceive) { BIRBasicBlock thenBB = new BIRBasicBlock(this.env.nextBBId()); addToTrapStack(thenBB); - BIRVariableDcl tempVarDcl = new BIRVariableDcl(workerReceive.getBType(), this.env.nextLocalVarId(names), + BIRVariableDcl tempVarDcl = new BIRVariableDcl(workerReceive.getBType(), this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand lhsOp = new BIROperand(tempVarDcl); @@ -1257,7 +1255,7 @@ public void visit(BLangWorkerAsyncSendExpr asyncSendExpr) { asyncSendExpr.expr.accept(this); BIROperand dataOp = this.env.targetOperand; BIRVariableDcl tempVarDcl = new BIRVariableDcl(asyncSendExpr.receive.matchingSendsError, - this.env.nextLocalVarId(names), VarScope.FUNCTION, VarKind.TEMP); + this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand lhsOp = new BIROperand(tempVarDcl); this.env.targetOperand = lhsOp; @@ -1279,7 +1277,7 @@ public void visit(BLangWorkerSyncSendExpr syncSend) { BIROperand dataOp = this.env.targetOperand; BIRVariableDcl tempVarDcl = new BIRVariableDcl(syncSend.receive.matchingSendsError, - this.env.nextLocalVarId(names), VarScope.FUNCTION, VarKind.TEMP); + this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand lhsOp = new BIROperand(tempVarDcl); this.env.targetOperand = lhsOp; @@ -1307,7 +1305,7 @@ public void visit(BLangWorkerFlushExpr flushExpr) { channels[i] = new BIRNode.ChannelDetails(sendStmt.getChannel().channelId(), isOnSameStrand, true); i++; } - BIRVariableDcl tempVarDcl = new BIRVariableDcl(flushExpr.getBType(), this.env.nextLocalVarId(names), + BIRVariableDcl tempVarDcl = new BIRVariableDcl(flushExpr.getBType(), this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand lhsOp = new BIROperand(tempVarDcl); @@ -1331,7 +1329,7 @@ private void createWait(BLangWaitExpr waitExpr) { exprList.add(this.env.targetOperand); }); - BIRVariableDcl tempVarDcl = new BIRVariableDcl(waitExpr.getBType(), this.env.nextLocalVarId(names), + BIRVariableDcl tempVarDcl = new BIRVariableDcl(waitExpr.getBType(), this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand lhsOp = new BIROperand(tempVarDcl); @@ -1346,7 +1344,7 @@ private void createWait(BLangWaitExpr waitExpr) { @Override public void visit(BLangErrorConstructorExpr errorConstructorExpr) { BIRVariableDcl tempVarError = new BIRVariableDcl(errorConstructorExpr.getBType(), - this.env.nextLocalVarId(names), VarScope.FUNCTION, + this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarError); @@ -1400,7 +1398,7 @@ private void createCall(BLangInvocation invocationExpr, boolean isVirtual) { } // Create a temporary variable to store the return operation result. - BIRVariableDcl tempVarDcl = new BIRVariableDcl(invocationExpr.getBType(), this.env.nextLocalVarId(names), + BIRVariableDcl tempVarDcl = new BIRVariableDcl(invocationExpr.getBType(), this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand lhsOp = new BIROperand(tempVarDcl); @@ -1603,14 +1601,14 @@ public void visit(BLangWhile astWhileStmt) { @Override public void visit(BLangIgnoreExpr ignoreExpr) { BIRVariableDcl tempVarDcl = new BIRVariableDcl(ignoreExpr.getBType(), - this.env.nextLocalVarId(names), VarScope.FUNCTION, VarKind.TEMP); + this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); } @Override public void visit(BLangLiteral astLiteralExpr) { BIRVariableDcl tempVarDcl = new BIRVariableDcl(astLiteralExpr.getBType(), - this.env.nextLocalVarId(names), VarScope.FUNCTION, VarKind.TEMP); + this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand toVarRef = new BIROperand(tempVarDcl); setScopeAndEmit(new BIRNonTerminator.ConstantLoad(astLiteralExpr.pos, @@ -1627,7 +1625,7 @@ public void visit(BLangMapLiteral astMapLiteralExpr) { visitTypedesc(astMapLiteralExpr.pos, type, Collections.emptyList(), getAnnotations(type.tsymbol, this.env)); BIRVariableDcl tempVarDcl = - new BIRVariableDcl(astMapLiteralExpr.getBType(), this.env.nextLocalVarId(names), + new BIRVariableDcl(astMapLiteralExpr.getBType(), this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand toVarRef = new BIROperand(tempVarDcl); @@ -1641,7 +1639,7 @@ public void visit(BLangMapLiteral astMapLiteralExpr) { @Override public void visit(BLangTypeConversionExpr astTypeConversionExpr) { BIRVariableDcl tempVarDcl = new BIRVariableDcl(astTypeConversionExpr.getBType(), - this.env.nextLocalVarId(names), VarScope.FUNCTION, VarKind.TEMP); + this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand toVarRef = new BIROperand(tempVarDcl); @@ -1661,7 +1659,7 @@ public void visit(BLangStructLiteral astStructLiteralExpr) { visitTypedesc(astStructLiteralExpr.pos, type, Collections.emptyList(), getAnnotations(type.tsymbol, this.env)); BIRVariableDcl tempVarDcl = new BIRVariableDcl(astStructLiteralExpr.getBType(), - this.env.nextLocalVarId(names), VarScope.FUNCTION, VarKind.TEMP); + this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand toVarRef = new BIROperand(tempVarDcl); @@ -1678,7 +1676,7 @@ public void visit(BLangStructLiteral astStructLiteralExpr) { @Override public void visit(BLangTypeInit connectorInitExpr) { BType exprType = connectorInitExpr.getBType(); - BIRVariableDcl tempVarDcl = new BIRVariableDcl(exprType, this.env.nextLocalVarId(names), VarScope.FUNCTION, + BIRVariableDcl tempVarDcl = new BIRVariableDcl(exprType, this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand toVarRef = new BIROperand(tempVarDcl); @@ -1752,7 +1750,7 @@ public void visit(BLangMapAccessExpr astMapAccessExpr) { keyRegIndex, rhsOp, astMapAccessExpr.isStoreOnCreation)); return; } - BIRVariableDcl tempVarDcl = new BIRVariableDcl(astMapAccessExpr.getBType(), this.env.nextLocalVarId(names), + BIRVariableDcl tempVarDcl = new BIRVariableDcl(astMapAccessExpr.getBType(), this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand tempVarRef = new BIROperand(tempVarDcl); @@ -1780,7 +1778,7 @@ public void visit(BLangTableAccessExpr astTableAccessExpr) { varRefRegIndex, keyRegIndex, rhsOp)); return; } - BIRVariableDcl tempVarDcl = new BIRVariableDcl(astTableAccessExpr.getBType(), this.env.nextLocalVarId(names), + BIRVariableDcl tempVarDcl = new BIRVariableDcl(astTableAccessExpr.getBType(), this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand tempVarRef = new BIROperand(tempVarDcl); @@ -1814,7 +1812,7 @@ public void visit(BLangDynamicArgExpr dynamicParamExpr) { @Override public void visit(BLangStringAccessExpr stringAccessExpr) { - BIRVariableDcl tempVarDcl = new BIRVariableDcl(stringAccessExpr.getBType(), this.env.nextLocalVarId(names), + BIRVariableDcl tempVarDcl = new BIRVariableDcl(stringAccessExpr.getBType(), this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand tempVarRef = new BIROperand(tempVarDcl); @@ -1843,7 +1841,7 @@ public void visit(BLangIndexBasedAccess.BLangTupleAccessExpr tupleAccessExpr) { @Override public void visit(BLangIsLikeExpr isLikeExpr) { BIRVariableDcl tempVarDcl = new BIRVariableDcl(symTable.booleanType, - this.env.nextLocalVarId(names), VarScope.FUNCTION, VarKind.TEMP); + this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand toVarRef = new BIROperand(tempVarDcl); @@ -1859,7 +1857,7 @@ public void visit(BLangIsLikeExpr isLikeExpr) { @Override public void visit(BLangTypeTestExpr typeTestExpr) { BIRVariableDcl tempVarDcl = new BIRVariableDcl(symTable.booleanType, - this.env.nextLocalVarId(names), VarScope.FUNCTION, VarKind.TEMP); + this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand toVarRef = new BIROperand(tempVarDcl); @@ -1885,7 +1883,7 @@ public void visit(BLangLocalVarRef astVarRefExpr) { } } else { BIRVariableDcl tempVarDcl = new BIRVariableDcl(varSymbol.type, - this.env.nextLocalVarId(names), VarScope.FUNCTION, VarKind.TEMP); + this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand tempVarRef = new BIROperand(tempVarDcl); @@ -1912,7 +1910,7 @@ public void visit(BLangPackageVarRef astPackageVarRefExpr) { } else { if (this.env.isInArrayOrStructure > 0) { BIRVariableDcl tempVarDcl = new BIRVariableDcl(astPackageVarRefExpr.getBType(), - this.env.nextLocalVarId(names), VarScope.FUNCTION, VarKind.TEMP); + this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand tempVarRef = new BIROperand(tempVarDcl); BIROperand fromVarRef = new BIROperand(getVarRef(astPackageVarRefExpr)); @@ -1952,7 +1950,7 @@ public void visit(BLangBinaryExpr astBinaryExpr) { // Create a temporary variable to store the binary operation result. BIRVariableDcl tempVarDcl = new BIRVariableDcl(astBinaryExpr.getBType(), - this.env.nextLocalVarId(names), VarScope.FUNCTION, VarKind.TEMP); + this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand lhsOp = new BIROperand(tempVarDcl); this.env.targetOperand = lhsOp; @@ -1970,7 +1968,7 @@ public void visit(BLangUnaryExpr unaryExpr) { // Create a temporary variable to store the unary operation result. BIRVariableDcl tempVarDcl = new BIRVariableDcl(unaryExpr.getBType(), - this.env.nextLocalVarId(names), VarScope.FUNCTION, VarKind.TEMP); + this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand lhsOp = new BIROperand(tempVarDcl); @@ -2024,7 +2022,7 @@ public void visit(BLangWaitForAllExpr.BLangWaitLiteral waitLiteral) { addToTrapStack(thenBB); BIRVariableDcl tempVarDcl = new BIRVariableDcl(waitLiteral.getBType(), - this.env.nextLocalVarId(names), VarScope.FUNCTION, VarKind.TEMP); + this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand toVarRef = new BIROperand(tempVarDcl); setScopeAndEmit(new BIRNonTerminator.NewStructure(waitLiteral.pos, toVarRef, this.env.targetOperand)); @@ -2049,7 +2047,7 @@ public void visit(BLangWaitForAllExpr.BLangWaitLiteral waitLiteral) { @Override public void visit(BLangIsAssignableExpr assignableExpr) { - BIRVariableDcl tempVarDcl = new BIRVariableDcl(symTable.booleanType, this.env.nextLocalVarId(names), + BIRVariableDcl tempVarDcl = new BIRVariableDcl(symTable.booleanType, this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand toVarRef = new BIROperand(tempVarDcl); @@ -2065,7 +2063,7 @@ public void visit(BLangIsAssignableExpr assignableExpr) { @Override public void visit(BLangXMLQName xmlQName) { BIRVariableDcl tempVarDcl = - new BIRVariableDcl(symTable.anyType, this.env.nextLocalVarId(names), VarScope.FUNCTION, VarKind.TEMP); + new BIRVariableDcl(symTable.anyType, this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand toVarRef = new BIROperand(tempVarDcl); @@ -2089,7 +2087,7 @@ public void visit(BLangXMLQName xmlQName) { @Override public void visit(BLangXMLElementLiteral xmlElementLiteral) { - BIRVariableDcl tempVarDcl = new BIRVariableDcl(xmlElementLiteral.getBType(), this.env.nextLocalVarId(names), + BIRVariableDcl tempVarDcl = new BIRVariableDcl(xmlElementLiteral.getBType(), this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand toVarRef = new BIROperand(tempVarDcl); @@ -2134,7 +2132,7 @@ public void visit(BLangXMLAttribute attribute) { @Override public void visit(BLangXMLSequenceLiteral xmlSequenceLiteral) { - BIRVariableDcl tempVarDcl = new BIRVariableDcl(xmlSequenceLiteral.getBType(), this.env.nextLocalVarId(names), + BIRVariableDcl tempVarDcl = new BIRVariableDcl(xmlSequenceLiteral.getBType(), this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); @@ -2150,7 +2148,7 @@ public void visit(BLangXMLSequenceLiteral xmlSequenceLiteral) { @Override public void visit(BLangXMLTextLiteral xmlTextLiteral) { - BIRVariableDcl tempVarDcl = new BIRVariableDcl(xmlTextLiteral.getBType(), this.env.nextLocalVarId(names), + BIRVariableDcl tempVarDcl = new BIRVariableDcl(xmlTextLiteral.getBType(), this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand toVarRef = new BIROperand(tempVarDcl); @@ -2166,7 +2164,7 @@ public void visit(BLangXMLTextLiteral xmlTextLiteral) { @Override public void visit(BLangXMLCommentLiteral xmlCommentLiteral) { - BIRVariableDcl tempVarDcl = new BIRVariableDcl(xmlCommentLiteral.getBType(), this.env.nextLocalVarId(names), + BIRVariableDcl tempVarDcl = new BIRVariableDcl(xmlCommentLiteral.getBType(), this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand toVarRef = new BIROperand(tempVarDcl); @@ -2184,7 +2182,7 @@ public void visit(BLangXMLCommentLiteral xmlCommentLiteral) { @Override public void visit(BLangXMLProcInsLiteral xmlProcInsLiteral) { - BIRVariableDcl tempVarDcl = new BIRVariableDcl(xmlProcInsLiteral.getBType(), this.env.nextLocalVarId(names), + BIRVariableDcl tempVarDcl = new BIRVariableDcl(xmlProcInsLiteral.getBType(), this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand toVarRef = new BIROperand(tempVarDcl); @@ -2236,7 +2234,7 @@ public void visit(BLangXMLAccessExpr xmlAccessExpr) { @Override public void visit(BLangTypedescExpr accessExpr) { BIRVariableDcl tempVarDcl = - new BIRVariableDcl(accessExpr.getBType(), this.env.nextLocalVarId(names), VarScope.FUNCTION, + new BIRVariableDcl(accessExpr.getBType(), this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand toVarRef = new BIROperand(tempVarDcl); @@ -2247,7 +2245,7 @@ public void visit(BLangTypedescExpr accessExpr) { @Override public void visit(BLangTableConstructorExpr tableConstructorExpr) { - BIRVariableDcl tempVarDcl = new BIRVariableDcl(tableConstructorExpr.getBType(), this.env.nextLocalVarId(names), + BIRVariableDcl tempVarDcl = new BIRVariableDcl(tableConstructorExpr.getBType(), this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); @@ -2303,7 +2301,7 @@ private void visitTypedesc(Location pos, BType type, BIROperand annotations) { } private void visitTypedesc(Location pos, BType type, List varDcls, BIROperand annotations) { - BIRVariableDcl tempVarDcl = new BIRVariableDcl(symTable.typeDesc, this.env.nextLocalVarId(names), + BIRVariableDcl tempVarDcl = new BIRVariableDcl(symTable.typeDesc, this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); BIRGenEnv env = this.env; env.enclFunc.localVars.add(tempVarDcl); @@ -2648,7 +2646,7 @@ public void visit(BLangReFlagsOnOff reFlagsOnOff) { } private BIROperand createVarRefOperand(BType type) { - BIRVariableDcl tempVarDcl = new BIRVariableDcl(type, this.env.nextLocalVarId(names), VarScope.FUNCTION, + BIRVariableDcl tempVarDcl = new BIRVariableDcl(type, this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); return new BIROperand(tempVarDcl); @@ -2702,7 +2700,7 @@ private InstructionKind getUnaryInstructionKind(OperatorKind opKind) { private void generateListConstructorExpr(BLangListConstructorExpr listConstructorExpr) { this.env.isInArrayOrStructure++; // Emit create array instruction - BIRVariableDcl tempVarDcl = new BIRVariableDcl(listConstructorExpr.getBType(), this.env.nextLocalVarId(names), + BIRVariableDcl tempVarDcl = new BIRVariableDcl(listConstructorExpr.getBType(), this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand toVarRef = new BIROperand(tempVarDcl); @@ -2770,7 +2768,7 @@ private void generateArrayAccess(BLangIndexBasedAccess astArrayAccessExpr) { varRefRegIndex, keyRegIndex, rhsOp)); return; } - BIRVariableDcl tempVarDcl = new BIRVariableDcl(astArrayAccessExpr.getBType(), this.env.nextLocalVarId(names), + BIRVariableDcl tempVarDcl = new BIRVariableDcl(astArrayAccessExpr.getBType(), this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand tempVarRef = new BIROperand(tempVarDcl); @@ -2813,7 +2811,7 @@ private void generateMappingAccess(BLangIndexBasedAccess astIndexBasedAccessExpr rhsOp, astIndexBasedAccessExpr.isStoreOnCreation)); } else { BIRVariableDcl tempVarDcl = new BIRVariableDcl(astIndexBasedAccessExpr.getBType(), - this.env.nextLocalVarId(names), + this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarDcl); BIROperand tempVarRef = new BIROperand(tempVarDcl); @@ -2876,7 +2874,7 @@ private BIROperand generateStringLiteral(String value) { private void generateXMLNamespace(BLangXMLNS xmlnsNode) { BIRVariableDcl birVarDcl = new BIRVariableDcl(xmlnsNode.pos, symTable.stringType, - this.env.nextLocalVarId(names), VarScope.FUNCTION, VarKind.LOCAL, null); + this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.LOCAL, null); this.env.enclFunc.localVars.add(birVarDcl); this.env.symbolVarMap.put(xmlnsNode.symbol, birVarDcl); @@ -2902,7 +2900,7 @@ private BIROperand generateNamespaceRef(BXMLNSSymbol nsSymbol, Location pos) { return generateStringLiteral(nsSymbol.namespaceURI); } - BIRVariableDcl nsURIVarDcl = new BIRVariableDcl(symTable.stringType, this.env.nextLocalVarId(names), + BIRVariableDcl nsURIVarDcl = new BIRVariableDcl(symTable.stringType, this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(nsURIVarDcl); BIROperand nsURIVarRef = new BIROperand(nsURIVarDcl); @@ -2955,7 +2953,7 @@ private BIROperand getQNameOP(BLangExpression qnameExpr, BIROperand keyRegIndex) } BIRVariableDcl tempQNameVarDcl = new BIRVariableDcl(symTable.anyType, - this.env.nextLocalVarId(names), VarScope.FUNCTION, VarKind.TEMP); + this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempQNameVarDcl); BIROperand qnameVarRef = new BIROperand(tempQNameVarDcl); setScopeAndEmit(new BIRNonTerminator.NewStringXMLQName(qnameExpr.pos, qnameVarRef, keyRegIndex)); @@ -2984,7 +2982,7 @@ private void generateXMLAccess(BLangXMLAccessExpr xmlAccessExpr, BIROperand temp private void generateFPVarRef(BLangExpression fpVarRef, BInvokableSymbol funcSymbol) { // fpload instruction BIRVariableDcl tempVarLambda = - new BIRVariableDcl(fpVarRef.getBType(), this.env.nextLocalVarId(names), VarScope.FUNCTION, + new BIRVariableDcl(fpVarRef.getBType(), this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.TEMP); this.env.enclFunc.localVars.add(tempVarLambda); BIROperand lhsOp = new BIROperand(tempVarLambda); @@ -2993,14 +2991,14 @@ private void generateFPVarRef(BLangExpression fpVarRef, BInvokableSymbol funcSym List params = new ArrayList<>(); funcSymbol.params.forEach(param -> { - BIRVariableDcl birVarDcl = new BIRVariableDcl(fpVarRef.pos, param.type, this.env.nextLambdaVarId(names), + BIRVariableDcl birVarDcl = new BIRVariableDcl(fpVarRef.pos, param.type, this.env.nextLambdaVarId(), VarScope.FUNCTION, VarKind.ARG, null); params.add(birVarDcl); }); BVarSymbol restParam = funcSymbol.restParam; if (restParam != null) { - BIRVariableDcl birVarDcl = new BIRVariableDcl(fpVarRef.pos, restParam.type, this.env.nextLambdaVarId(names), + BIRVariableDcl birVarDcl = new BIRVariableDcl(fpVarRef.pos, restParam.type, this.env.nextLambdaVarId(), VarScope.FUNCTION, VarKind.ARG, null); params.add(birVarDcl); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGenEnv.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGenEnv.java index 9cf1bb8eafa0..ad18654642b3 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGenEnv.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGenEnv.java @@ -85,14 +85,14 @@ int nextBBId() { return ++currentBBId; } - Name nextLocalVarId(Names names) { + Name nextLocalVarId() { currentLocalVarId++; - return names.merge(Names.BIR_LOCAL_VAR_PREFIX, Names.fromString(Integer.toString(currentLocalVarId))); + return Names.merge(Names.BIR_LOCAL_VAR_PREFIX, Names.fromString(Integer.toString(currentLocalVarId))); } - Name nextLambdaVarId(Names names) { + Name nextLambdaVarId() { currentLambdaVarId++; - return names.merge(Names.BIR_LOCAL_VAR_PREFIX, Names.fromString(Integer.toString(currentLambdaVarId))); + return Names.merge(Names.BIR_LOCAL_VAR_PREFIX, Names.fromString(Integer.toString(currentLambdaVarId))); } void clear() { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ASTBuilderUtil.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ASTBuilderUtil.java index d36bb7fe379e..a53dea454ba0 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ASTBuilderUtil.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ASTBuilderUtil.java @@ -167,9 +167,9 @@ static void appendStatement(BLangStatement stmt, BLangBlockStmt target) { target.stmts.add(index, stmt); } - static void defineVariable(BLangSimpleVariable variable, BSymbol targetSymbol, Names names) { - variable.symbol = new BVarSymbol(0, names.fromIdNode(variable.name), - names.originalNameFromIdNode(variable.name), + static void defineVariable(BLangSimpleVariable variable, BSymbol targetSymbol) { + variable.symbol = new BVarSymbol(0, Names.fromIdNode(variable.name), + Names.originalNameFromIdNode(variable.name), targetSymbol.pkgID, variable.getBType(), targetSymbol, variable.pos, VIRTUAL); targetSymbol.scope.define(variable.symbol.name, variable.symbol); } @@ -628,7 +628,6 @@ static BLangIsAssignableExpr createIsAssignableExpr(Location pos, BLangExpression lhsExpr, BType targetType, BType type, - Names names, Location opSymPos) { final BLangIsAssignableExpr assignableExpr = new BLangIsAssignableExpr(); assignableExpr.pos = pos; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/AnnotationDesugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/AnnotationDesugar.java index 6fa8f65020e6..5b460b2872cd 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/AnnotationDesugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/AnnotationDesugar.java @@ -135,7 +135,6 @@ public class AnnotationDesugar { private final Desugar desugar; private final SymbolTable symTable; private final Types types; - private final Names names; private SymbolResolver symResolver; private ConstantValueResolver constantValueResolver; private ClosureGenerator closureGenerator; @@ -153,7 +152,6 @@ private AnnotationDesugar(CompilerContext context) { this.desugar = Desugar.getInstance(context); this.symTable = SymbolTable.getInstance(context); this.types = Types.getInstance(context); - this.names = Names.getInstance(context); this.symResolver = SymbolResolver.getInstance(context); this.constantValueResolver = ConstantValueResolver.getInstance(context); this.closureGenerator = ClosureGenerator.getInstance(context); @@ -921,7 +919,7 @@ private BLangSimpleVariable createGlobalAnnotationMapVar(BLangPackage pkgNode) { symTable.mapType, ASTBuilderUtil.createEmptyRecordLiteral( pkgNode.pos, symTable.mapType), null); - ASTBuilderUtil.defineVariable(annotationMap, pkgNode.symbol, names); + ASTBuilderUtil.defineVariable(annotationMap, pkgNode.symbol); pkgNode.globalVars.add(0, annotationMap); // TODO fix this pkgNode.topLevelNodes.add(0, annotationMap); return annotationMap; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ClassClosureDesugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ClassClosureDesugar.java index ac4477a039a2..04f9cf96d05b 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ClassClosureDesugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ClassClosureDesugar.java @@ -178,7 +178,6 @@ public class ClassClosureDesugar extends BLangNodeVisitor { private final SymbolTable symTable; private final Desugar desugar; - private final Names names; private final BLangDiagnosticLog dlog; static { @@ -197,7 +196,6 @@ private ClassClosureDesugar(CompilerContext context) { context.put(CLASS_CLOSURE_DESUGAR_KEY, this); this.symTable = SymbolTable.getInstance(context); this.desugar = Desugar.getInstance(context); - this.names = Names.getInstance(context); this.dlog = BLangDiagnosticLog.getInstance(context); CLOSURE_MAP_NOT_FOUND.pos = this.symTable.builtinPos; } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ClosureDesugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ClosureDesugar.java index bedf07625c9d..59ae8428b4d3 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ClosureDesugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ClosureDesugar.java @@ -210,7 +210,6 @@ public class ClosureDesugar extends BLangNodeVisitor { private BLangNode result; private Types types; private Desugar desugar; - private Names names; private ClassClosureDesugar classClosureDesugar; private int funClosureMapCount = 1; private int blockClosureMapCount = 1; @@ -233,7 +232,6 @@ private ClosureDesugar(CompilerContext context) { this.symTable = SymbolTable.getInstance(context); this.types = Types.getInstance(context); this.desugar = Desugar.getInstance(context); - this.names = Names.getInstance(context); this.symResolver = SymbolResolver.getInstance(context); this.classClosureDesugar = ClassClosureDesugar.getInstance(context); CLOSURE_MAP_NOT_FOUND.pos = this.symTable.builtinPos; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/DeclarativeAuthDesugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/DeclarativeAuthDesugar.java index 2b8533ea8cf3..7ef6d9d61217 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/DeclarativeAuthDesugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/DeclarativeAuthDesugar.java @@ -70,7 +70,6 @@ public class DeclarativeAuthDesugar { private final SymbolTable symTable; private final SymbolResolver symResolver; - private final Names names; private static final String ORG_NAME = "ballerina"; private static final String HTTP_PACKAGE_NAME = "http"; @@ -94,7 +93,6 @@ private DeclarativeAuthDesugar(CompilerContext context) { context.put(DECLARATIVE_AUTH_DESUGAR_KEY, this); this.symTable = SymbolTable.getInstance(context); this.symResolver = SymbolResolver.getInstance(context); - this.names = Names.getInstance(context); } void desugarFunction(BLangFunction functionNode, SymbolEnv env, List expressionTypes) { @@ -181,7 +179,7 @@ void addAuthDesugarFunctionInvocation(BLangFunction functionNode, SymbolEnv env, List statements = getFunctionBodyStatementList(functionNode); statements.add(0, result); - BVarSymbol resultSymbol = new BVarSymbol(0, names.fromIdNode(result.var.name), env.enclPkg.packageID, + BVarSymbol resultSymbol = new BVarSymbol(0, Names.fromIdNode(result.var.name), env.enclPkg.packageID, result.var.getBType(), functionNode.symbol, pos, VIRTUAL); functionNode.symbol.scope.define(resultSymbol.name, resultSymbol); result.var.symbol = resultSymbol; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java index 8aa47375a4d7..6f69a1a82607 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/Desugar.java @@ -387,7 +387,6 @@ public class Desugar extends BLangNodeVisitor { private Code2CloudDesugar code2CloudDesugar; private AnnotationDesugar annotationDesugar; private Types types; - private Names names; private ServiceDesugar serviceDesugar; private BLangNode result; private NodeCloner nodeCloner; @@ -465,8 +464,6 @@ private Desugar(CompilerContext context) { this.annotationDesugar = AnnotationDesugar.getInstance(context); this.largeMethodSplitter = LargeMethodSplitter.getInstance(context); this.types = Types.getInstance(context); - this.names = Names.getInstance(context); - this.names = Names.getInstance(context); this.serviceDesugar = ServiceDesugar.getInstance(context); this.nodeCloner = NodeCloner.getInstance(context); this.semanticAnalyzer = SemanticAnalyzer.getInstance(context); @@ -1640,7 +1637,7 @@ private void createRestFieldVarDefStmts(BLangTupleVariable parentTupleVariable, final BLangSimpleVariable foreachVariable = ASTBuilderUtil.createVariable(pos, "$foreach$i", foreach.varType); - foreachVariable.symbol = new BVarSymbol(0, names.fromIdNode(foreachVariable.name), + foreachVariable.symbol = new BVarSymbol(0, Names.fromIdNode(foreachVariable.name), this.env.scope.owner.pkgID, foreachVariable.getBType(), this.env.scope.owner, pos, VIRTUAL); BLangSimpleVarRef foreachVarRef = ASTBuilderUtil.createVariableRef(pos, foreachVariable.symbol); @@ -1886,7 +1883,7 @@ private void createVarDefStmts(BLangErrorVariable parentErrorVariable, BLangBloc parentErrorVariable.message.getBType(), convertedErrorVarSymbol, null); - if (names.fromIdNode(parentErrorVariable.message.name) == Names.IGNORE) { + if (Names.fromIdNode(parentErrorVariable.message.name) == Names.IGNORE) { parentErrorVariable.message = null; } else { BLangSimpleVariableDef messageVariableDef = @@ -1933,7 +1930,7 @@ private void createVarDefStmts(BLangErrorVariable parentErrorVariable, BLangBloc detailTempVarDef.setBType(parentErrorVariable.detailExpr.getBType()); parentBlockStmt.addStatement(detailTempVarDef); - this.env.scope.define(names.fromIdNode(detailTempVarDef.var.name), detailTempVarDef.var.symbol); + this.env.scope.define(Names.fromIdNode(detailTempVarDef.var.name), detailTempVarDef.var.symbol); for (BLangErrorVariable.BLangErrorDetailEntry detailEntry : parentErrorVariable.detail) { BLangExpression detailEntryVar = createErrorDetailVar(detailEntry, detailTempVarDef.var.symbol); @@ -2465,7 +2462,7 @@ private void createSimpleVarDefStmt(BLangSimpleVariable simpleVariable, BLangBlo BLangLiteral indexExpr, BVarSymbol tupleVarSymbol, BLangIndexBasedAccess parentArrayAccessExpr) { - Name varName = names.fromIdNode(simpleVariable.name); + Name varName = Names.fromIdNode(simpleVariable.name); if (varName == Names.IGNORE) { return; } @@ -2609,7 +2606,7 @@ private void createRestFieldAssignmentStmt(BLangTupleVarRef tupleVarRef, BLangBl final BLangSimpleVariable foreachVariable = ASTBuilderUtil.createVariable(pos, "$foreach$i", foreach.varType); - foreachVariable.symbol = new BVarSymbol(0, names.fromIdNode(foreachVariable.name), + foreachVariable.symbol = new BVarSymbol(0, Names.fromIdNode(foreachVariable.name), this.env.scope.owner.pkgID, foreachVariable.getBType(), this.env.scope.owner, pos, VIRTUAL); BLangSimpleVarRef foreachVarRef = ASTBuilderUtil.createVariableRef(pos, foreachVariable.symbol); @@ -2735,7 +2732,7 @@ private void createAssignmentStmt(BLangExpression accessibleExpression, BLangBlo BLangIndexBasedAccess parentArrayAccessExpr) { if (accessibleExpression.getKind() == NodeKind.SIMPLE_VARIABLE_REF) { - Name varName = names.fromIdNode(((BLangSimpleVarRef) accessibleExpression).variableName); + Name varName = Names.fromIdNode(((BLangSimpleVarRef) accessibleExpression).variableName); if (varName == Names.IGNORE) { return; } @@ -2918,7 +2915,7 @@ private void createVarRefAssignmentStmts(BLangRecordVarRef parentRecordVarRef, B private void createVarRefAssignmentStmts(BLangErrorVarRef parentErrorVarRef, BLangBlockStmt parentBlockStmt, BVarSymbol errorVarySymbol, BLangIndexBasedAccess parentIndexAccessExpr) { if (parentErrorVarRef.message != null && - names.fromIdNode(((BLangSimpleVarRef) parentErrorVarRef.message).variableName) != Names.IGNORE) { + Names.fromIdNode(((BLangSimpleVarRef) parentErrorVarRef.message).variableName) != Names.IGNORE) { BLangAssignment message = ASTBuilderUtil.createAssignmentStmt(parentBlockStmt.pos, parentBlockStmt); message.expr = generateErrorMessageBuiltinFunction(parentErrorVarRef.message.pos, symTable.stringType, errorVarySymbol, parentIndexAccessExpr); @@ -2927,7 +2924,7 @@ private void createVarRefAssignmentStmts(BLangErrorVarRef parentErrorVarRef, BLa } if (parentErrorVarRef.cause != null && (parentErrorVarRef.cause.getKind() != NodeKind.SIMPLE_VARIABLE_REF || - names.fromIdNode(((BLangSimpleVarRef) parentErrorVarRef.cause).variableName) != Names.IGNORE)) { + Names.fromIdNode(((BLangSimpleVarRef) parentErrorVarRef.cause).variableName) != Names.IGNORE)) { BLangAssignment cause = ASTBuilderUtil.createAssignmentStmt(parentBlockStmt.pos, parentBlockStmt); cause.expr = generateErrorCauseLanglibFunction(parentErrorVarRef.cause.pos, symTable.errorType, errorVarySymbol, parentIndexAccessExpr); @@ -2949,7 +2946,7 @@ private void createVarRefAssignmentStmts(BLangErrorVarRef parentErrorVarRef, BLa parentErrorVarRef.pos); detailTempVarDef.setBType(symTable.detailType); parentBlockStmt.addStatement(detailTempVarDef); - this.env.scope.define(names.fromIdNode(detailTempVarDef.var.name), detailTempVarDef.var.symbol); + this.env.scope.define(Names.fromIdNode(detailTempVarDef.var.name), detailTempVarDef.var.symbol); List extractedKeys = new ArrayList<>(); for (BLangNamedArgsExpression detail : parentErrorVarRef.detail) { @@ -4924,7 +4921,7 @@ private BType createMatchingRecordType(BLangErrorFieldMatchPatterns errorFieldMa BRecordType detailRecordType = createAnonRecordType(errorFieldMatchPatterns.pos); List typeDefFields = new ArrayList<>(); for (BLangNamedArgMatchPattern bindingPattern : errorFieldMatchPatterns.namedArgMatchPatterns) { - Name fieldName = names.fromIdNode(bindingPattern.argName); + Name fieldName = Names.fromIdNode(bindingPattern.argName); BVarSymbol declaredVarSym = bindingPattern.declaredVars.get(fieldName.value); if (declaredVarSym == null) { // constant match pattern expr, not needed for detail record type @@ -5013,7 +5010,7 @@ private BType createMatchingRecordType(BLangErrorFieldBindingPatterns errorField BRecordType detailRecordType = createAnonRecordType(errorFieldBindingPatterns.pos); List typeDefFields = new ArrayList<>(); for (BLangNamedArgBindingPattern bindingPattern : errorFieldBindingPatterns.namedArgBindingPatterns) { - Name fieldName = names.fromIdNode(bindingPattern.argName); + Name fieldName = Names.fromIdNode(bindingPattern.argName); BVarSymbol declaredVarSym = bindingPattern.declaredVars.get(fieldName.value); if (declaredVarSym == null) { // constant match pattern expr, not needed for detail record type @@ -8392,7 +8389,7 @@ private BLangClassDefinition desugarTemplateLiteralObjectTypedef(List de } for (BLangErrorVariable.BLangErrorDetailEntry detailEntry : detail) { - Name fieldName = names.fromIdNode(detailEntry.key); + Name fieldName = Names.fromIdNode(detailEntry.key); BType fieldType = getStructuredBindingPatternType(detailEntry.valueBindingPattern); BVarSymbol fieldSym = new BVarSymbol(Flags.PUBLIC, fieldName, detailRecordType.tsymbol.pkgID, fieldType, detailRecordType.tsymbol, detailEntry.key.pos, VIRTUAL); @@ -10439,7 +10436,7 @@ private BLangFunction createInitFunctionForClassDefn(BLangClassDefinition classD } BLangFunction initFunction = - TypeDefBuilderHelper.createInitFunctionForStructureType(classDefinition.symbol, env, names, + TypeDefBuilderHelper.createInitFunctionForStructureType(classDefinition.symbol, env, GENERATED_INIT_SUFFIX, classDefinition.getBType(), returnType); BObjectTypeSymbol typeSymbol = ((BObjectTypeSymbol) classDefinition.getBType().tsymbol); typeSymbol.generatedInitializerFunc = new BAttachedFunction(GENERATED_INIT_SUFFIX, initFunction.symbol, diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/LargeMethodSplitter.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/LargeMethodSplitter.java index 59d2083cc87e..25f9bdb3d24e 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/LargeMethodSplitter.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/LargeMethodSplitter.java @@ -62,7 +62,6 @@ public class LargeMethodSplitter { private final Desugar desugar; private final SymbolTable symTable; - private final Names names; private final SymbolResolver symResolver; private static final CompilerContext.Key LARGE_METHOD_SPLITTER_KEY = @@ -80,7 +79,6 @@ private LargeMethodSplitter(CompilerContext context) { context.put(LARGE_METHOD_SPLITTER_KEY, this); this.desugar = Desugar.getInstance(context); this.symTable = SymbolTable.getInstance(context); - this.names = Names.getInstance(context); this.symResolver = SymbolResolver.getInstance(context); } @@ -142,7 +140,7 @@ private BLangFunction splitInitFunction(BLangPackage packageNode, SymbolEnv env) } newFunc.pos = newFuncPos; newFuncBody = (BLangBlockFunctionBody) newFunc.body; - symTable.rootScope.define(names.fromIdNode(newFunc.name), newFunc.symbol); + symTable.rootScope.define(Names.fromIdNode(newFunc.name), newFunc.symbol); } newFuncBody.stmts.add(stmts.get(i)); } @@ -209,7 +207,7 @@ private BLangFunction splitStartFunction(BLangPackage packageNode, SymbolEnv env generatedFunctions.add(newFunc); newFunc = createIntermediateStartFunction(packageNode, env); newFuncBody = (BLangBlockFunctionBody) newFunc.body; - symTable.rootScope.define(names.fromIdNode(newFunc.name), newFunc.symbol); + symTable.rootScope.define(Names.fromIdNode(newFunc.name), newFunc.symbol); } newFuncBody.stmts.add(stmts.get(i)); } @@ -271,7 +269,7 @@ private BLangFunction splitStopFunction(BLangPackage packageNode, SymbolEnv env) generatedFunctions.add(newFunc); newFunc = createIntermediateStopFunction(packageNode, env); newFuncBody = (BLangBlockFunctionBody) newFunc.body; - symTable.rootScope.define(names.fromIdNode(newFunc.name), newFunc.symbol); + symTable.rootScope.define(Names.fromIdNode(newFunc.name), newFunc.symbol); } newFuncBody.stmts.add(stmts.get(i)); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/QueryDesugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/QueryDesugar.java index 8c1e94878d25..f6030a14084f 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/QueryDesugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/QueryDesugar.java @@ -250,7 +250,6 @@ public class QueryDesugar extends BLangNodeVisitor { private final Desugar desugar; private final SymbolTable symTable; private final SymbolResolver symResolver; - private final Names names; private final Types types; private SymbolEnv env; private SymbolEnv queryEnv; @@ -264,7 +263,6 @@ private QueryDesugar(CompilerContext context) { context.put(QUERY_DESUGAR_KEY, this); this.symTable = SymbolTable.getInstance(context); this.symResolver = SymbolResolver.getInstance(context); - this.names = Names.getInstance(context); this.types = Types.getInstance(context); this.desugar = Desugar.getInstance(context); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ServiceDesugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ServiceDesugar.java index f5a8a18e74e0..41183c32cd32 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ServiceDesugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/ServiceDesugar.java @@ -76,7 +76,6 @@ public class ServiceDesugar { private final SymbolTable symTable; private final SymbolResolver symResolver; - private final Names names; private DeclarativeAuthDesugar declarativeAuthDesugar; private TransactionDesugar transactionDesugar; private final Types types; @@ -94,7 +93,6 @@ private ServiceDesugar(CompilerContext context) { context.put(SERVICE_DESUGAR_KEY, this); this.symTable = SymbolTable.getInstance(context); this.symResolver = SymbolResolver.getInstance(context); - this.names = Names.getInstance(context); this.declarativeAuthDesugar = DeclarativeAuthDesugar.getInstance(context); this.transactionDesugar = TransactionDesugar.getInstance(context); this.types = Types.getInstance(context); @@ -154,7 +152,7 @@ void rewriteServiceVariable(BLangService service, SymbolEnv env, BLangBlockStmt final Location pos = service.pos; - ASTBuilderUtil.defineVariable(service.serviceVariable, env.enclPkg.symbol, names); + ASTBuilderUtil.defineVariable(service.serviceVariable, env.enclPkg.symbol); env.enclPkg.globalVars.add(service.serviceVariable); int count = 0; @@ -169,7 +167,7 @@ void rewriteServiceVariable(BLangService service, SymbolEnv env, BLangBlockStmt .createVariable(pos, generateServiceListenerVarName(service) + count, attachExpr.getBType(), attachExpr, null); - ASTBuilderUtil.defineVariable(listenerVar, env.enclPkg.symbol, names); + ASTBuilderUtil.defineVariable(listenerVar, env.enclPkg.symbol); listenerVar.symbol.flags |= Flags.LISTENER; env.enclPkg.globalVars.add(listenerVar); listenerVarRef = ASTBuilderUtil.createVariableRef(pos, listenerVar.symbol); @@ -184,7 +182,7 @@ void rewriteServiceVariable(BLangService service, SymbolEnv env, BLangBlockStmt getListenerTypeWithoutError(listenerVarRef.getBType()), listenerCheckExpr, null); - ASTBuilderUtil.defineVariable(listenerWithoutErrors, env.enclPkg.symbol, names); + ASTBuilderUtil.defineVariable(listenerWithoutErrors, env.enclPkg.symbol); env.enclPkg.globalVars.add(listenerWithoutErrors); BLangSimpleVarRef checkedRef = ASTBuilderUtil.createVariableRef(pos, listenerWithoutErrors.symbol); listenerVarRef = checkedRef; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/TransactionDesugar.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/TransactionDesugar.java index d81adba0d815..cefcef868423 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/TransactionDesugar.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/desugar/TransactionDesugar.java @@ -94,7 +94,6 @@ public class TransactionDesugar extends BLangNodeVisitor { private final Desugar desugar; private final SymbolTable symTable; private final SymbolResolver symResolver; - private final Names names; private final PackageCache packageCache; private BSymbol transactionError; @@ -115,7 +114,6 @@ private TransactionDesugar(CompilerContext context) { context.put(TRANSACTION_DESUGAR_KEY, this); this.symTable = SymbolTable.getInstance(context); this.symResolver = SymbolResolver.getInstance(context); - this.names = Names.getInstance(context); this.desugar = Desugar.getInstance(context); this.packageCache = PackageCache.getInstance(context); this.types = Types.getInstance(context); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java index 4edbc78127c4..e7dd28fc44fc 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/CodeAnalyzer.java @@ -294,7 +294,6 @@ public class CodeAnalyzer extends SimpleBLangNodeAnalyzer(); private final BLangMissingNodesHelper missingNodesHelper; - private final Names names; private final SymbolTable symTable; private final SymbolResolver symResolver; private BLangDiagnosticLog dlog; @@ -66,7 +65,6 @@ private ConstantAnalyzer(CompilerContext context) { context.put(CONSTANT_ANALYZER_KEY, this); this.missingNodesHelper = BLangMissingNodesHelper.getInstance(context); - this.names = Names.getInstance(context); this.symTable = SymbolTable.getInstance(context); this.symResolver = SymbolResolver.getInstance(context); this.dlog = BLangDiagnosticLog.getInstance(context); @@ -106,7 +104,7 @@ public void visit(BLangSimpleVarRef varRef) { if (varRef.pkgSymbol != symTable.notFoundSymbol && symbol == symTable.notFoundSymbol) { SymbolEnv pkgEnv = symTable.pkgEnvMap.get(varRef.pkgSymbol); symbol = pkgEnv == null ? symbol : symResolver.lookupMainSpaceSymbolInPackage(varRef.pos, pkgEnv, - names.fromIdNode(varRef.pkgAlias), names.fromIdNode(varRef.variableName)); + Names.fromIdNode(varRef.pkgAlias), Names.fromIdNode(varRef.variableName)); } if (symbol == symTable.notFoundSymbol) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/ConstantTypeChecker.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/ConstantTypeChecker.java index 1f1087921e10..71baed9aadb7 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/ConstantTypeChecker.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/ConstantTypeChecker.java @@ -127,7 +127,6 @@ public class ConstantTypeChecker extends SimpleBLangNodeAnalyzer(); private final SymbolTable symTable; - private final Names names; private final NodeCloner nodeCloner; private final SymbolResolver symResolver; private final BLangDiagnosticLog dlog; @@ -141,7 +140,6 @@ public ConstantTypeChecker(CompilerContext context) { context.put(CONSTANT_TYPE_CHECKER_KEY, this); this.symTable = SymbolTable.getInstance(context); - this.names = Names.getInstance(context); this.symResolver = SymbolResolver.getInstance(context); this.nodeCloner = NodeCloner.getInstance(context); this.dlog = BLangDiagnosticLog.getInstance(context); @@ -293,13 +291,13 @@ public void visit(BLangSimpleVarRef varRefExpr, AnalyzerData data) { // Set error type as the actual type. BType actualType = symTable.semanticError; - Name varName = names.fromIdNode(varRefExpr.variableName); + Name varName = Names.fromIdNode(varRefExpr.variableName); if (varName == Names.IGNORE) { varRefExpr.setBType(this.symTable.anyType); // If the variable name is a wildcard('_'), the symbol should be ignorable. varRefExpr.symbol = new BVarSymbol(0, true, varName, - names.originalNameFromIdNode(varRefExpr.variableName), + Names.originalNameFromIdNode(varRefExpr.variableName), data.env.enclPkg.symbol.pkgID, varRefExpr.getBType(), data.env.scope.owner, varRefExpr.pos, VIRTUAL); @@ -309,13 +307,13 @@ public void visit(BLangSimpleVarRef varRefExpr, AnalyzerData data) { Name compUnitName = typeChecker.getCurrentCompUnit(varRefExpr); varRefExpr.pkgSymbol = - symResolver.resolvePrefixSymbol(data.env, names.fromIdNode(varRefExpr.pkgAlias), compUnitName); + symResolver.resolvePrefixSymbol(data.env, Names.fromIdNode(varRefExpr.pkgAlias), compUnitName); if (varRefExpr.pkgSymbol == symTable.notFoundSymbol) { varRefExpr.symbol = symTable.notFoundSymbol; dlog.error(varRefExpr.pos, DiagnosticErrorCode.UNDEFINED_MODULE, varRefExpr.pkgAlias); } else { BSymbol symbol = - typeResolver.getSymbolOfVarRef(varRefExpr.pos, data.env, names.fromIdNode(varRefExpr.pkgAlias), + typeResolver.getSymbolOfVarRef(varRefExpr.pos, data.env, Names.fromIdNode(varRefExpr.pkgAlias), varName); if (symbol == symTable.notFoundSymbol) { @@ -353,13 +351,13 @@ public void visit(BLangListConstructorExpr listConstructor, AnalyzerData data) { public void visit(BLangRecordLiteral.BLangRecordVarNameField varRefExpr, AnalyzerData data) { BType actualType = symTable.semanticError; - Name varName = names.fromIdNode(varRefExpr.variableName); + Name varName = Names.fromIdNode(varRefExpr.variableName); if (varName == Names.IGNORE) { varRefExpr.setBType(this.symTable.anyType); // If the variable name is a wildcard('_'), the symbol should be ignorable. varRefExpr.symbol = new BVarSymbol(0, true, varName, - names.originalNameFromIdNode(varRefExpr.variableName), + Names.originalNameFromIdNode(varRefExpr.variableName), data.env.enclPkg.symbol.pkgID, varRefExpr.getBType(), data.env.scope.owner, varRefExpr.pos, VIRTUAL); @@ -369,7 +367,7 @@ public void visit(BLangRecordLiteral.BLangRecordVarNameField varRefExpr, Analyze Name compUnitName = typeChecker.getCurrentCompUnit(varRefExpr); varRefExpr.pkgSymbol = - symResolver.resolvePrefixSymbol(data.env, names.fromIdNode(varRefExpr.pkgAlias), compUnitName); + symResolver.resolvePrefixSymbol(data.env, Names.fromIdNode(varRefExpr.pkgAlias), compUnitName); if (varRefExpr.pkgSymbol == symTable.notFoundSymbol) { varRefExpr.symbol = symTable.notFoundSymbol; dlog.error(varRefExpr.pos, DiagnosticErrorCode.UNDEFINED_MODULE, varRefExpr.pkgAlias); @@ -377,7 +375,7 @@ public void visit(BLangRecordLiteral.BLangRecordVarNameField varRefExpr, Analyze if (varRefExpr.pkgSymbol != symTable.notFoundSymbol) { BSymbol symbol = - typeResolver.getSymbolOfVarRef(varRefExpr.pos, data.env, names.fromIdNode(varRefExpr.pkgAlias), + typeResolver.getSymbolOfVarRef(varRefExpr.pos, data.env, Names.fromIdNode(varRefExpr.pkgAlias), varName); if (symbol == symTable.notFoundSymbol) { @@ -519,8 +517,7 @@ private BRecordType createNewRecordType(BRecordTypeSymbol symbol, LinkedHashMap< symbol.type = recordType; recordType.tsymbol = symbol; recordType.sealed = true; - TypeDefBuilderHelper.createTypeDefinition(recordType, data.constantSymbol.pos, names, types, - symTable, data.env); + TypeDefBuilderHelper.createTypeDefinition(recordType, data.constantSymbol.pos, types, symTable, data.env); return recordType; } @@ -644,15 +641,15 @@ private BType getMappingConstructorCompatibleNonUnionType(BType type, AnalyzerDa case TypeTags.JSON: return !Symbols.isFlagOn(type.flags, Flags.READONLY) ? symTable.mapJsonType : ImmutableTypeCloner.getEffectiveImmutableType(null, types, symTable.mapJsonType, data.env, - symTable, anonymousModelHelper, names); + symTable, anonymousModelHelper); case TypeTags.ANYDATA: return !Symbols.isFlagOn(type.flags, Flags.READONLY) ? symTable.mapAnydataType : ImmutableTypeCloner.getEffectiveImmutableType(null, types, symTable.mapAnydataType, - data.env, symTable, anonymousModelHelper, names); + data.env, symTable, anonymousModelHelper); case TypeTags.ANY: return !Symbols.isFlagOn(type.flags, Flags.READONLY) ? symTable.mapAllType : ImmutableTypeCloner.getEffectiveImmutableType(null, types, symTable.mapAllType, data.env, - symTable, anonymousModelHelper, names); + symTable, anonymousModelHelper); case TypeTags.INTERSECTION: return ((BIntersectionType) type).effectiveType; case TypeTags.TYPEREFDESC: @@ -1388,13 +1385,13 @@ private BType getListConstructorCompatibleNonUnionType(BType type, AnalyzerData TypeTags.TYPEDESC -> type; case TypeTags.JSON -> !Symbols.isFlagOn(type.flags, Flags.READONLY) ? symTable.arrayJsonType : ImmutableTypeCloner.getEffectiveImmutableType(null, types, symTable.arrayJsonType, - data.env, symTable, anonymousModelHelper, names); + data.env, symTable, anonymousModelHelper); case TypeTags.ANYDATA -> !Symbols.isFlagOn(type.flags, Flags.READONLY) ? symTable.arrayAnydataType : ImmutableTypeCloner.getEffectiveImmutableType(null, types, symTable.arrayAnydataType, - data.env, symTable, anonymousModelHelper, names); + data.env, symTable, anonymousModelHelper); case TypeTags.ANY -> !Symbols.isFlagOn(type.flags, Flags.READONLY) ? symTable.arrayAllType : ImmutableTypeCloner.getEffectiveImmutableType(null, types, symTable.arrayAllType, data.env, - symTable, anonymousModelHelper, names); + symTable, anonymousModelHelper); case TypeTags.INTERSECTION -> ((BIntersectionType) type).effectiveType; default -> symTable.semanticError; }; @@ -2160,7 +2157,6 @@ public static class FillMembers implements TypeVisitor { private final SymbolTable symTable; private final Types types; private final ConstantTypeChecker constantTypeChecker; - private final Names names; private final BLangDiagnosticLog dlog; private AnalyzerData data; @@ -2171,7 +2167,6 @@ public FillMembers(CompilerContext context) { this.symTable = SymbolTable.getInstance(context); this.types = Types.getInstance(context); this.constantTypeChecker = ConstantTypeChecker.getInstance(context); - this.names = Names.getInstance(context); this.dlog = BLangDiagnosticLog.getInstance(context); } @@ -2321,7 +2316,7 @@ public void visit(BMapType bMapType) { resultRecordType.tsymbol = recordSymbol; resultRecordType.sealed = true; resultRecordType.restFieldType = symTable.neverType; - TypeDefBuilderHelper.createTypeDefinition(resultRecordType, data.constantSymbol.pos, names, types, + TypeDefBuilderHelper.createTypeDefinition(resultRecordType, data.constantSymbol.pos, types, symTable, data.env); data.resultType = resultRecordType; } @@ -2439,7 +2434,7 @@ public void visit(BRecordType recordType) { resultRecordType.tsymbol = recordSymbol; resultRecordType.sealed = true; resultRecordType.restFieldType = symTable.neverType; - TypeDefBuilderHelper.createTypeDefinition(resultRecordType, data.constantSymbol.pos, names, types, + TypeDefBuilderHelper.createTypeDefinition(resultRecordType, data.constantSymbol.pos, types, symTable, data.env); data.resultType = resultRecordType; } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/ConstantValueResolver.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/ConstantValueResolver.java index 2b4567a63a47..d41dbfb0c508 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/ConstantValueResolver.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/ConstantValueResolver.java @@ -103,7 +103,6 @@ public class ConstantValueResolver extends BLangNodeVisitor { private Location currentPos; private BLangAnonymousModelHelper anonymousModelHelper; private SymbolEnv symEnv; - private Names names; private SymbolTable symTable; private Types types; private PackageID pkgID; @@ -118,7 +117,6 @@ private ConstantValueResolver(CompilerContext context) { context.put(CONSTANT_VALUE_RESOLVER_KEY, this); this.dlog = BLangDiagnosticLog.getInstance(context); this.symTable = SymbolTable.getInstance(context); - this.names = Names.getInstance(context); this.anonymousModelHelper = BLangAnonymousModelHelper.getInstance(context); this.types = Types.getInstance(context); } @@ -794,7 +792,7 @@ private void createTypeDefinition(BRecordType type, Location pos, SymbolEnv env) BLangRecordTypeNode recordTypeNode = TypeDefBuilderHelper.createRecordTypeNode(new ArrayList<>(), type, pos); - TypeDefBuilderHelper.populateStructureFieldsAndTypeInclusions(types, symTable, null, names, + TypeDefBuilderHelper.populateStructureFieldsAndTypeInclusions(types, symTable, null, recordTypeNode, type, type, pos, env, pkgID, null, 0, false); recordTypeNode.sealed = true; type.restFieldType = new BNoType(TypeTags.NONE); @@ -868,7 +866,7 @@ private void updateRecordFields(BRecordType recordType, Location pos, SymbolEnv BTypeSymbol structureSymbol = recordType.tsymbol; for (BField field : recordType.fields.values()) { field.type = ImmutableTypeCloner.getImmutableType(pos, types, field.type, env, - env.enclPkg.packageID, env.scope.owner, symTable, anonymousModelHelper, names, + env.enclPkg.packageID, env.scope.owner, symTable, anonymousModelHelper, new HashSet<>()); Name fieldName = field.symbol.name; field.symbol = new BVarSymbol(field.symbol.flags | Flags.READONLY, fieldName, @@ -1027,7 +1025,7 @@ private BType createTupleType(BLangExpression expr, BConstantSymbol constantSymb env.scope.owner, pos, VIRTUAL); return ImmutableTypeCloner.getImmutableIntersectionType(pos, types, new BTupleType(tupleTypeSymbol, tupleTypes), - env, symTable, anonymousModelHelper, names, + env, symTable, anonymousModelHelper, new HashSet<>()); } } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DataflowAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DataflowAnalyzer.java index 4ff22f030b2f..6a2fad335790 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DataflowAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DataflowAnalyzer.java @@ -259,7 +259,6 @@ public class DataflowAnalyzer extends BLangNodeVisitor { private final SymbolResolver symResolver; - private final Names names; private SymbolEnv env; private SymbolTable symTable; private BLangDiagnosticLog dlog; @@ -285,7 +284,6 @@ private DataflowAnalyzer(CompilerContext context) { this.dlog = BLangDiagnosticLog.getInstance(context); this.types = Types.getInstance(context); this.symResolver = SymbolResolver.getInstance(context); - this.names = Names.getInstance(context); this.currDependentSymbolDeque = new ArrayDeque<>(); this.globalVariableRefAnalyzer = GlobalVariableRefAnalyzer.getInstance(context); this.unusedLocalVariables = new HashMap<>(); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DocumentationAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DocumentationAnalyzer.java index 8be47bd45013..e42aeb63271a 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DocumentationAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/DocumentationAnalyzer.java @@ -84,7 +84,6 @@ public class DocumentationAnalyzer extends SimpleBLangNodeAnalyzer UPDATE_IMMUTABLE_TYPE_KEY = new CompilerContext.Key<>(); private final SymbolTable symTable; - private final Names names; private final Types types; private final BLangAnonymousModelHelper anonymousModelHelper; private Location loc; @@ -100,7 +99,6 @@ public class EffectiveTypePopulator implements TypeVisitor { public EffectiveTypePopulator(CompilerContext context) { context.put(UPDATE_IMMUTABLE_TYPE_KEY, this); this.symTable = SymbolTable.getInstance(context); - this.names = Names.getInstance(context); this.types = Types.getInstance(context); this.anonymousModelHelper = BLangAnonymousModelHelper.getInstance(context); } @@ -144,7 +142,7 @@ public void visit(BArrayType bArrayType) { if (origArrayType != null) { if (bArrayType.eType.tag == TypeTags.NEVER || bArrayType.eType == symTable.semanticError) { bArrayType.eType = ImmutableTypeCloner.getImmutableType(loc, types, origArrayType.eType, env, - pkgID, env.scope.owner, symTable, anonymousModelHelper, names, new HashSet<>()); + pkgID, env.scope.owner, symTable, anonymousModelHelper, new HashSet<>()); } updateType(bArrayType.eType, loc, pkgID, typeNode, env); bArrayType.mutableType = null; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/IsolationAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/IsolationAnalyzer.java index 5575a3bbdcf1..6a76ba7a1069 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/IsolationAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/IsolationAnalyzer.java @@ -290,7 +290,6 @@ public class IsolationAnalyzer extends BLangNodeVisitor { private SymbolEnv env; private final SymbolTable symTable; private final SymbolResolver symResolver; - private final Names names; private final Types types; private final BLangDiagnosticLog dlog; @@ -306,7 +305,6 @@ private IsolationAnalyzer(CompilerContext context) { context.put(ISOLATION_ANALYZER_KEY, this); this.symTable = SymbolTable.getInstance(context); this.symResolver = SymbolResolver.getInstance(context); - this.names = Names.getInstance(context); this.types = Types.getInstance(context); this.dlog = BLangDiagnosticLog.getInstance(context); } @@ -3249,7 +3247,7 @@ private boolean hasRefDefinedOutsideLock(BLangExpression variableReference) { switch (variableReference.getKind()) { case SIMPLE_VARIABLE_REF: BLangSimpleVarRef simpleVarRef = (BLangSimpleVarRef) variableReference; - return isDefinedOutsideLock(names.fromIdNode(simpleVarRef.variableName), simpleVarRef.symbol.tag, + return isDefinedOutsideLock(Names.fromIdNode(simpleVarRef.variableName), simpleVarRef.symbol.tag, env); case RECORD_VARIABLE_REF: BLangRecordVarRef recordVarRef = (BLangRecordVarRef) variableReference; @@ -3362,7 +3360,7 @@ private boolean isFunction(BLangNode enclNode) { } private boolean isInvalidCopyIn(BLangSimpleVarRef varRefExpr, SymbolEnv currentEnv) { - return isInvalidCopyIn(varRefExpr, names.fromIdNode(varRefExpr.variableName), varRefExpr.symbol.tag, + return isInvalidCopyIn(varRefExpr, Names.fromIdNode(varRefExpr.variableName), varRefExpr.symbol.tag, currentEnv); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/QueryTypeChecker.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/QueryTypeChecker.java index dd92270be20c..cf6a9cf1db30 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/QueryTypeChecker.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/QueryTypeChecker.java @@ -116,7 +116,6 @@ public class QueryTypeChecker extends TypeChecker { private final TypeParamAnalyzer typeParamAnalyzer; private final TypeNarrower typeNarrower; private final BLangAnonymousModelHelper anonymousModelHelper; - private final Names names; private final BLangDiagnosticLog dlog; private final NodeCloner nodeCloner; @@ -132,7 +131,6 @@ public QueryTypeChecker(CompilerContext context) { super(context, new CompilerContext.Key<>()); context.put(QUERY_TYPE_CHECKER_KEY, this); - this.names = Names.getInstance(context); this.symTable = SymbolTable.getInstance(context); this.symResolver = SymbolResolver.getInstance(context); this.types = Types.getInstance(context); @@ -969,7 +967,7 @@ public void visit(BLangInvocation iExpr, TypeChecker.AnalyzerData data) { super.visit(iExpr, data); return; } - Name pkgAlias = names.fromIdNode(iExpr.pkgAlias); + Name pkgAlias = Names.fromIdNode(iExpr.pkgAlias); BSymbol pkgSymbol = symResolver.resolvePrefixSymbol(data.env, pkgAlias, getCurrentCompUnit(iExpr)); if (pkgSymbol == symTable.notFoundSymbol) { dlog.error(iExpr.pos, DiagnosticErrorCode.UNDEFINED_MODULE, pkgAlias); @@ -983,7 +981,7 @@ public void visit(BLangInvocation iExpr, TypeChecker.AnalyzerData data) { invocationType = firstArgType.tag == TypeTags.SEQUENCE ? ((BSequenceType) firstArgType).elementType : firstArgType; } - Name funcName = names.fromIdNode(iExpr.name); + Name funcName = Names.fromIdNode(iExpr.name); BSymbol symbol = symResolver.lookupLangLibMethod(invocationType, funcName, data.env); if (symbol == symTable.notFoundSymbol) { symbol = symResolver.lookupMainSpaceSymbolInPackage(iExpr.pos, data.env, pkgAlias, funcName); @@ -1091,13 +1089,13 @@ public void visit(BLangSimpleVarRef varRefExpr, TypeChecker.AnalyzerData data) { BType actualType = symTable.semanticError; BLangIdentifier identifier = varRefExpr.variableName; - Name varName = names.fromIdNode(identifier); + Name varName = Names.fromIdNode(identifier); if (varName == Names.IGNORE) { varRefExpr.setBType(this.symTable.anyType); // If the variable name is a wildcard('_'), the symbol should be ignorable. varRefExpr.symbol = new BVarSymbol(0, true, varName, - names.originalNameFromIdNode(identifier), + Names.originalNameFromIdNode(identifier), data.env.enclPkg.symbol.pkgID, varRefExpr.getBType(), data.env.scope.owner, varRefExpr.pos, VIRTUAL); @@ -1106,7 +1104,7 @@ public void visit(BLangSimpleVarRef varRefExpr, TypeChecker.AnalyzerData data) { } Name compUnitName = getCurrentCompUnit(varRefExpr); - BSymbol pkgSymbol = symResolver.resolvePrefixSymbol(data.env, names.fromIdNode(varRefExpr.pkgAlias), + BSymbol pkgSymbol = symResolver.resolvePrefixSymbol(data.env, Names.fromIdNode(varRefExpr.pkgAlias), compUnitName); varRefExpr.pkgSymbol = pkgSymbol; if (pkgSymbol == symTable.notFoundSymbol) { @@ -1118,7 +1116,7 @@ public void visit(BLangSimpleVarRef varRefExpr, TypeChecker.AnalyzerData data) { actualType = symTable.stringType; } else if (pkgSymbol != symTable.notFoundSymbol) { BSymbol symbol = symResolver.lookupMainSpaceSymbolInPackage(varRefExpr.pos, data.env, - names.fromIdNode(varRefExpr.pkgAlias), varName); + Names.fromIdNode(varRefExpr.pkgAlias), varName); // if no symbol, check same for object attached function BLangType enclType = data.env.enclType; if (symbol == symTable.notFoundSymbol && enclType != null && enclType.getBType().tsymbol.scope != null) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/ReachabilityAnalyzer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/ReachabilityAnalyzer.java index a169ec2ad9ff..c2e25a84a2d6 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/ReachabilityAnalyzer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/ReachabilityAnalyzer.java @@ -124,14 +124,12 @@ public class ReachabilityAnalyzer extends SimpleBLangNodeAnalyzer()); + lhsType, currentEnv, symTable, anonModelHelper, new HashSet<>()); varNode.setBType(lhsType); varNode.symbol.type = lhsType; } @@ -2131,8 +2129,8 @@ void handleDeclaredVarInForeach(BLangVariable variable, BType rhsType, SymbolEnv private void recursivelyDefineVariables(BLangVariable variable, SymbolEnv blockEnv) { switch (variable.getKind()) { case VARIABLE: - Name name = names.fromIdNode(((BLangSimpleVariable) variable).name); - Name origName = names.originalNameFromIdNode(((BLangSimpleVariable) variable).name); + Name name = Names.fromIdNode(((BLangSimpleVariable) variable).name); + Name origName = Names.originalNameFromIdNode(((BLangSimpleVariable) variable).name); variable.setBType(symTable.semanticError); symbolEnter.defineVarSymbol(variable.pos, variable.flagSet, variable.getBType(), name, origName, blockEnv, variable.internal); @@ -2397,7 +2395,7 @@ public void visit(BLangRecordDestructure recordDeStmt, AnalyzerData data) { public void visit(BLangErrorDestructure errorDeStmt, AnalyzerData data) { BLangErrorVarRef varRef = errorDeStmt.varRef; if (varRef.message != null) { - if (names.fromIdNode(((BLangSimpleVarRef) varRef.message).variableName) != Names.IGNORE) { + if (Names.fromIdNode(((BLangSimpleVarRef) varRef.message).variableName) != Names.IGNORE) { setTypeOfVarRefInErrorBindingAssignment(varRef.message, data); checkInvalidTypeDef(varRef.message); } else { @@ -2408,7 +2406,7 @@ public void visit(BLangErrorDestructure errorDeStmt, AnalyzerData data) { if (varRef.cause != null) { if (varRef.cause.getKind() != NodeKind.SIMPLE_VARIABLE_REF || - names.fromIdNode(((BLangSimpleVarRef) varRef.cause).variableName) != Names.IGNORE) { + Names.fromIdNode(((BLangSimpleVarRef) varRef.cause).variableName) != Names.IGNORE) { setTypeOfVarRefInErrorBindingAssignment(varRef.cause, data); checkInvalidTypeDef(varRef.cause); } else { @@ -2484,7 +2482,7 @@ private void checkRecordVarRefEquivalency(Location pos, BLangRecordVarRef lhsVar } else if (variableReference.getKind() == NodeKind.ERROR_VARIABLE_REF) { checkErrorVarRefEquivalency((BLangErrorVarRef) variableReference, rhsField.type, rhsPos, data); } else if (variableReference.getKind() == NodeKind.SIMPLE_VARIABLE_REF) { - Name varName = names.fromIdNode(((BLangSimpleVarRef) variableReference).variableName); + Name varName = Names.fromIdNode(((BLangSimpleVarRef) variableReference).variableName); if (varName == Names.IGNORE) { continue; } @@ -2546,7 +2544,7 @@ private void checkArrayVarRefEquivalency(Location pos, BLangTupleVarRef target, checkErrorVarRefEquivalency(errorVarRef, souceElementType, rhsPos, data); } else if (expression.getKind() == NodeKind.SIMPLE_VARIABLE_REF) { BLangSimpleVarRef simpleVarRef = (BLangSimpleVarRef) expression; - Name varName = names.fromIdNode(simpleVarRef.variableName); + Name varName = Names.fromIdNode(simpleVarRef.variableName); if (varName == Names.IGNORE) { continue; } @@ -2614,7 +2612,7 @@ private void checkTupleVarRefEquivalency(Location pos, BLangTupleVarRef target, checkErrorVarRefEquivalency(errorVarRef, sourceType, rhsPos, data); } else if (varRefExpr.getKind() == NodeKind.SIMPLE_VARIABLE_REF) { BLangSimpleVarRef simpleVarRef = (BLangSimpleVarRef) varRefExpr; - Name varName = names.fromIdNode(simpleVarRef.variableName); + Name varName = Names.fromIdNode(simpleVarRef.variableName); if (varName == Names.IGNORE) { continue; } @@ -2769,7 +2767,7 @@ private void checkConstantAssignment(BLangExpression varRef, AnalyzerData data) return; } - Name varName = names.fromIdNode(simpleVarRef.variableName); + Name varName = Names.fromIdNode(simpleVarRef.variableName); if (!Names.IGNORE.equals(varName) && currentEnv.enclInvokable != currentEnv.enclPkg.initFunction) { if ((simpleVarRef.symbol.flags & Flags.FINAL) == Flags.FINAL) { if ((simpleVarRef.symbol.flags & Flags.SERVICE) == Flags.SERVICE) { @@ -3049,9 +3047,9 @@ public void visit(BLangMappingMatchPattern mappingMatchPattern, AnalyzerData dat for (BLangFieldMatchPattern fieldMatchPattern : mappingMatchPattern.fieldMatchPatterns) { analyzeNode(fieldMatchPattern, data); - Name fieldName = names.fromIdNode(fieldMatchPattern.fieldName); + Name fieldName = Names.fromIdNode(fieldMatchPattern.fieldName); BVarSymbol fieldSymbol = new BVarSymbol(0, fieldName, - names.originalNameFromIdNode(fieldMatchPattern.fieldName), + Names.originalNameFromIdNode(fieldMatchPattern.fieldName), currentEnv.enclPkg.symbol.pkgID, fieldMatchPattern.matchPattern.getBType(), recordSymbol, fieldMatchPattern.pos, COMPILED_SOURCE); @@ -3341,7 +3339,7 @@ public void visit(BLangListBindingPattern listBindingPattern, AnalyzerData data) public void visit(BLangRestBindingPattern restBindingPattern, AnalyzerData data) { SymbolEnv currentEnv = data.env; Name name = new Name(restBindingPattern.variableName.value); - Name origName = names.originalNameFromIdNode(restBindingPattern.variableName); + Name origName = Names.originalNameFromIdNode(restBindingPattern.variableName); BSymbol symbol = symResolver.lookupSymbolInMainSpace(currentEnv, name); if (symbol == symTable.notFoundSymbol) { symbol = new BVarSymbol(0, name, origName, currentEnv.enclPkg.packageID, restBindingPattern.getBType(), @@ -3585,9 +3583,9 @@ public void visit(BLangMappingBindingPattern mappingBindingPattern, AnalyzerData for (BLangFieldBindingPattern fieldBindingPattern : mappingBindingPattern.fieldBindingPatterns) { fieldBindingPattern.accept(this, data); - Name fieldName = names.fromIdNode(fieldBindingPattern.fieldName); + Name fieldName = Names.fromIdNode(fieldBindingPattern.fieldName); BVarSymbol fieldSymbol = new BVarSymbol(0, fieldName, - names.originalNameFromIdNode(fieldBindingPattern.fieldName), + Names.originalNameFromIdNode(fieldBindingPattern.fieldName), currentEnv.enclPkg.symbol.pkgID, fieldBindingPattern.bindingPattern.getBType(), recordSymbol, fieldBindingPattern.pos, COMPILED_SOURCE); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolEnter.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolEnter.java index 943baf159e6b..ce885f5d1ae2 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolEnter.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolEnter.java @@ -223,7 +223,6 @@ public class SymbolEnter extends BLangNodeVisitor { private static final CompilerContext.Key SYMBOL_ENTER_KEY = new CompilerContext.Key<>(); private final SymbolTable symTable; - private final Names names; private final SymbolResolver symResolver; private final BLangDiagnosticLog dlog; private final Types types; @@ -262,7 +261,6 @@ public SymbolEnter(CompilerContext context) { context.put(SYMBOL_ENTER_KEY, this); this.symTable = SymbolTable.getInstance(context); - this.names = Names.getInstance(context); this.symResolver = SymbolResolver.getInstance(context); this.dlog = BLangDiagnosticLog.getInstance(context); this.types = Types.getInstance(context); @@ -389,12 +387,12 @@ private void defineConstructs(BLangPackage pkgNode, SymbolEnv pkgEnv) { for (BLangImportPackage unresolvedPkg : importHolder.unresolved) { BPackageSymbol importSymbol = importHolder.resolved.symbol; - Name resolvedPkgAlias = names.fromIdNode(importHolder.resolved.alias); - Name unresolvedPkgAlias = names.fromIdNode(unresolvedPkg.alias); + Name resolvedPkgAlias = Names.fromIdNode(importHolder.resolved.alias); + Name unresolvedPkgAlias = Names.fromIdNode(unresolvedPkg.alias); // check if its the same import or has the same alias. if (!Names.IGNORE.equals(unresolvedPkgAlias) && unresolvedPkgAlias.equals(resolvedPkgAlias) - && importSymbol.compUnit.equals(names.fromIdNode(unresolvedPkg.compUnit))) { + && importSymbol.compUnit.equals(Names.fromIdNode(unresolvedPkg.compUnit))) { if (isSameImport(unresolvedPkg, importSymbol)) { dlog.error(unresolvedPkg.pos, DiagnosticErrorCode.REDECLARED_IMPORT_MODULE, unresolvedPkg.getQualifiedPackageName()); @@ -407,7 +405,7 @@ private void defineConstructs(BLangPackage pkgNode, SymbolEnv pkgEnv) { unresolvedPkg.symbol = pkgSymbol; // and define it in the current package scope BPackageSymbol symbol = dupPackageSymbolAndSetCompUnit(pkgSymbol, - names.fromIdNode(unresolvedPkg.compUnit)); + Names.fromIdNode(unresolvedPkg.compUnit)); symbol.scope = pkgSymbol.scope; unresolvedPkg.symbol = symbol; pkgEnv.scope.define(unresolvedPkgAlias, symbol); @@ -837,7 +835,7 @@ private void defineReferencedClassFields(BLangClassDefinition classDefinition, S if (field.symbol.type == symTable.semanticError) { continue; } - objType.fields.put(field.name.value, new BField(names.fromIdNode(field.name), field.pos, field.symbol)); + objType.fields.put(field.name.value, new BField(Names.fromIdNode(field.name), field.pos, field.symbol)); } classDefinition.referencedFields.addAll(referencedFields); @@ -863,8 +861,8 @@ public void visit(BLangObjectConstructorExpression objectCtorExpression) { public void visit(BLangClassDefinition classDefinition) { EnumSet flags = EnumSet.copyOf(classDefinition.flagSet); boolean isPublicType = flags.contains(Flag.PUBLIC); - Name className = names.fromIdNode(classDefinition.name); - Name classOrigName = names.originalNameFromIdNode(classDefinition.name); + Name className = Names.fromIdNode(classDefinition.name); + Name classOrigName = Names.originalNameFromIdNode(classDefinition.name); BClassSymbol tSymbol = Symbols.createClassSymbol(Flags.asMask(flags), className, env.enclPkg.symbol.pkgID, null, @@ -937,8 +935,8 @@ public void visit(BLangClassDefinition classDefinition) { @Override public void visit(BLangAnnotation annotationNode) { - Name annotName = names.fromIdNode(annotationNode.name); - Name annotOrigName = names.originalNameFromIdNode(annotationNode.name); + Name annotName = Names.fromIdNode(annotationNode.name); + Name annotOrigName = Names.originalNameFromIdNode(annotationNode.name); BAnnotationSymbol annotationSymbol = Symbols.createAnnotationSymbol(Flags.asMask(annotationNode.flagSet), annotationNode.getAttachPoints(), annotName, annotOrigName, @@ -979,10 +977,10 @@ private boolean isNullOrEmpty(String s) { @Override public void visit(BLangImportPackage importPkgNode) { - Name pkgAlias = names.fromIdNode(importPkgNode.alias); + Name pkgAlias = Names.fromIdNode(importPkgNode.alias); if (!Names.IGNORE.equals(pkgAlias)) { BSymbol importSymbol = - symResolver.resolvePrefixSymbol(env, pkgAlias, names.fromIdNode(importPkgNode.compUnit)); + symResolver.resolvePrefixSymbol(env, pkgAlias, Names.fromIdNode(importPkgNode.compUnit)); if (importSymbol != symTable.notFoundSymbol) { if (isSameImport(importPkgNode, (BPackageSymbol) importSymbol)) { dlog.error(importPkgNode.pos, DiagnosticErrorCode.REDECLARED_IMPORT_MODULE, @@ -1008,9 +1006,9 @@ public void visit(BLangImportPackage importPkgNode) { // 2b. different project // 3. import module-name if (!isNullOrEmpty(importPkgNode.orgName.value)) { - orgName = names.fromIdNode(importPkgNode.orgName); + orgName = Names.fromIdNode(importPkgNode.orgName); if (!isNullOrEmpty(importPkgNode.version.value)) { - version = names.fromIdNode(importPkgNode.version); + version = Names.fromIdNode(importPkgNode.version); } else { // TODO We are removing the version in the import declaration anyway if (projectAPIInitiatedCompilation) { @@ -1034,7 +1032,7 @@ public void visit(BLangImportPackage importPkgNode) { } List nameComps = importPkgNode.pkgNameComps.stream() - .map(identifier -> names.fromIdNode(identifier)) + .map(identifier -> Names.fromIdNode(identifier)) .toList(); Name moduleName = new Name(nameComps.stream().map(Name::getValue).collect(Collectors.joining("."))); @@ -1124,7 +1122,7 @@ public void visit(BLangImportPackage importPkgNode) { // get a copy of the package symbol, add compilation unit info to it, // and define it in the current package scope - BPackageSymbol symbol = dupPackageSymbolAndSetCompUnit(pkgSymbol, names.fromIdNode(importPkgNode.compUnit)); + BPackageSymbol symbol = dupPackageSymbolAndSetCompUnit(pkgSymbol, Names.fromIdNode(importPkgNode.compUnit)); if (!Names.IGNORE.equals(pkgAlias)) { symbol.importPrefix = pkgAlias; } @@ -1193,12 +1191,12 @@ public void defineXMLNS(SymbolEnv symEnv, BLangXMLNS xmlnsNode) { xmlnsNode.prefix.value = XMLConstants.DEFAULT_NS_PREFIX; } - Name prefix = names.fromIdNode(xmlnsNode.prefix); + Name prefix = Names.fromIdNode(xmlnsNode.prefix); Location nsSymbolPos = prefix.value.isEmpty() ? xmlnsNode.pos : xmlnsNode.prefix.pos; BLangIdentifier compUnit = xmlnsNode.compUnit; BXMLNSSymbol xmlnsSymbol = Symbols.createXMLNSSymbol(prefix, nsURI, symEnv.enclPkg.symbol.pkgID, symEnv.scope.owner, nsSymbolPos, - getOrigin(prefix), compUnit != null ? names.fromIdNode(compUnit) : null); + getOrigin(prefix), compUnit != null ? Names.fromIdNode(compUnit) : null); xmlnsNode.symbol = xmlnsSymbol; // First check for package-imports with the same alias. @@ -1650,7 +1648,7 @@ public void visit(BLangTypeDefinition typeDefinition) { typeDefinition.setPrecedence(this.typePrecedence++); BSymbol typeDefSymbol = Symbols.createTypeDefinitionSymbol(Flags.asMask(typeDefinition.flagSet), - names.fromIdNode(typeDefinition.name), env.enclPkg.packageID, definedType, env.scope.owner, + Names.fromIdNode(typeDefinition.name), env.enclPkg.packageID, definedType, env.scope.owner, typeDefinition.name.pos, getOrigin(typeDefinition.name.value)); typeDefSymbol.markdownDocumentation = getMarkdownDocAttachment(typeDefinition.markdownDocumentationAttachment); BTypeSymbol typeSymbol = new BTypeSymbol(SymTag.TYPE_REF, typeDefSymbol.flags, typeDefSymbol.name, @@ -1663,8 +1661,8 @@ public void visit(BLangTypeDefinition typeDefinition) { //todo remove after type ref introduced to runtime if (definedType.tsymbol.name == Names.EMPTY) { isLabel = false; - definedType.tsymbol.name = names.fromIdNode(typeDefinition.name); - definedType.tsymbol.originalName = names.originalNameFromIdNode(typeDefinition.name); + definedType.tsymbol.name = Names.fromIdNode(typeDefinition.name); + definedType.tsymbol.originalName = Names.originalNameFromIdNode(typeDefinition.name); definedType.tsymbol.flags |= typeDefSymbol.flags; definedType.tsymbol.markdownDocumentation = typeDefSymbol.markdownDocumentation; @@ -1840,12 +1838,12 @@ private BEnumSymbol createEnumSymbol(BLangTypeDefinition typeDefinition, BType d } BEnumSymbol enumSymbol = new BEnumSymbol(enumMembers, Flags.asMask(typeDefinition.flagSet), - names.fromIdNode(typeDefinition.name), names.fromIdNode(typeDefinition.name), + Names.fromIdNode(typeDefinition.name), Names.fromIdNode(typeDefinition.name), env.enclPkg.symbol.pkgID, definedType, env.scope.owner, typeDefinition.pos, SOURCE); - enumSymbol.name = names.fromIdNode(typeDefinition.name); - enumSymbol.originalName = names.fromIdNode(typeDefinition.name); + enumSymbol.name = Names.fromIdNode(typeDefinition.name); + enumSymbol.originalName = Names.fromIdNode(typeDefinition.name); enumSymbol.flags |= Flags.asMask(typeDefinition.flagSet); enumSymbol.markdownDocumentation = getMarkdownDocAttachment(typeDefinition.markdownDocumentationAttachment); @@ -1880,7 +1878,7 @@ private void defineTypeInMainScope(BTypeSymbol typeDefSymbol, BLangTypeDefinitio } private BType defineSymbolForCyclicTypeDefinition(BLangTypeDefinition typeDef, SymbolEnv env) { - Name newTypeDefName = names.fromIdNode(typeDef.name); + Name newTypeDefName = Names.fromIdNode(typeDef.name); BTypeSymbol typeDefSymbol; BType newTypeNode; @@ -1907,7 +1905,7 @@ private BType defineSymbolForCyclicTypeDefinition(BLangTypeDefinition typeDef, S private BType getCyclicDefinedType(BLangTypeDefinition typeDef, SymbolEnv env) { // Get cyclic type reference from main scope - BSymbol foundSym = symResolver.lookupSymbolInMainSpace(env, names.fromIdNode(typeDef.name)); + BSymbol foundSym = symResolver.lookupSymbolInMainSpace(env, Names.fromIdNode(typeDef.name)); BType newTypeNode = foundSym.type; // Resolver only manages to resolve members as they are defined as user defined types. @@ -2305,9 +2303,9 @@ public void visit(BLangConstant constant) { public BConstantSymbol getConstantSymbol(BLangConstant constant) { // Create a new constant symbol. - Name name = names.fromIdNode(constant.name); + Name name = Names.fromIdNode(constant.name); PackageID pkgID = env.enclPkg.symbol.pkgID; - return new BConstantSymbol(Flags.asMask(constant.flagSet), name, names.originalNameFromIdNode(constant.name), + return new BConstantSymbol(Flags.asMask(constant.flagSet), name, Names.originalNameFromIdNode(constant.name), pkgID, symTable.semanticError, symTable.noType, env.scope.owner, constant.name.pos, getOrigin(name)); } @@ -2327,8 +2325,8 @@ public void visit(BLangSimpleVariable varNode) { } } - Name varName = names.fromIdNode(varNode.name); - Name varOrigName = names.originalNameFromIdNode(varNode.name); + Name varName = Names.fromIdNode(varNode.name); + Name varOrigName = Names.originalNameFromIdNode(varNode.name); if (varName == Names.IGNORE || varNode.symbol != null) { return; } @@ -2566,7 +2564,7 @@ boolean checkTypeAndVarCountConsistency(BLangTupleVariable varNode, BTupleType t if (var.getKind() == NodeKind.VARIABLE) { // '_' is allowed in tuple variables. Not allowed if all variables are named as '_' BLangSimpleVariable simpleVar = (BLangSimpleVariable) var; - Name varName = names.fromIdNode(simpleVar.name); + Name varName = Names.fromIdNode(simpleVar.name); if (varName == Names.IGNORE) { ignoredCount++; simpleVar.setBType(symTable.anyType); @@ -2910,9 +2908,9 @@ private BRecordType createSameTypedFieldsRecordType(BLangRecordVariable recordVa //TODO check below field position LinkedHashMap fields = new LinkedHashMap<>(); for (BLangRecordVariable.BLangRecordVariableKeyValue bLangRecordVariableKeyValue : recordVar.variableList) { - Name fieldName = names.fromIdNode(bLangRecordVariableKeyValue.key); + Name fieldName = Names.fromIdNode(bLangRecordVariableKeyValue.key); BField bField = new BField(fieldName, recordVar.pos, - new BVarSymbol(0, fieldName, names.originalNameFromIdNode(bLangRecordVariableKeyValue.key), + new BVarSymbol(0, fieldName, Names.originalNameFromIdNode(bLangRecordVariableKeyValue.key), env.enclPkg.symbol.pkgID, fieldType, recordSymbol, recordVar.pos, SOURCE)); fields.put(fieldName.getValue(), bField); } @@ -2942,7 +2940,7 @@ private boolean defineVariableList(BLangRecordVariable recordVar, BRecordType re if (value.getKind() == NodeKind.VARIABLE) { // '_' is allowed in record variables. Not allowed if all variables are named as '_' BLangSimpleVariable simpleVar = (BLangSimpleVariable) value; - Name varName = names.fromIdNode(simpleVar.name); + Name varName = Names.fromIdNode(simpleVar.name); if (varName == Names.IGNORE) { ignoredCount++; simpleVar.setBType(symTable.anyType); @@ -3311,7 +3309,7 @@ boolean validateErrorVariable(BLangErrorVariable errorVariable, SymbolEnv env) { BLangVariable errorCause = errorVariable.cause; if (errorCause != null) { if (errorCause.getKind() == NodeKind.VARIABLE && - names.fromIdNode(((BLangSimpleVariable) errorCause).name) == Names.IGNORE) { + Names.fromIdNode(((BLangSimpleVariable) errorCause).name) == Names.IGNORE) { dlog.error(errorCause.pos, DiagnosticErrorCode.CANNOT_USE_WILDCARD_BINDING_PATTERN_FOR_ERROR_CAUSE); return false; @@ -3874,7 +3872,7 @@ public void defineFieldsOfClassDef(BLangClassDefinition classDefinition, SymbolE if (field.symbol.type == symTable.semanticError) { continue; } - objType.fields.put(field.name.value, new BField(names.fromIdNode(field.name), field.pos, field.symbol)); + objType.fields.put(field.name.value, new BField(Names.fromIdNode(field.name), field.pos, field.symbol)); } } @@ -3914,7 +3912,7 @@ private void resolveFields(BStructureType structureType, BLangStructureTypeNode .filter(field -> field.symbol.type != symTable.semanticError) // filter out erroneous fields .map((BLangSimpleVariable field) -> { field.symbol.isDefaultable = field.expr != null; - return new BField(names.fromIdNode(field.name), field.pos, field.symbol); + return new BField(Names.fromIdNode(field.name), field.pos, field.symbol); }) .collect(getFieldCollector()); } @@ -4019,7 +4017,7 @@ private void defineReferencedFields(BStructureType structureType, BLangStructure if (field.symbol.type == symTable.semanticError) { continue; } - structureType.fields.put(field.name.value, new BField(names.fromIdNode(field.name), field.pos, + structureType.fields.put(field.name.value, new BField(Names.fromIdNode(field.name), field.pos, field.symbol)); } } @@ -4231,7 +4229,7 @@ private void populateImmutableTypeFieldsAndMembers(List typ SymbolEnv typeDefEnv = SymbolEnv.createTypeEnv(typeDef.typeNode, typeDef.symbol.scope, pkgEnv); ImmutableTypeCloner.defineUndefinedImmutableFields(typeDef, types, typeDefEnv, symTable, - anonymousModelHelper, names); + anonymousModelHelper); if (nodeKind != NodeKind.OBJECT_TYPE) { continue; @@ -4241,7 +4239,7 @@ private void populateImmutableTypeFieldsAndMembers(List typ BObjectType mutableObjectType = immutableObjectType.mutableType; ImmutableTypeCloner.defineObjectFunctions((BObjectTypeSymbol) immutableObjectType.tsymbol, - (BObjectTypeSymbol) mutableObjectType.tsymbol, names, symTable); + (BObjectTypeSymbol) mutableObjectType.tsymbol, symTable); } } @@ -4305,7 +4303,7 @@ private void validateFieldsAndSetReadOnlyType(List typeDefNodes, Symb if (!types.isInherentlyImmutableType(type)) { field.type = field.symbol.type = ImmutableTypeCloner.getImmutableIntersectionType( pos, types, type, typeDefEnv, symTable, - anonymousModelHelper, names, flagSet); + anonymousModelHelper, flagSet); } @@ -4377,7 +4375,7 @@ private void setReadOnlynessOfClassDef(BLangClassDefinition classDef, SymbolEnv } ImmutableTypeCloner.markFieldsAsImmutable(classDef, pkgEnv, objectType, types, anonymousModelHelper, - symTable, names, pos); + symTable, pos); } else if (classDef.isObjectContructorDecl) { Collection fields = objectType.fields.values(); if (fields.isEmpty()) { @@ -4838,7 +4836,7 @@ private void validateFunctionsAttachedToObject(BLangFunction funcNode, BInvokabl if (funcNode.getKind() == NodeKind.RESOURCE_FUNC) { attachedFunc = createResourceFunction(funcNode, funcSymbol, funcType); } else { - attachedFunc = new BAttachedFunction(names.fromIdNode(funcNode.name), funcSymbol, funcType, funcNode.pos); + attachedFunc = new BAttachedFunction(Names.fromIdNode(funcNode.name), funcSymbol, funcType, funcNode.pos); } validateRemoteFunctionAttachedToObject(funcNode, objectSymbol); @@ -4858,7 +4856,7 @@ private BAttachedFunction createResourceFunction(BLangFunction funcNode, BInvoka BInvokableType funcType) { BObjectTypeSymbol objectTypeSymbol = (BObjectTypeSymbol) funcNode.receiver.getBType().tsymbol; BLangResourceFunction resourceFunction = (BLangResourceFunction) funcNode; - Name accessor = names.fromIdNode(resourceFunction.methodName); + Name accessor = Names.fromIdNode(resourceFunction.methodName); List pathParamSymbols = resourceFunction.pathParams.stream() .map(p -> { @@ -4873,7 +4871,7 @@ private BAttachedFunction createResourceFunction(BLangFunction funcNode, BInvoka restPathParamSym.kind = SymbolKind.PATH_REST_PARAMETER; } - BResourceFunction bResourceFunction = new BResourceFunction(names.fromIdNode(funcNode.name), funcSymbol, + BResourceFunction bResourceFunction = new BResourceFunction(Names.fromIdNode(funcNode.name), funcSymbol, funcType, accessor, pathParamSymbols, restPathParamSym, funcNode.pos); List pathSegments = resourceFunction.resourcePathSegments; @@ -4992,11 +4990,11 @@ private Name getFuncSymbolName(BLangFunction funcNode) { return Names.fromString(Symbols.getAttachedFuncSymbolName( funcNode.receiver.getBType().tsymbol.name.value, funcNode.name.value)); } - return names.fromIdNode(funcNode.name); + return Names.fromIdNode(funcNode.name); } private Name getFuncSymbolOriginalName(BLangFunction funcNode) { - return names.originalNameFromIdNode(funcNode.name); + return Names.originalNameFromIdNode(funcNode.name); } private Name getFieldSymbolName(BLangSimpleVariable receiver, BLangSimpleVariable variable) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolResolver.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolResolver.java index e0d23ea3de8c..2fb34346df94 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolResolver.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/SymbolResolver.java @@ -154,7 +154,6 @@ public class SymbolResolver extends BLangNodeTransformer(); private final SymbolTable symTable; - private final Names names; private final BLangDiagnosticLog dlog; private final Types types; @@ -179,7 +178,6 @@ public SymbolResolver(CompilerContext context) { context.put(SYMBOL_RESOLVER_KEY, this); this.symTable = SymbolTable.getInstance(context); - this.names = Names.getInstance(context); this.dlog = BLangDiagnosticLog.getInstance(context); this.types = Types.getInstance(context); this.symbolEnter = SymbolEnter.getInstance(context); @@ -1200,8 +1198,8 @@ public BType transform(BLangArrayType arrayTypeNode, AnalyzerData data) { } BLangSimpleVarRef sizeReference = (BLangSimpleVarRef) size; - Name pkgAlias = names.fromIdNode(sizeReference.pkgAlias); - Name typeName = names.fromIdNode(sizeReference.variableName); + Name pkgAlias = Names.fromIdNode(sizeReference.pkgAlias); + Name typeName = Names.fromIdNode(sizeReference.variableName); BSymbol sizeSymbol = lookupMainSpaceSymbolInPackage(size.pos, data.env, pkgAlias, typeName); sizeReference.symbol = sizeSymbol; @@ -1601,9 +1599,9 @@ public BType transform(BLangUserDefinedType userDefinedTypeNode, AnalyzerData da // 3) If the symbol is not found, then lookup in the root scope. e.g. for types such as 'error' BLangIdentifier pkgAliasIdentifier = userDefinedTypeNode.pkgAlias; - Name pkgAlias = names.fromIdNode(pkgAliasIdentifier); + Name pkgAlias = Names.fromIdNode(pkgAliasIdentifier); BLangIdentifier typeNameIdentifier = userDefinedTypeNode.typeName; - Name typeName = names.fromIdNode(typeNameIdentifier); + Name typeName = Names.fromIdNode(typeNameIdentifier); BSymbol symbol = symTable.notFoundSymbol; SymbolEnv env = data.env; @@ -1769,7 +1767,7 @@ public ParameterizedTypeInfo getTypedescParamValueType(List } if (defaultValueExprKind == NodeKind.SIMPLE_VARIABLE_REF) { - Name varName = names.fromIdNode(((BLangSimpleVarRef) param.expr).variableName); + Name varName = Names.fromIdNode(((BLangSimpleVarRef) param.expr).variableName); BSymbol typeRefSym = lookupSymbolInMainSpace(data.env, varName); if (typeRefSym != symTable.notFoundSymbol) { return new ParameterizedTypeInfo(typeRefSym.type, i); @@ -2203,7 +2201,7 @@ private BSymbol resolveOperator(ScopeEntry entry, List typeList) { } public BType visitBuiltInTypeNode(BLangType typeNode, AnalyzerData data, TypeKind typeKind) { - Name typeName = names.fromTypeKind(typeKind); + Name typeName = Names.fromTypeKind(typeKind); BSymbol typeSymbol = lookupMemberSymbol(typeNode.pos, symTable.rootScope, data.env, typeName, SymTag.TYPE); if (typeSymbol == symTable.notFoundSymbol) { dlog.error(typeNode.pos, data.diagCode, typeName); @@ -2395,7 +2393,7 @@ private BType computeIntersectionType(BLangIntersectionTypeNode intersectionType } return ImmutableTypeCloner.getImmutableIntersectionType(intersectionTypeNode.pos, types, potentialIntersectionType, - data.env, symTable, anonymousModelHelper, names, flagSet); + data.env, symTable, anonymousModelHelper, flagSet); } public BIntersectionType createIntersectionErrorType(BErrorType intersectionErrorType, diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java index 709cc373a601..48a6659629eb 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeChecker.java @@ -239,7 +239,6 @@ public class TypeChecker extends SimpleBLangNodeAnalyzer key) { context.put(key, this); - this.names = Names.getInstance(context); this.symTable = SymbolTable.getInstance(context); this.symbolEnter = SymbolEnter.getInstance(context); this.symResolver = SymbolResolver.getInstance(context); @@ -916,7 +913,7 @@ public BType setLiteralValueAndGetType(BLangLiteral literalExpr, BType expType, BArrayState.CLOSED); if (Symbols.isFlagOn(expectedType.flags, Flags.READONLY)) { literalType = ImmutableTypeCloner.getEffectiveImmutableType(literalExpr.pos, types, - literalType, data.env, symTable, anonymousModelHelper, names); + literalType, data.env, symTable, anonymousModelHelper); } if (expectedType.tag == TypeTags.ARRAY) { @@ -1957,13 +1954,13 @@ private BType getListConstructorCompatibleNonUnionType(BType type, AnalyzerData TypeTags.TYPEDESC -> type; case TypeTags.JSON -> !Symbols.isFlagOn(referredType.flags, Flags.READONLY) ? symTable.arrayJsonType : ImmutableTypeCloner.getEffectiveImmutableType(null, types, symTable.arrayJsonType, - data.env, symTable, anonymousModelHelper, names); + data.env, symTable, anonymousModelHelper); case TypeTags.ANYDATA -> !Symbols.isFlagOn(referredType.flags, Flags.READONLY) ? symTable.arrayAnydataType : ImmutableTypeCloner.getEffectiveImmutableType(null, types, symTable.arrayAnydataType, - data.env, symTable, anonymousModelHelper, names); + data.env, symTable, anonymousModelHelper); case TypeTags.ANY -> !Symbols.isFlagOn(referredType.flags, Flags.READONLY) ? symTable.arrayAllType : ImmutableTypeCloner.getEffectiveImmutableType(null, types, symTable.arrayAllType, data.env, - symTable, anonymousModelHelper, names); + symTable, anonymousModelHelper); default -> symTable.semanticError; }; } @@ -2644,15 +2641,15 @@ private BType getMappingConstructorCompatibleNonUnionType(BType type, AnalyzerDa case TypeTags.JSON: return !Symbols.isFlagOn(type.flags, Flags.READONLY) ? symTable.mapJsonType : ImmutableTypeCloner.getEffectiveImmutableType(null, types, symTable.mapJsonType, data.env, - symTable, anonymousModelHelper, names); + symTable, anonymousModelHelper); case TypeTags.ANYDATA: return !Symbols.isFlagOn(type.flags, Flags.READONLY) ? symTable.mapAnydataType : ImmutableTypeCloner.getEffectiveImmutableType(null, types, symTable.mapAnydataType, - data.env, symTable, anonymousModelHelper, names); + data.env, symTable, anonymousModelHelper); case TypeTags.ANY: return !Symbols.isFlagOn(type.flags, Flags.READONLY) ? symTable.mapAllType : ImmutableTypeCloner.getEffectiveImmutableType(null, types, symTable.mapAllType, data.env, - symTable, anonymousModelHelper, names); + symTable, anonymousModelHelper); case TypeTags.INTERSECTION: return ((BIntersectionType) type).effectiveType; case TypeTags.TYPEREFDESC: @@ -2888,7 +2885,7 @@ public void visit(BLangWorkerFlushExpr workerFlushExpr, AnalyzerData data) { @Override public void visit(BLangWorkerSyncSendExpr syncSendExpr, AnalyzerData data) { - BSymbol symbol = symResolver.lookupSymbolInMainSpace(data.env, names.fromIdNode(syncSendExpr.workerIdentifier)); + BSymbol symbol = symResolver.lookupSymbolInMainSpace(data.env, Names.fromIdNode(syncSendExpr.workerIdentifier)); if (symTable.notFoundSymbol.equals(symbol)) { syncSendExpr.workerType = symTable.semanticError; @@ -2922,7 +2919,7 @@ public void visit(BLangWorkerSyncSendExpr syncSendExpr, AnalyzerData data) { @Override public void visit(BLangWorkerAsyncSendExpr asyncSendExpr, AnalyzerData data) { BSymbol symbol = - symResolver.lookupSymbolInMainSpace(data.env, names.fromIdNode(asyncSendExpr.workerIdentifier)); + symResolver.lookupSymbolInMainSpace(data.env, Names.fromIdNode(asyncSendExpr.workerIdentifier)); if (symTable.notFoundSymbol.tag == symbol.tag) { asyncSendExpr.workerType = symTable.semanticError; @@ -3086,7 +3083,7 @@ private boolean fieldsCompatibleWithRecord(HashSet fieldNames, BRecordTy @Override public void visit(BLangWorkerReceive workerReceiveExpr, AnalyzerData data) { BSymbol symbol = - symResolver.lookupSymbolInMainSpace(data.env, names.fromIdNode(workerReceiveExpr.workerIdentifier)); + symResolver.lookupSymbolInMainSpace(data.env, Names.fromIdNode(workerReceiveExpr.workerIdentifier)); // TODO Need to remove this cached env workerReceiveExpr.env = data.env; @@ -3122,7 +3119,7 @@ private boolean workerExists(SymbolEnv env, String workerName) { @Override public void visit(BLangConstRef constRef, AnalyzerData data) { constRef.symbol = symResolver.lookupMainSpaceSymbolInPackage(constRef.pos, data.env, - names.fromIdNode(constRef.pkgAlias), names.fromIdNode(constRef.variableName)); + Names.fromIdNode(constRef.pkgAlias), Names.fromIdNode(constRef.variableName)); types.setImplicitCastExpr(constRef, constRef.getBType(), data.expType); data.resultType = constRef.getBType(); @@ -3134,13 +3131,13 @@ public void visit(BLangSimpleVarRef varRefExpr, AnalyzerData data) { BType actualType = symTable.semanticError; BLangIdentifier identifier = varRefExpr.variableName; - Name varName = names.fromIdNode(identifier); + Name varName = Names.fromIdNode(identifier); if (varName == Names.IGNORE) { varRefExpr.setBType(this.symTable.anyType); // If the variable name is a wildcard('_'), the symbol should be ignorable. varRefExpr.symbol = new BVarSymbol(0, true, varName, - names.originalNameFromIdNode(identifier), + Names.originalNameFromIdNode(identifier), data.env.enclPkg.symbol.pkgID, varRefExpr.getBType(), data.env.scope.owner, varRefExpr.pos, VIRTUAL); @@ -3149,7 +3146,7 @@ public void visit(BLangSimpleVarRef varRefExpr, AnalyzerData data) { } Name compUnitName = getCurrentCompUnit(varRefExpr); - BSymbol pkgSymbol = symResolver.resolvePrefixSymbol(data.env, names.fromIdNode(varRefExpr.pkgAlias), + BSymbol pkgSymbol = symResolver.resolvePrefixSymbol(data.env, Names.fromIdNode(varRefExpr.pkgAlias), compUnitName); varRefExpr.pkgSymbol = pkgSymbol; if (pkgSymbol == symTable.notFoundSymbol) { @@ -3161,7 +3158,7 @@ public void visit(BLangSimpleVarRef varRefExpr, AnalyzerData data) { actualType = symTable.stringType; } else if (pkgSymbol != symTable.notFoundSymbol) { BSymbol symbol = symResolver.lookupMainSpaceSymbolInPackage(varRefExpr.pos, data.env, - names.fromIdNode(varRefExpr.pkgAlias), varName); + Names.fromIdNode(varRefExpr.pkgAlias), varName); // if no symbol, check same for object attached function BLangType enclType = data.env.enclType; if (symbol == symTable.notFoundSymbol && enclType != null && enclType.getBType().tsymbol.scope != null) { @@ -3260,9 +3257,9 @@ public void visit(BLangRecordVarRef varRefExpr, AnalyzerData data) { continue; } BVarSymbol bVarSymbol = (BVarSymbol) bLangVarReference.symbol; - BField field = new BField(names.fromIdNode(recordRefField.variableName), varRefExpr.pos, - new BVarSymbol(0, names.fromIdNode(recordRefField.variableName), - names.originalNameFromIdNode(recordRefField.variableName), + BField field = new BField(Names.fromIdNode(recordRefField.variableName), varRefExpr.pos, + new BVarSymbol(0, Names.fromIdNode(recordRefField.variableName), + Names.originalNameFromIdNode(recordRefField.variableName), data.env.enclPkg.symbol.pkgID, bVarSymbol.type, recordSymbol, varRefExpr.pos, SOURCE)); fields.put(field.name.value, field); @@ -3554,9 +3551,9 @@ private void checkFieldBasedAccess(BLangFieldBasedAccess fieldAccessExpr, boolea return; } actualType = checkOptionalFieldAccessExpr(fieldAccessExpr, varRefType, - names.fromIdNode(fieldAccessExpr.field), data); + Names.fromIdNode(fieldAccessExpr.field), data); } else { - actualType = checkFieldAccessExpr(fieldAccessExpr, varRefType, names.fromIdNode(fieldAccessExpr.field), + actualType = checkFieldAccessExpr(fieldAccessExpr, varRefType, Names.fromIdNode(fieldAccessExpr.field), data); if (actualType != symTable.semanticError && @@ -4198,7 +4195,7 @@ private void checkActionInvocation(BLangInvocation.BLangActionInvocation aInv, B } private boolean invalidModuleAliasUsage(BLangInvocation invocation) { - Name pkgAlias = names.fromIdNode(invocation.pkgAlias); + Name pkgAlias = Names.fromIdNode(invocation.pkgAlias); if (pkgAlias != Names.EMPTY) { dlog.error(invocation.pos, DiagnosticErrorCode.PKG_ALIAS_NOT_ALLOWED_HERE); return true; @@ -4928,13 +4925,13 @@ private BRecordType getWaitForAllExprReturnType(BLangWaitForAllExpr waitExpr, fieldName = ((BLangSimpleVarRef) keyVal.valueExpr).variableName; } - BSymbol symbol = symResolver.lookupSymbolInMainSpace(data.env, names.fromIdNode(fieldName)); + BSymbol symbol = symResolver.lookupSymbolInMainSpace(data.env, Names.fromIdNode(fieldName)); BType referredSymType = Types.getImpliedType(symbol.type); BType fieldType = referredSymType.tag == TypeTags.FUTURE ? ((BFutureType) referredSymType).constraint : symbol.type; - BField field = new BField(names.fromIdNode(keyVal.key), null, - new BVarSymbol(0, names.fromIdNode(keyVal.key), - names.originalNameFromIdNode(keyVal.key), + BField field = new BField(Names.fromIdNode(keyVal.key), null, + new BVarSymbol(0, Names.fromIdNode(keyVal.key), + Names.originalNameFromIdNode(keyVal.key), data.env.enclPkg.packageID, fieldType, null, keyVal.pos, VIRTUAL)); retType.fields.put(field.name.value, field); @@ -5039,7 +5036,7 @@ private void checkMissingReqFieldsForWait(BRecordType type, List()); + matchingBoundNonReadOnlyType, env, symTable, anonymousModelHelper, new HashSet<>()); } private BTupleType getMatchingTupleBoundType(BTupleType expType, SymbolEnv env, HashSet resolvedTypes) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeResolver.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeResolver.java index 2e4e4d944cdb..40b920e87e8d 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeResolver.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/TypeResolver.java @@ -143,7 +143,6 @@ public class TypeResolver { private static final CompilerContext.Key TYPE_RESOLVER_KEY = new CompilerContext.Key<>(); private final SymbolTable symTable; - private final Names names; private final SymbolResolver symResolver; private final SymbolEnter symEnter; private final BLangDiagnosticLog dlog; @@ -175,7 +174,6 @@ public TypeResolver(CompilerContext context) { this.symTable = SymbolTable.getInstance(context); this.symEnter = SymbolEnter.getInstance(context); - this.names = Names.getInstance(context); this.symResolver = SymbolResolver.getInstance(context); this.dlog = BLangDiagnosticLog.getInstance(context); this.types = Types.getInstance(context); @@ -318,7 +316,7 @@ public void defineFieldsOfClassDef(BLangClassDefinition classDefinition, SymbolE if (field.symbol.type == symTable.semanticError) { continue; } - objType.fields.put(field.name.value, new BField(names.fromIdNode(field.name), field.pos, field.symbol)); + objType.fields.put(field.name.value, new BField(Names.fromIdNode(field.name), field.pos, field.symbol)); } } @@ -348,8 +346,8 @@ private void defineRestFields(BLangTypeDefinition typeDef) { public void defineClassDef(BLangClassDefinition classDefinition, SymbolEnv env) { EnumSet flags = EnumSet.copyOf(classDefinition.flagSet); boolean isPublicType = flags.contains(Flag.PUBLIC); - Name className = names.fromIdNode(classDefinition.name); - Name classOrigName = names.originalNameFromIdNode(classDefinition.name); + Name className = Names.fromIdNode(classDefinition.name); + Name classOrigName = Names.originalNameFromIdNode(classDefinition.name); BClassSymbol tSymbol = Symbols.createClassSymbol(Flags.asMask(flags), className, env.enclPkg.symbol.pkgID, null, env.scope.owner, classDefinition.name.pos, @@ -887,8 +885,8 @@ private BType resolveTypeDesc(BLangArrayType td, ResolverData data) { } BLangSimpleVarRef sizeReference = (BLangSimpleVarRef) size; - Name pkgAlias = names.fromIdNode(sizeReference.pkgAlias); - Name typeName = names.fromIdNode(sizeReference.variableName); + Name pkgAlias = Names.fromIdNode(sizeReference.pkgAlias); + Name typeName = Names.fromIdNode(sizeReference.variableName); BSymbol sizeSymbol = symResolver.lookupMainSpaceSymbolInPackage(size.pos, symEnv, pkgAlias, typeName); @@ -1155,8 +1153,8 @@ public BType createInvokableType(List paramVars, for (BLangVariable paramNode : paramVars) { BLangSimpleVariable param = (BLangSimpleVariable) paramNode; - Name paramName = names.fromIdNode(param.name); - Name paramOrigName = names.originalNameFromIdNode(param.name); + Name paramName = Names.fromIdNode(param.name); + Name paramOrigName = Names.originalNameFromIdNode(param.name); if (paramName != Names.EMPTY) { if (paramNames.contains(paramName.value)) { dlog.error(param.name.pos, DiagnosticErrorCode.REDECLARED_SYMBOL, paramName.value); @@ -1194,7 +1192,7 @@ public BType createInvokableType(List paramVars, BLangIdentifier id = ((BLangSimpleVariable) restVariable).name; restVariable.setBType(restType); restParam = new BVarSymbol(Flags.asMask(restVariable.flagSet), - names.fromIdNode(id), names.originalNameFromIdNode(id), + Names.fromIdNode(id), Names.originalNameFromIdNode(id), env.enclPkg.symbol.pkgID, restType, env.scope.owner, restVariable.pos, BUILTIN); restVariable.symbol = restParam; } @@ -1465,7 +1463,7 @@ private void fillEffectiveType(BIntersectionType intersectionType, BIntersectionType immutableIntersectionType = ImmutableTypeCloner.getImmutableIntersectionType(intersectionType.tsymbol.pos, types, - intersectionType.effectiveType, env, symTable, anonymousModelHelper, names, + intersectionType.effectiveType, env, symTable, anonymousModelHelper, new HashSet<>()); intersectionType.effectiveType = immutableIntersectionType.effectiveType; } @@ -1485,8 +1483,8 @@ private BType resolveTypeDesc(BLangUserDefinedType td, ResolverData data) { // 3) If the symbol is not found, then lookup in the root scope. e.g. for types such as 'error' SymbolResolver.AnalyzerData analyzerData = new SymbolResolver.AnalyzerData(symEnv); - Name pkgAlias = names.fromIdNode(td.pkgAlias); - Name typeName = names.fromIdNode(td.typeName); + Name pkgAlias = Names.fromIdNode(td.pkgAlias); + Name typeName = Names.fromIdNode(td.typeName); BSymbol symbol = symTable.notFoundSymbol; // 1) Resolve ANNOTATION type if and only current scope inside ANNOTATION definition. @@ -1783,7 +1781,7 @@ private BType resolveTypeDesc(BLangStreamType td, ResolverData data) { } public BType visitBuiltInTypeNode(BLangType typeNode, SymbolResolver.AnalyzerData data, TypeKind typeKind) { - Name typeName = names.fromTypeKind(typeKind); + Name typeName = Names.fromTypeKind(typeKind); BSymbol typeSymbol = symResolver.lookupMemberSymbol(typeNode.pos, symTable.rootScope, data.env, typeName, SymTag.TYPE); if (typeSymbol == symTable.notFoundSymbol) { @@ -1814,7 +1812,7 @@ public BType defineTypeDefinition(BLangTypeDefinition typeDefinition, BType reso typeDefinition.setPrecedence(this.typePrecedence++); BSymbol typeDefSymbol = Symbols.createTypeDefinitionSymbol(Flags.asMask(typeDefinition.flagSet), - names.fromIdNode(typeDefinition.name), env.enclPkg.packageID, resolvedType, env.scope.owner, + Names.fromIdNode(typeDefinition.name), env.enclPkg.packageID, resolvedType, env.scope.owner, typeDefinition.name.pos, symEnter.getOrigin(typeDefinition.name.value)); typeDefSymbol.markdownDocumentation = symEnter.getMarkdownDocAttachment(typeDefinition.markdownDocumentationAttachment); @@ -1831,8 +1829,8 @@ public BType defineTypeDefinition(BLangTypeDefinition typeDefinition, BType reso //todo remove after type ref introduced to runtime if (resolvedType.tsymbol.name == Names.EMPTY) { - resolvedType.tsymbol.name = names.fromIdNode(typeDefinition.name); - resolvedType.tsymbol.originalName = names.originalNameFromIdNode(typeDefinition.name); + resolvedType.tsymbol.name = Names.fromIdNode(typeDefinition.name); + resolvedType.tsymbol.originalName = Names.originalNameFromIdNode(typeDefinition.name); resolvedType.tsymbol.flags |= typeDefSymbol.flags; resolvedType.tsymbol.markdownDocumentation = typeDefSymbol.markdownDocumentation; @@ -1917,12 +1915,12 @@ private BEnumSymbol createEnumSymbol(BLangTypeDefinition typeDefinition, BType d } BEnumSymbol enumSymbol = new BEnumSymbol(enumMembers, Flags.asMask(typeDefinition.flagSet), - names.fromIdNode(typeDefinition.name), names.fromIdNode(typeDefinition.name), + Names.fromIdNode(typeDefinition.name), Names.fromIdNode(typeDefinition.name), env.enclPkg.symbol.pkgID, definedType, env.scope.owner, typeDefinition.pos, SOURCE); - enumSymbol.name = names.fromIdNode(typeDefinition.name); - enumSymbol.originalName = names.fromIdNode(typeDefinition.name); + enumSymbol.name = Names.fromIdNode(typeDefinition.name); + enumSymbol.originalName = Names.fromIdNode(typeDefinition.name); enumSymbol.flags |= Flags.asMask(typeDefinition.flagSet); enumSymbol.markdownDocumentation = @@ -1953,8 +1951,8 @@ public void resolveConstant(SymbolEnv symEnv, Map modTable, B public void resolveXMLNS(SymbolEnv symEnv, BLangXMLNS xmlnsNode) { if (xmlnsNode.namespaceURI.getKind() == NodeKind.SIMPLE_VARIABLE_REF) { BLangSimpleVarRef varRef = (BLangSimpleVarRef) xmlnsNode.namespaceURI; - varRef.symbol = getSymbolOfVarRef(varRef.pos, symEnv, names.fromIdNode(varRef.pkgAlias), - names.fromIdNode(varRef.variableName)); + varRef.symbol = getSymbolOfVarRef(varRef.pos, symEnv, Names.fromIdNode(varRef.pkgAlias), + Names.fromIdNode(varRef.variableName)); } symEnter.defineXMLNS(symEnv, xmlnsNode); } @@ -2045,12 +2043,12 @@ private void defineConstant(SymbolEnv symEnv, Map modTable, B } if (resolvedType.tag == TypeTags.FINITE) { - resolvedType.tsymbol.originalName = names.originalNameFromIdNode(constant.name); + resolvedType.tsymbol.originalName = Names.originalNameFromIdNode(constant.name); } // Get immutable type for the narrowed type. BType intersectionType = ImmutableTypeCloner.getImmutableType(constant.pos, types, resolvedType, symEnv, - symEnv.scope.owner.pkgID, symEnv.scope.owner, symTable, anonymousModelHelper, names, + symEnv.scope.owner.pkgID, symEnv.scope.owner, symTable, anonymousModelHelper, new HashSet<>()); // Fix the constant expr types due to tooling requirements. diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/Types.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/Types.java index 5d90b2db49d6..455df7340f52 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/Types.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/analyzer/Types.java @@ -167,7 +167,6 @@ public class Types { private SymbolTable symTable; private SymbolResolver symResolver; private BLangDiagnosticLog dlog; - private Names names; private int finiteTypeCount = 0; private BUnionType expandedXMLBuiltinSubtypes; private final BLangAnonymousModelHelper anonymousModelHelper; @@ -200,7 +199,6 @@ public Types(CompilerContext context) { this.symTable = SymbolTable.getInstance(context); this.symResolver = SymbolResolver.getInstance(context); this.dlog = BLangDiagnosticLog.getInstance(context); - this.names = Names.getInstance(context); this.expandedXMLBuiltinSubtypes = BUnionType.create(null, symTable.xmlElementType, symTable.xmlCommentType, symTable.xmlPIType, symTable.xmlTextType); @@ -5160,7 +5158,7 @@ private BType getIntersection(IntersectionContext intersectionContext, BType lhs } return ImmutableTypeCloner.getEffectiveImmutableType(intersectionContext.pos, this, bType, - env, symTable, anonymousModelHelper, names); + env, symTable, anonymousModelHelper); } } @@ -5308,7 +5306,7 @@ private BMapType getMapTypeForAnydataOrJson(BType type, SymbolEnv env) { if (isImmutable(type)) { return (BMapType) ImmutableTypeCloner.getEffectiveImmutableType(null, this, mapType, env, symTable, - anonymousModelHelper, names); + anonymousModelHelper); } return mapType; } @@ -5319,7 +5317,7 @@ private BArrayType getArrayTypeForAnydataOrJson(BType type, SymbolEnv env) { if (isImmutable(type)) { return (BArrayType) ImmutableTypeCloner.getEffectiveImmutableType(null, this, arrayType, env, symTable, - anonymousModelHelper, names); + anonymousModelHelper); } return arrayType; } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/SymbolTable.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/SymbolTable.java index a6c13bb63586..e57c660b3c45 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/SymbolTable.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/semantics/model/SymbolTable.java @@ -223,7 +223,6 @@ public class SymbolTable { public BPackageSymbol langRegexpModuleSymbol; - private Names names; private Types types; public Map pkgEnvMap = new HashMap<>(); public Map predeclaredModules = new HashMap<>(); @@ -241,7 +240,6 @@ public static SymbolTable getInstance(CompilerContext context) { private SymbolTable(CompilerContext context) { context.put(SYM_TABLE_KEY, this); - this.names = Names.getInstance(context); this.types = Types.getInstance(context); this.rootPkgNode = (BLangPackage) TreeBuilder.createPackageNode(); @@ -314,7 +312,7 @@ private SymbolTable(CompilerContext context) { }}); this.anyAndReadonly = - ImmutableTypeCloner.getImmutableIntersectionType(this.anyType, this, names, this.types, + ImmutableTypeCloner.getImmutableIntersectionType(this.anyType, this, this.types, rootPkgSymbol.pkgID); initializeType(this.anyAndReadonly, this.anyAndReadonly.effectiveType.name.getValue(), BUILTIN); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/util/ImmutableTypeCloner.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/util/ImmutableTypeCloner.java index 544b2779d08b..9c2542237d88 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/util/ImmutableTypeCloner.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/util/ImmutableTypeCloner.java @@ -95,19 +95,19 @@ private ImmutableTypeCloner() { public static BType getEffectiveImmutableType(Location pos, Types types, BType type, SymbolEnv env, - SymbolTable symTable, BLangAnonymousModelHelper anonymousModelHelper, - Names names) { + SymbolTable symTable, BLangAnonymousModelHelper anonymousModelHelper + ) { return getImmutableIntersectionType(pos, types, type, env, env.enclPkg.packageID, env.scope.owner, - symTable, anonymousModelHelper, names, new HashSet<>(), + symTable, anonymousModelHelper, new HashSet<>(), new HashSet<>()).effectiveType; } public static BType getEffectiveImmutableType(Location pos, Types types, BType type, PackageID pkgId, BSymbol owner, SymbolTable symTable, - BLangAnonymousModelHelper anonymousModelHelper, Names names) { + BLangAnonymousModelHelper anonymousModelHelper) { return getImmutableIntersectionType(pos, types, type, null, pkgId, owner, - symTable, anonymousModelHelper, names, new HashSet<>(), + symTable, anonymousModelHelper, new HashSet<>(), new HashSet<>()).effectiveType; } @@ -115,20 +115,20 @@ public static BIntersectionType getImmutableIntersectionType(Location pos, Types BType type, SymbolEnv env, SymbolTable symTable, BLangAnonymousModelHelper anonymousModelHelper, - Names names, Set origObjFlagSet) { + Set origObjFlagSet) { return getImmutableIntersectionType(pos, types, type, env, env.enclPkg.packageID, env.scope.owner, - symTable, anonymousModelHelper, names, origObjFlagSet, new HashSet<>()); + symTable, anonymousModelHelper, origObjFlagSet, new HashSet<>()); } - public static BIntersectionType getImmutableIntersectionType(BType type, SymbolTable symbolTable, Names names, + public static BIntersectionType getImmutableIntersectionType(BType type, SymbolTable symbolTable, Types types, PackageID pkgId) { return getImmutableIntersectionType(null, types, type, null, pkgId, null, symbolTable, - null, names, null, new HashSet<>()); + null, null, new HashSet<>()); } public static void markFieldsAsImmutable(BLangClassDefinition classDef, SymbolEnv pkgEnv, BObjectType objectType, Types types, BLangAnonymousModelHelper anonymousModelHelper, - SymbolTable symbolTable, Names names, Location pos) { + SymbolTable symbolTable, Location pos) { SymbolEnv typeDefEnv = SymbolEnv.createClassEnv(classDef, objectType.tsymbol.scope, pkgEnv); Iterator objectTypeFieldIterator = objectType.fields.values().iterator(); @@ -151,7 +151,7 @@ public static void markFieldsAsImmutable(BLangClassDefinition classDef, SymbolEn if (!types.isInherentlyImmutableType(type)) { BType immutableFieldType = typeField.symbol.type = ImmutableTypeCloner.getImmutableIntersectionType( - pos, types, type, typeDefEnv, symbolTable, anonymousModelHelper, names, classDef.flagSet); + pos, types, type, typeDefEnv, symbolTable, anonymousModelHelper, classDef.flagSet); classField.setBType(typeField.type = immutableFieldType); } @@ -163,7 +163,7 @@ public static void markFieldsAsImmutable(BLangClassDefinition classDef, SymbolEn public static BType getImmutableType(Location pos, Types types, BType type, SymbolEnv env, PackageID pkgId, BSymbol owner, SymbolTable symTable, - BLangAnonymousModelHelper anonymousModelHelper, Names names, + BLangAnonymousModelHelper anonymousModelHelper, Set unresolvedTypes) { if (type == null) { return symTable.semanticError; @@ -178,7 +178,7 @@ public static BType getImmutableType(Location pos, Types types, BType type, Symb } return getImmutableIntersectionType(pos, types, type, env, pkgId, - owner, symTable, anonymousModelHelper, names, new HashSet<>(), + owner, symTable, anonymousModelHelper, new HashSet<>(), unresolvedTypes); } @@ -187,7 +187,6 @@ private static BIntersectionType getImmutableIntersectionType(Location pos, SymbolEnv env, PackageID pkgId, BSymbol owner, SymbolTable symTable, BLangAnonymousModelHelper anonymousModelHelper, - Names names, Set origObjFlagSet, Set unresolvedTypes) { BType refType = Types.getReferredType(bType); @@ -202,7 +201,7 @@ private static BIntersectionType getImmutableIntersectionType(Location pos, } return ImmutableTypeCloner.setImmutableType(pos, types, type, bType, env, pkgId, owner, symTable, - anonymousModelHelper, names, origObjFlagSet, unresolvedTypes); + anonymousModelHelper, origObjFlagSet, unresolvedTypes); } private static BIntersectionType setImmutableType(Location pos, Types types, @@ -211,7 +210,6 @@ private static BIntersectionType setImmutableType(Location pos, Types types, SymbolEnv env, PackageID pkgId, BSymbol owner, SymbolTable symTable, BLangAnonymousModelHelper anonymousModelHelper, - Names names, Set origObjFlagSet, Set unresolvedTypes) { BType type = (BType) selectivelyImmutableRefType; switch (type.tag) { @@ -231,33 +229,33 @@ private static BIntersectionType setImmutableType(Location pos, Types types, Types.addImmutableType(symTable, pkgId, origXmlSubType, immutableXmlSubTypeIntersectionType); return immutableXmlSubTypeIntersectionType; case TypeTags.XML: - return defineImmutableXMLType(pos, types, env, pkgId, owner, symTable, anonymousModelHelper, names, + return defineImmutableXMLType(pos, types, env, pkgId, owner, symTable, anonymousModelHelper, unresolvedTypes, (BXMLType) type, originalType); case TypeTags.ARRAY: case TypeTags.BYTE_ARRAY: - return defineImmutableArrayType(pos, types, env, pkgId, owner, symTable, anonymousModelHelper, names, + return defineImmutableArrayType(pos, types, env, pkgId, owner, symTable, anonymousModelHelper, unresolvedTypes, (BArrayType) type, originalType); case TypeTags.TUPLE: - return defineImmutableTupleType(pos, types, env, pkgId, owner, symTable, anonymousModelHelper, names, + return defineImmutableTupleType(pos, types, env, pkgId, owner, symTable, anonymousModelHelper, unresolvedTypes, (BTupleType) type, originalType); case TypeTags.MAP: - return defineImmutableMapType(pos, types, env, pkgId, owner, symTable, anonymousModelHelper, names, + return defineImmutableMapType(pos, types, env, pkgId, owner, symTable, anonymousModelHelper, unresolvedTypes, (BMapType) type, originalType); case TypeTags.RECORD: BRecordType origRecordType = (BRecordType) type; return defineImmutableRecordType(pos, origRecordType, originalType, env, symTable, - anonymousModelHelper, names, types, unresolvedTypes); + anonymousModelHelper, types, unresolvedTypes); case TypeTags.OBJECT: BObjectType origObjectType = (BObjectType) type; return defineImmutableObjectType(pos, origObjectType, originalType, env, symTable, - anonymousModelHelper, names, types, origObjFlagSet, unresolvedTypes); + anonymousModelHelper, types, origObjFlagSet, unresolvedTypes); case TypeTags.TABLE: - return defineImmutableTableType(pos, types, env, pkgId, owner, symTable, anonymousModelHelper, names, + return defineImmutableTableType(pos, types, env, pkgId, owner, symTable, anonymousModelHelper, unresolvedTypes, (BTableType) type, originalType); case TypeTags.ANY: BAnyType origAnyType = (BAnyType) type; - BTypeSymbol immutableAnyTSymbol = getReadonlyTSymbol(names, origAnyType.tsymbol, env, pkgId, owner); + BTypeSymbol immutableAnyTSymbol = getReadonlyTSymbol(origAnyType.tsymbol, env, pkgId, owner); BAnyType immutableAnyType; if (immutableAnyTSymbol != null) { @@ -266,7 +264,7 @@ private static BIntersectionType setImmutableType(Location pos, Types types, immutableAnyTSymbol.type = immutableAnyType; } else { immutableAnyType = new BAnyType(origAnyType.tag, immutableAnyTSymbol, - getImmutableTypeName(names, TypeKind.ANY.typeName()), + getImmutableTypeName(TypeKind.ANY.typeName()), origAnyType.flags | Flags.READONLY, origAnyType.isNullable()); } @@ -279,11 +277,11 @@ private static BIntersectionType setImmutableType(Location pos, Types types, case TypeTags.ANYDATA: case TypeTags.JSON: return defineImmutableBuiltInUnionType(pos, types, env, pkgId, owner, symTable, anonymousModelHelper, - names, unresolvedTypes, (BUnionType) type, originalType); + unresolvedTypes, (BUnionType) type, originalType); case TypeTags.INTERSECTION: return (BIntersectionType) type; default: - return defineImmutableUnionType(pos, types, env, pkgId, owner, symTable, anonymousModelHelper, names, + return defineImmutableUnionType(pos, types, env, pkgId, owner, symTable, anonymousModelHelper, unresolvedTypes, (BUnionType) type, originalType); } } @@ -291,10 +289,10 @@ private static BIntersectionType setImmutableType(Location pos, Types types, private static BIntersectionType defineImmutableTableType(Location pos, Types types, SymbolEnv env, PackageID pkgId, BSymbol owner, SymbolTable symTable, BLangAnonymousModelHelper anonymousModelHelper, - Names names, Set unresolvedTypes, + Set unresolvedTypes, BTableType type, BType originalType) { - BTypeSymbol immutableTableTSymbol = getReadonlyTSymbol(names, type.tsymbol, env, pkgId, owner); + BTypeSymbol immutableTableTSymbol = getReadonlyTSymbol(type.tsymbol, env, pkgId, owner); Optional immutableType = Types.getImmutableType(symTable, pkgId, type); if (immutableType.isPresent()) { return immutableType.get(); @@ -307,13 +305,13 @@ originalType, new BTableType(TypeTags.TABLE, null, immutableTableTSymbol, BIntersectionType immutableTableType = Types.getImmutableType(symTable, pkgId, type).orElseThrow(); BTableType tableEffectiveImmutableType = (BTableType) immutableTableType.effectiveType; tableEffectiveImmutableType.constraint = getImmutableType(pos, types, type.constraint, env, pkgId, owner, - symTable, anonymousModelHelper, names, unresolvedTypes); + symTable, anonymousModelHelper, unresolvedTypes); BType origKeyTypeConstraint = type.keyTypeConstraint; if (origKeyTypeConstraint != null) { tableEffectiveImmutableType.keyTypeConstraint = getImmutableType(pos, types, origKeyTypeConstraint, env, pkgId, owner, symTable, - anonymousModelHelper, names, + anonymousModelHelper, unresolvedTypes); } @@ -333,10 +331,10 @@ originalType, new BTableType(TypeTags.TABLE, null, immutableTableTSymbol, private static BIntersectionType defineImmutableXMLType(Location pos, Types types, SymbolEnv env, PackageID pkgId, BSymbol owner, SymbolTable symTable, BLangAnonymousModelHelper anonymousModelHelper, - Names names, Set unresolvedTypes, + Set unresolvedTypes, BXMLType type, BType originalType) { - BTypeSymbol immutableXmlTSymbol = getReadonlyTSymbol(names, type.tsymbol, env, pkgId, owner); + BTypeSymbol immutableXmlTSymbol = getReadonlyTSymbol(type.tsymbol, env, pkgId, owner); Optional immutableType = Types.getImmutableType(symTable, pkgId, type); if (immutableType.isPresent()) { return immutableType.get(); @@ -350,17 +348,17 @@ originalType, new BXMLType(null, immutableXmlTSymbol, type.flags | Flags.READONL BXMLType xmlEffectiveImmutableType = (BXMLType) immutableXMLType.effectiveType; xmlEffectiveImmutableType.mutableType = type; xmlEffectiveImmutableType.constraint = getImmutableType(pos, types, type.constraint, env, pkgId, owner, - symTable, anonymousModelHelper, names, unresolvedTypes); + symTable, anonymousModelHelper, unresolvedTypes); return immutableXMLType; } private static BIntersectionType defineImmutableArrayType(Location pos, Types types, SymbolEnv env, PackageID pkgId, BSymbol owner, SymbolTable symTable, BLangAnonymousModelHelper anonymousModelHelper, - Names names, Set unresolvedTypes, + Set unresolvedTypes, BArrayType type, BType originalType) { - BTypeSymbol immutableArrayTSymbol = getReadonlyTSymbol(names, type.tsymbol, env, pkgId, owner); + BTypeSymbol immutableArrayTSymbol = getReadonlyTSymbol(type.tsymbol, env, pkgId, owner); Optional immutableType = Types.getImmutableType(symTable, pkgId, type); if (immutableType.isPresent()) { return immutableType.get(); @@ -374,17 +372,17 @@ originalType, new BArrayType(null, immutableArrayTSymbol, type.size, type.state, BArrayType arrayEffectiveImmutableType = (BArrayType) immutableArrayType.effectiveType; arrayEffectiveImmutableType.mutableType = type; arrayEffectiveImmutableType.eType = getImmutableType(pos, types, type.eType, env, pkgId, owner, - symTable, anonymousModelHelper, names, unresolvedTypes); + symTable, anonymousModelHelper, unresolvedTypes); return immutableArrayType; } private static BIntersectionType defineImmutableMapType(Location pos, Types types, SymbolEnv env, PackageID pkgId, BSymbol owner, SymbolTable symTable, BLangAnonymousModelHelper anonymousModelHelper, - Names names, Set unresolvedTypes, + Set unresolvedTypes, BMapType type, BType originalType) { - BTypeSymbol immutableMapTSymbol = getReadonlyTSymbol(names, type.tsymbol, env, pkgId, owner); + BTypeSymbol immutableMapTSymbol = getReadonlyTSymbol(type.tsymbol, env, pkgId, owner); Optional immutableType = Types.getImmutableType(symTable, pkgId, type); if (immutableType.isPresent()) { return immutableType.get(); @@ -399,7 +397,7 @@ originalType, new BMapType(TypeTags.MAP, null, immutableMapTSymbol, BMapType mapEffectiveImmutableType = (BMapType) immutableMapType.effectiveType; mapEffectiveImmutableType.mutableType = type; mapEffectiveImmutableType.constraint = getImmutableType(pos, types, type.constraint, env, pkgId, owner, - symTable, anonymousModelHelper, names, + symTable, anonymousModelHelper, unresolvedTypes); return immutableMapType; } @@ -407,7 +405,7 @@ originalType, new BMapType(TypeTags.MAP, null, immutableMapTSymbol, private static BIntersectionType defineImmutableTupleType(Location pos, Types types, SymbolEnv env, PackageID pkgId, BSymbol owner, SymbolTable symTable, BLangAnonymousModelHelper anonymousModelHelper, - Names names, Set unresolvedTypes, + Set unresolvedTypes, BTupleType type, BType originalType) { BTypeSymbol origTupleTypeSymbol = type.tsymbol; @@ -432,7 +430,7 @@ private static BIntersectionType defineImmutableTupleType(Location pos, Types ty Name origTupleTypeSymbolName = Names.EMPTY; if (!originalTypeName.isEmpty()) { origTupleTypeSymbolName = origTupleTypeSymbol.name.value.isEmpty() ? Names.EMPTY : - getImmutableTypeName(names, getSymbolFQN(origTupleTypeSymbol)); + getImmutableTypeName(getSymbolFQN(origTupleTypeSymbol)); tupleEffectiveImmutableType.name = origTupleTypeSymbolName; } @@ -445,7 +443,7 @@ private static BIntersectionType defineImmutableTupleType(Location pos, Types ty continue; } BType newType = getImmutableType(pos, types, origTupleMemType.type, env, - pkgId, owner, symTable, anonymousModelHelper, names, unresolvedTypes); + pkgId, owner, symTable, anonymousModelHelper, unresolvedTypes); BVarSymbol varSymbol = Symbols.createVarSymbolForTupleMember(newType); BTupleMember member = new BTupleMember(newType, varSymbol); tupleEffectiveImmutableType.addMembers(member); @@ -453,7 +451,7 @@ private static BIntersectionType defineImmutableTupleType(Location pos, Types ty if (type.restType != null) { tupleEffectiveImmutableType.addRestType(getImmutableType(pos, types, type.restType, env, pkgId, - owner, symTable, anonymousModelHelper, names, unresolvedTypes)); + owner, symTable, anonymousModelHelper, unresolvedTypes)); } BIntersectionType immutableTupleIntersectionType = Types.getImmutableType(symTable, pkgId, type).get(); @@ -490,8 +488,7 @@ private static BIntersectionType defineImmutableTupleType(Location pos, Types ty public static void defineUndefinedImmutableFields(BLangTypeDefinition immutableTypeDefinition, Types types, SymbolEnv pkgEnv, SymbolTable symTable, - BLangAnonymousModelHelper anonymousModelHelper, - Names names) { + BLangAnonymousModelHelper anonymousModelHelper) { Location pos = immutableTypeDefinition.pos; SymbolEnv env = SymbolEnv.createTypeEnv(immutableTypeDefinition.typeNode, immutableTypeDefinition.symbol.scope, pkgEnv); @@ -500,11 +497,11 @@ public static void defineUndefinedImmutableFields(BLangTypeDefinition immutableT BType immutableType = Types.getImpliedType(immutableTypeDefinition.getBType()); if (immutableType.tag == TypeTags.RECORD) { defineUndefinedImmutableRecordFields((BRecordType) immutableType, pos, pkgID, immutableTypeDefinition, - types, env, symTable, anonymousModelHelper, names); + types, env, symTable, anonymousModelHelper); return; } defineUndefinedImmutableObjectFields((BObjectType) immutableType, pos, pkgID, immutableTypeDefinition, - types, env, symTable, anonymousModelHelper, names); + types, env, symTable, anonymousModelHelper); } private static void defineUndefinedImmutableRecordFields(BRecordType immutableRecordType, @@ -512,12 +509,11 @@ private static void defineUndefinedImmutableRecordFields(BRecordType immutableRe PackageID pkgID, BLangTypeDefinition immutableTypeDefinition, Types types, SymbolEnv env, SymbolTable symTable, - BLangAnonymousModelHelper anonymousModelHelper, - Names names) { + BLangAnonymousModelHelper anonymousModelHelper) { BRecordType origRecordType = immutableRecordType.mutableType; if (origRecordType != null && (origRecordType.fields.size() != immutableRecordType.fields.size())) { - populateImmutableStructureFields(types, symTable, anonymousModelHelper, names, + populateImmutableStructureFields(types, symTable, anonymousModelHelper, (BLangRecordTypeNode) immutableTypeDefinition.typeNode, immutableRecordType, origRecordType, loc, env, pkgID, new HashSet<>()); } @@ -527,7 +523,7 @@ private static void defineUndefinedImmutableRecordFields(BRecordType immutableRe return; } - setRestType(types, symTable, anonymousModelHelper, names, immutableRecordType, origRecordType, loc, env, + setRestType(types, symTable, anonymousModelHelper, immutableRecordType, origRecordType, loc, env, new HashSet<>()); } @@ -536,30 +532,29 @@ private static void defineUndefinedImmutableObjectFields(BObjectType immutableOb PackageID pkgID, BLangTypeDefinition immutableTypeDefinition, Types types, SymbolEnv env, SymbolTable symTable, - BLangAnonymousModelHelper anonymousModelHelper, - Names names) { + BLangAnonymousModelHelper anonymousModelHelper) { BObjectType origObjectType = immutableObjectType.mutableType; if (origObjectType.fields.size() != immutableObjectType.fields.size()) { - TypeDefBuilderHelper.populateStructureFieldsAndTypeInclusions(types, symTable, anonymousModelHelper, names, + TypeDefBuilderHelper.populateStructureFieldsAndTypeInclusions(types, symTable, anonymousModelHelper, (BLangObjectTypeNode) immutableTypeDefinition.typeNode, immutableObjectType, origObjectType, location, env, pkgID, new HashSet<>(), Flags.FINAL, true); } } private static void populateImmutableStructureFields(Types types, SymbolTable symTable, - BLangAnonymousModelHelper anonymousModelHelper, Names names, + BLangAnonymousModelHelper anonymousModelHelper, BLangStructureTypeNode immutableStructureTypeNode, BStructureType immutableStructureType, BStructureType origStructureType, Location pos, SymbolEnv env, PackageID pkgID, Set unresolvedTypes) { - TypeDefBuilderHelper.populateStructureFieldsAndTypeInclusions(types, symTable, anonymousModelHelper, names, + TypeDefBuilderHelper.populateStructureFieldsAndTypeInclusions(types, symTable, anonymousModelHelper, immutableStructureTypeNode, immutableStructureType, origStructureType, pos, env, pkgID, unresolvedTypes, Flags.READONLY, true); } private static void setRestType(Types types, SymbolTable symTable, BLangAnonymousModelHelper anonymousModelHelper, - Names names, BRecordType immutableRecordType, BRecordType origRecordType, + BRecordType immutableRecordType, BRecordType origRecordType, Location pos, SymbolEnv env, Set unresolvedTypes) { immutableRecordType.sealed = origRecordType.sealed; @@ -570,7 +565,7 @@ private static void setRestType(Types types, SymbolTable symTable, BLangAnonymou return; } BType restFieldImmutableType = getImmutableType(pos, types, origRestFieldType, env, env.enclPkg.packageID, - env.scope.owner, symTable, anonymousModelHelper, names, + env.scope.owner, symTable, anonymousModelHelper, unresolvedTypes); immutableRecordType.restFieldType = restFieldImmutableType == symTable.semanticError ? symTable.neverType : restFieldImmutableType; @@ -580,12 +575,12 @@ private static BIntersectionType defineImmutableRecordType(Location pos, BRecord BType originalType, SymbolEnv env, SymbolTable symTable, BLangAnonymousModelHelper anonymousModelHelper, - Names names, Types types, Set unresolvedTypes) { + Types types, Set unresolvedTypes) { PackageID pkgID = env.enclPkg.symbol.pkgID; BTypeSymbol recordTypeSymbol = origRecordType.tsymbol; BRecordTypeSymbol recordSymbol = Symbols.createRecordSymbol(recordTypeSymbol.flags | Flags.READONLY, - getImmutableTypeName(names, getSymbolFQN(recordTypeSymbol)), + getImmutableTypeName(getSymbolFQN(recordTypeSymbol)), pkgID, null, env.scope.owner, pos, VIRTUAL); BInvokableType bInvokableType = new BInvokableType(new ArrayList<>(), symTable.nilType, null); @@ -611,10 +606,10 @@ private static BIntersectionType defineImmutableRecordType(Location pos, BRecord BLangRecordTypeNode recordTypeNode = TypeDefBuilderHelper.createRecordTypeNode(new ArrayList<>(), immutableRecordType, pos); - populateImmutableStructureFields(types, symTable, anonymousModelHelper, names, recordTypeNode, + populateImmutableStructureFields(types, symTable, anonymousModelHelper, recordTypeNode, immutableRecordType, origRecordType, pos, env, pkgID, unresolvedTypes); - setRestType(types, symTable, anonymousModelHelper, names, immutableRecordType, origRecordType, pos, env, + setRestType(types, symTable, anonymousModelHelper, immutableRecordType, origRecordType, pos, env, unresolvedTypes); TypeDefBuilderHelper.addTypeDefinition(immutableRecordType, recordSymbol, recordTypeNode, env); @@ -625,7 +620,7 @@ private static BIntersectionType defineImmutableObjectType(Location pos, BObjectType origObjectType, BType originalType, SymbolEnv env, SymbolTable symTable, BLangAnonymousModelHelper anonymousModelHelper, - Names names, Types types, + Types types, Set flagSet, Set unresolvedTypes) { PackageID pkgID = env.enclPkg.symbol.pkgID; BObjectTypeSymbol origObjectTSymbol = (BObjectTypeSymbol) origObjectType.tsymbol; @@ -634,13 +629,13 @@ private static BIntersectionType defineImmutableObjectType(Location pos, flags &= ~Flags.CLASS; BObjectTypeSymbol objectSymbol = Symbols.createObjectSymbol(flags, - getImmutableTypeName(names, + getImmutableTypeName( getSymbolFQN(origObjectTSymbol)), pkgID, null, env.scope.owner, pos, VIRTUAL); objectSymbol.scope = new Scope(objectSymbol); - defineObjectFunctions(objectSymbol, origObjectTSymbol, names, symTable); + defineObjectFunctions(objectSymbol, origObjectTSymbol, symTable); BObjectType immutableObjectType = new BObjectType(objectSymbol, origObjectType.flags | Flags.READONLY); @@ -659,7 +654,7 @@ private static BIntersectionType defineImmutableObjectType(Location pos, immutableObjectType, pos); objectTypeNode.flagSet.addAll(flagSet); - TypeDefBuilderHelper.populateStructureFieldsAndTypeInclusions(types, symTable, anonymousModelHelper, names, + TypeDefBuilderHelper.populateStructureFieldsAndTypeInclusions(types, symTable, anonymousModelHelper, objectTypeNode, immutableObjectType, origObjectType, pos, env, pkgID, unresolvedTypes, Flags.FINAL, true); @@ -671,7 +666,7 @@ private static BIntersectionType defineImmutableObjectType(Location pos, } public static void defineObjectFunctions(BObjectTypeSymbol immutableObjectSymbol, - BObjectTypeSymbol originalObjectSymbol, Names names, + BObjectTypeSymbol originalObjectSymbol, SymbolTable symTable) { List originalObjectAttachedFuncs = originalObjectSymbol.attachedFuncs; List immutableObjectAttachedFuncs = immutableObjectSymbol.attachedFuncs; @@ -699,7 +694,7 @@ public static void defineObjectFunctions(BObjectTypeSymbol immutableObjectSymbol private static BIntersectionType defineImmutableUnionType(Location pos, Types types, SymbolEnv env, PackageID pkgId, BSymbol owner, SymbolTable symTable, BLangAnonymousModelHelper anonymousModelHelper, - Names names, Set unresolvedTypes, + Set unresolvedTypes, BUnionType type, BType originalType) { BTypeSymbol origUnionTypeSymbol = type.tsymbol; @@ -715,7 +710,7 @@ private static BIntersectionType defineImmutableUnionType(Location pos, Types ty } BIntersectionType immutableType = handleImmutableUnionType(pos, types, env, pkgId, owner, symTable, - anonymousModelHelper, names, + anonymousModelHelper, unresolvedTypes, type, origUnionTypeSymbol, originalMemberList); BType effectiveType = immutableType.effectiveType; @@ -738,7 +733,7 @@ private static BIntersectionType defineImmutableBuiltInUnionType(Location pos, T PackageID pkgId, BSymbol owner, SymbolTable symTable, BLangAnonymousModelHelper anonymousModelHelper, - Names names, Set unresolvedTypes, + Set unresolvedTypes, BUnionType type, BType originalType) { BTypeSymbol origBuiltInUnionTypeSymbol = type.tsymbol; @@ -749,22 +744,22 @@ private static BIntersectionType defineImmutableBuiltInUnionType(Location pos, T BUnionType effectiveType; if (type.tag == TypeTags.JSON) { - effectiveType = defineImmutableJsonType(env, pkgId, owner, names, (BJSONType) type); + effectiveType = defineImmutableJsonType(env, pkgId, owner, (BJSONType) type); } else { - effectiveType = defineImmutableAnydataType(env, pkgId, owner, names, (BAnydataType) type); + effectiveType = defineImmutableAnydataType(env, pkgId, owner, (BAnydataType) type); } BIntersectionType immutableBuiltInUnionIntersectionType = createImmutableIntersectionType(pkgId, owner, originalType, effectiveType, symTable); Types.addImmutableType(symTable, pkgId, type, immutableBuiltInUnionIntersectionType); - return handleImmutableUnionType(pos, types, env, pkgId, owner, symTable, anonymousModelHelper, names, + return handleImmutableUnionType(pos, types, env, pkgId, owner, symTable, anonymousModelHelper, unresolvedTypes, type, origBuiltInUnionTypeSymbol, type.getMemberTypes()); } - private static BAnydataType defineImmutableAnydataType(SymbolEnv env, PackageID pkgId, BSymbol owner, Names names, + private static BAnydataType defineImmutableAnydataType(SymbolEnv env, PackageID pkgId, BSymbol owner, BAnydataType type) { - BTypeSymbol immutableAnydataTSymbol = getReadonlyTSymbol(names, type.tsymbol, env, pkgId, owner); + BTypeSymbol immutableAnydataTSymbol = getReadonlyTSymbol(type.tsymbol, env, pkgId, owner); if (immutableAnydataTSymbol != null) { BAnydataType immutableAnydataType = @@ -775,13 +770,13 @@ private static BAnydataType defineImmutableAnydataType(SymbolEnv env, PackageID return immutableAnydataType; } return new BAnydataType(immutableAnydataTSymbol, - getImmutableTypeName(names, TypeKind.ANYDATA.typeName()), + getImmutableTypeName(TypeKind.ANYDATA.typeName()), type.flags | Flags.READONLY, type.isNullable()); } - private static BJSONType defineImmutableJsonType(SymbolEnv env, PackageID pkgId, BSymbol owner, Names names, + private static BJSONType defineImmutableJsonType(SymbolEnv env, PackageID pkgId, BSymbol owner, BJSONType type) { - BTypeSymbol immutableJsonTSymbol = getReadonlyTSymbol(names, type.tsymbol, env, pkgId, owner); + BTypeSymbol immutableJsonTSymbol = getReadonlyTSymbol(type.tsymbol, env, pkgId, owner); BJSONType immutableJsonType = new BJSONType(immutableJsonTSymbol, type.isNullable(), type.flags | Flags.READONLY); @@ -794,7 +789,7 @@ private static BJSONType defineImmutableJsonType(SymbolEnv env, PackageID pkgId, private static BIntersectionType handleImmutableUnionType(Location pos, Types types, SymbolEnv env, PackageID pkgId, BSymbol owner, SymbolTable symTable, BLangAnonymousModelHelper anonymousModelHelper, - Names names, Set unresolvedTypes, BUnionType type, + Set unresolvedTypes, BUnionType type, BTypeSymbol origUnionTypeSymbol, LinkedHashSet originalMemberList) { BIntersectionType immutableType = Types.getImmutableType(symTable, pkgId, type).get(); @@ -806,7 +801,7 @@ private static BIntersectionType handleImmutableUnionType(Location pos, Types ty String originalTypeName = origUnionTypeSymbol == null ? "" : origUnionTypeSymbol.name.getValue(); if (!originalTypeName.isEmpty()) { - unionEffectiveImmutableType.name = getImmutableTypeName(names, getSymbolFQN(origUnionTypeSymbol)); + unionEffectiveImmutableType.name = getImmutableTypeName(getSymbolFQN(origUnionTypeSymbol)); } for (BType memberType : originalMemberList) { @@ -820,7 +815,7 @@ private static BIntersectionType handleImmutableUnionType(Location pos, Types ty } BType immutableMemberType = getImmutableType(pos, types, memberType, env, pkgId, owner, symTable, - anonymousModelHelper, names, unresolvedTypes); + anonymousModelHelper, unresolvedTypes); unionEffectiveImmutableType.add(immutableMemberType); } @@ -831,7 +826,7 @@ private static BIntersectionType handleImmutableUnionType(Location pos, Types ty BTypeSymbol immutableUnionTSymbol = getReadonlyTSymbol(origUnionTypeSymbol, env, pkgId, owner, origUnionTypeSymbol.name.value.isEmpty() ? Names.EMPTY : - getImmutableTypeName(names, getSymbolFQN(origUnionTypeSymbol))); + getImmutableTypeName(getSymbolFQN(origUnionTypeSymbol))); immutableType.effectiveType.tsymbol = immutableUnionTSymbol; immutableType.effectiveType.flags |= (type.flags | Flags.READONLY); @@ -845,13 +840,13 @@ private static BIntersectionType handleImmutableUnionType(Location pos, Types ty return immutableType; } - private static BTypeSymbol getReadonlyTSymbol(Names names, BTypeSymbol originalTSymbol, SymbolEnv env, + private static BTypeSymbol getReadonlyTSymbol(BTypeSymbol originalTSymbol, SymbolEnv env, PackageID pkgId, BSymbol owner) { if (originalTSymbol == null) { return null; } - return getReadonlyTSymbol(originalTSymbol, env, pkgId, owner, getImmutableTypeName(names, originalTSymbol)); + return getReadonlyTSymbol(originalTSymbol, env, pkgId, owner, getImmutableTypeName(originalTSymbol)); } private static BTypeSymbol getReadonlyTSymbol(BTypeSymbol originalTSymbol, SymbolEnv env, PackageID pkgId, @@ -881,11 +876,11 @@ private static String getSymbolFQN(BTypeSymbol originalTSymbol) { getMajorVersion(pkgID.version.value) + ":" + originalTSymbol.name; } - private static Name getImmutableTypeName(Names names, BTypeSymbol originalTSymbol) { - return getImmutableTypeName(names, originalTSymbol.name.getValue()); + private static Name getImmutableTypeName(BTypeSymbol originalTSymbol) { + return getImmutableTypeName(originalTSymbol.name.getValue()); } - private static Name getImmutableTypeName(Names names, String origName) { + private static Name getImmutableTypeName(String origName) { if (origName.isEmpty()) { return Names.EMPTY; } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/util/NodeUtils.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/util/NodeUtils.java index 7d11bf155ef1..42e009f2b3c2 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/util/NodeUtils.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/util/NodeUtils.java @@ -33,12 +33,10 @@ private NodeUtils() { /** * Return the {@code Name} from the give package name components. * - * @param names utility class which manages all the names used - * in the Ballerina compiler. * @param pkgNameComps components of the given package name. * @return returns the name from the given package name components. */ - public static Name getName(Names names, List pkgNameComps) { + public static Name getName(List pkgNameComps) { String pkgName = String.join(".", pkgNameComps.stream() .map(id -> id.value) .toList()); @@ -50,14 +48,14 @@ public static Name getName(String localname, String namespaceURI) { return new Name(qname); } - public static PackageID getPackageID(Names names, BLangIdentifier orgNameNode, + public static PackageID getPackageID(BLangIdentifier orgNameNode, List pkgNameComps, BLangIdentifier versionNode) { - List nameList = pkgNameComps.stream().map(names::fromIdNode).toList(); + List nameList = pkgNameComps.stream().map(Names::fromIdNode).toList(); Name orgName = null; if (orgNameNode != null) { - orgName = names.fromIdNode(orgNameNode); + orgName = Names.fromIdNode(orgNameNode); } - Name version = names.fromIdNode(versionNode); + Name version = Names.fromIdNode(versionNode); if (version == Names.EMPTY) { version = Names.DEFAULT_VERSION; } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/util/TypeDefBuilderHelper.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/util/TypeDefBuilderHelper.java index c2fd5f5b7026..e32c2213d09a 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/util/TypeDefBuilderHelper.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/util/TypeDefBuilderHelper.java @@ -138,16 +138,14 @@ public static BLangObjectTypeNode createObjectTypeNode(List public static BLangFunction createInitFunctionForStructureType(BSymbol symbol, SymbolEnv env, - Names names, Name suffix, SymbolTable symTable, BType type) { - return createInitFunctionForStructureType(symbol, env, names, suffix, type, symTable.nilType); + return createInitFunctionForStructureType(symbol, env, suffix, type, symTable.nilType); } public static BLangFunction createInitFunctionForStructureType(BSymbol symbol, SymbolEnv env, - Names names, Name suffix, BType type, BType returnType) { @@ -157,8 +155,8 @@ public static BLangFunction createInitFunctionForStructureType(BSymbol symbol, // Create the receiver and add receiver details to the node initFunction.receiver = ASTBuilderUtil.createReceiver(null, type); BVarSymbol receiverSymbol = new BVarSymbol(Flags.asMask(EnumSet.noneOf(Flag.class)), - names.fromIdNode(initFunction.receiver.name), - names.originalNameFromIdNode(initFunction.receiver.name), + Names.fromIdNode(initFunction.receiver.name), + Names.originalNameFromIdNode(initFunction.receiver.name), env.enclPkg.symbol.pkgID, type, null, null, VIRTUAL); initFunction.receiver.symbol = receiverSymbol; initFunction.attachedFunction = true; @@ -299,7 +297,7 @@ public static String getPackageAlias(SymbolEnv env, String compUnitName, Package public static void populateStructureFieldsAndTypeInclusions(Types types, SymbolTable symTable, BLangAnonymousModelHelper anonymousModelHelper, - Names names, BLangStructureTypeNode structureTypeNode, + BLangStructureTypeNode structureTypeNode, BStructureType structureType, BStructureType origStructureType, Location pos, SymbolEnv env, PackageID pkgID, @@ -312,7 +310,7 @@ public static void populateStructureFieldsAndTypeInclusions(Types types, SymbolT BType fieldType; if (isImmutable) { fieldType = ImmutableTypeCloner.getImmutableType(pos, types, origField.type, env, - env.enclPkg.packageID, env.scope.owner, symTable, anonymousModelHelper, names, unresolvedTypes); + env.enclPkg.packageID, env.scope.owner, symTable, anonymousModelHelper, unresolvedTypes); } else { fieldType = origField.type; } @@ -364,7 +362,7 @@ public static void populateStructureFieldsAndTypeInclusions(Types types, SymbolT } } - public static void createTypeDefinition(BRecordType type, Location pos, Names names, + public static void createTypeDefinition(BRecordType type, Location pos, Types types, SymbolTable symTable, SymbolEnv env) { BRecordTypeSymbol recordSymbol = (BRecordTypeSymbol) type.tsymbol; @@ -386,7 +384,7 @@ public static void createTypeDefinition(BRecordType type, Location pos, Names na BLangRecordTypeNode recordTypeNode = TypeDefBuilderHelper.createRecordTypeNode(new ArrayList<>(), type, pos); - TypeDefBuilderHelper.populateStructureFieldsAndTypeInclusions(types, symTable, null, names, recordTypeNode, + TypeDefBuilderHelper.populateStructureFieldsAndTypeInclusions(types, symTable, null, recordTypeNode, type, type, pos, env, env.scope.owner.pkgID, null, Flags.REQUIRED, false); recordTypeNode.sealed = true; diff --git a/compiler/ballerina-lang/src/test/java/org/wso2/ballerinalang/compiler/SourceDirectoryManagerTest.java b/compiler/ballerina-lang/src/test/java/org/wso2/ballerinalang/compiler/SourceDirectoryManagerTest.java index fd3c49271a47..4573477dd889 100644 --- a/compiler/ballerina-lang/src/test/java/org/wso2/ballerinalang/compiler/SourceDirectoryManagerTest.java +++ b/compiler/ballerina-lang/src/test/java/org/wso2/ballerinalang/compiler/SourceDirectoryManagerTest.java @@ -51,7 +51,6 @@ public void init() { @Test(description = "Return modules list should be equivalence to the expected module list") public void testListSourceFilesAndPackages() { - Names names = Names.getInstance(context); List expectedPackageIds = new ArrayList<>(); expectedPackageIds.add(new PackageID(Names.fromString("abc"), Names.fromString("fruits"), @@ -65,7 +64,6 @@ public void testListSourceFilesAndPackages() { @Test(description = "Return module should be equivalence to the expected module") public void testGetPackageID() { PackageID fruits = directoryManager.getPackageID("fruits"); - Names names = Names.getInstance(context); PackageID expectedPackageId = new PackageID(Names.fromString("abc"), Names.fromString("fruits"), Names.fromString("0.0.1")); @@ -75,7 +73,6 @@ public void testGetPackageID() { @Test(description = "Test if module exist in the project") public void testIsModuleExists() { Project project = context.get(Project.PROJECT_KEY); - Names names = Names.getInstance(context); PackageID expectedPackageId = new PackageID(Names.fromString("abc"), Names.fromString("fruits"), Names.fromString("0.0.1")); @@ -97,7 +94,6 @@ public void testIsModuleExists() { @Test(description = "Test if get bala path") public void getBalaPath() throws InvalidModuleException { Project project = context.get(Project.PROJECT_KEY); - Names names = Names.getInstance(context); PackageID moduleId = new PackageID(Names.fromString("abc"), Names.fromString("fruits"), Names.fromString("0.0.1")); From 97b4c9dd37d17dd1ac76e8bc08a036ef3b94aa48 Mon Sep 17 00:00:00 2001 From: Felix Schnabel Date: Sun, 11 Aug 2024 22:20:12 +0200 Subject: [PATCH 3/3] Encapsulate `Name.value` --- .../api/impl/BallerinaSemanticModel.java | 2 +- .../compiler/api/impl/ExpectedTypeFinder.java | 2 +- .../compiler/api/impl/LangLibrary.java | 8 +- .../compiler/api/impl/ReferenceFinder.java | 2 +- .../compiler/api/impl/SymbolFactory.java | 6 +- .../symbols/AbstractIntSubTypeSymbol.java | 4 +- .../symbols/AbstractXMLSubTypeSymbol.java | 4 +- .../impl/symbols/BallerinaClassSymbol.java | 6 +- .../impl/symbols/BallerinaConstantSymbol.java | 2 +- .../symbols/BallerinaErrorTypeSymbol.java | 2 +- .../symbols/BallerinaObjectFieldSymbol.java | 2 +- .../symbols/BallerinaObjectTypeSymbol.java | 8 +- .../symbols/BallerinaRecordFieldSymbol.java | 2 +- .../symbols/BallerinaRecordTypeSymbol.java | 2 +- .../symbols/BallerinaRegexpTypeSymbol.java | 2 +- .../BallerinaResourceMethodSymbol.java | 2 +- .../BallerinaServiceDeclarationSymbol.java | 11 +- .../BallerinaStringCharTypeSymbol.java | 4 +- .../api/impl/symbols/BallerinaSymbol.java | 2 +- .../api/impl/symbols/TypesFactory.java | 4 +- .../BallerinaPathSegmentList.java | 2 +- .../io/ballerina/projects/ConfigReader.java | 2 +- .../ballerina/projects/DocumentContext.java | 6 +- .../projects/JBallerinaBalaWriter.java | 4 +- .../ballerina/projects/PackageResolution.java | 4 +- .../model/elements/PackageID.java | 10 +- .../fs/GeneralFSPackageRepository.java | 6 +- .../compiler/BIRPackageSymbolEnter.java | 28 +-- .../ballerinalang/compiler/PackageCache.java | 8 +- .../compiler/SourceDirectoryManager.java | 12 +- .../ballerinalang/compiler/bir/BIRGen.java | 50 ++--- .../compiler/bir/codegen/JvmCodeGenUtil.java | 37 ++-- .../compiler/bir/codegen/JvmDesugarPhase.java | 40 ++-- .../compiler/bir/codegen/JvmErrorGen.java | 10 +- .../bir/codegen/JvmInstructionGen.java | 10 +- .../compiler/bir/codegen/JvmPackageGen.java | 39 ++-- .../bir/codegen/JvmTerminatorGen.java | 34 ++-- .../compiler/bir/codegen/JvmTypeGen.java | 18 +- .../compiler/bir/codegen/JvmTypeTestGen.java | 4 +- .../compiler/bir/codegen/JvmValueGen.java | 20 +- .../internal/FieldNameHashComparator.java | 4 +- .../internal/FunctionParamComparator.java | 2 +- .../codegen/internal/NameHashComparator.java | 4 +- .../bir/codegen/interop/AnnotationProc.java | 12 +- .../bir/codegen/interop/InteropMethodGen.java | 12 +- .../bir/codegen/interop/JMethodResolver.java | 5 +- .../codegen/methodgen/ConfigMethodGen.java | 2 +- .../bir/codegen/methodgen/FrameClassGen.java | 2 +- .../bir/codegen/methodgen/InitMethodGen.java | 2 +- .../bir/codegen/methodgen/LambdaGen.java | 8 +- .../bir/codegen/methodgen/MainMethodGen.java | 3 +- .../bir/codegen/methodgen/MethodGen.java | 38 ++-- .../bir/codegen/methodgen/MethodGenUtils.java | 10 +- .../optimizer/LargeMethodOptimizer.java | 26 +-- .../bir/codegen/split/JvmCreateTypeGen.java | 20 +- .../constants/JvmBallerinaConstantsGen.java | 2 +- .../constants/JvmErrorTypeConstantsGen.java | 2 +- .../constants/JvmModuleConstantsGen.java | 6 +- .../JvmStrandMetadataConstantsGen.java | 6 +- .../creators/JvmFunctionCallsCreatorsGen.java | 4 +- .../split/creators/JvmObjectCreatorGen.java | 4 +- .../codegen/split/types/JvmObjectTypeGen.java | 20 +- .../codegen/split/types/JvmRecordTypeGen.java | 2 +- .../codegen/split/types/JvmRefTypeGen.java | 2 +- .../codegen/split/values/JvmObjectGen.java | 9 +- .../codegen/split/values/JvmRecordGen.java | 16 +- .../compiler/bir/emit/BIREmitter.java | 2 +- .../compiler/bir/emit/EmitterUtils.java | 8 +- .../compiler/bir/model/BIRNode.java | 6 +- .../optimizer/BIRRecordValueOptimizer.java | 8 +- .../compiler/bir/writer/BIRBinaryWriter.java | 44 ++--- .../bir/writer/BIRInstructionWriter.java | 46 ++--- .../compiler/bir/writer/BIRTypeWriter.java | 28 +-- .../compiler/bir/writer/BIRWriterUtils.java | 2 +- .../compiler/desugar/ASTBuilderUtil.java | 4 +- .../compiler/desugar/AnnotationDesugar.java | 10 +- .../compiler/desugar/ClassClosureDesugar.java | 8 +- .../compiler/desugar/ClosureDesugar.java | 27 +-- .../compiler/desugar/ClosureGenerator.java | 21 ++- .../compiler/desugar/Code2CloudDesugar.java | 8 +- .../desugar/DeclarativeAuthDesugar.java | 10 +- .../compiler/desugar/Desugar.java | 113 ++++++------ .../compiler/desugar/LargeMethodSplitter.java | 6 +- .../desugar/ObservabilityDesugar.java | 4 +- .../compiler/desugar/QueryDesugar.java | 4 +- .../compiler/desugar/ServiceDesugar.java | 4 +- .../packaging/converters/PathConverter.java | 8 +- .../packaging/converters/ZipConverter.java | 2 +- .../compiler/packaging/repo/HomeRepo.java | 6 +- .../compiler/packaging/repo/JarRepo.java | 2 +- .../compiler/packaging/repo/ObjRepo.java | 6 +- .../compiler/packaging/repo/PathBalaRepo.java | 8 +- .../packaging/repo/ProgramingSourceRepo.java | 2 +- .../packaging/repo/ProjectSourceRepo.java | 8 +- .../repo/ProjectSourceRepoWithTests.java | 2 +- .../compiler/packaging/repo/RemoteRepo.java | 8 +- .../parser/BLangAnonymousModelHelper.java | 4 +- .../parser/BLangMissingNodesHelper.java | 2 +- .../compiler/parser/BLangNodeBuilder.java | 14 +- .../semantics/analyzer/CodeAnalyzer.java | 8 +- .../analyzer/CompilerPluginRunner.java | 9 +- .../analyzer/ConstantTypeChecker.java | 10 +- .../analyzer/ConstantValueResolver.java | 6 +- .../semantics/analyzer/DataflowAnalyzer.java | 23 +-- .../analyzer/EffectiveTypePopulator.java | 34 ++-- .../semantics/analyzer/IsolationAnalyzer.java | 8 +- .../semantics/analyzer/QueryTypeChecker.java | 16 +- .../semantics/analyzer/SemanticAnalyzer.java | 41 +++-- .../semantics/analyzer/SymbolEnter.java | 85 ++++----- .../semantics/analyzer/SymbolResolver.java | 25 +-- .../semantics/analyzer/TypeChecker.java | 84 ++++----- .../semantics/analyzer/TypeHashVisitor.java | 12 +- .../semantics/analyzer/TypeParamAnalyzer.java | 20 +- .../semantics/analyzer/TypeResolver.java | 15 +- .../compiler/semantics/analyzer/Types.java | 28 +-- .../compiler/semantics/model/SymbolTable.java | 2 +- .../model/symbols/BResourceFunction.java | 2 +- .../symbols/BResourcePathSegmentSymbol.java | 6 +- .../model/symbols/BTypeDefinitionSymbol.java | 2 +- .../semantics/model/symbols/BTypeSymbol.java | 2 +- .../semantics/model/symbols/Symbols.java | 2 +- .../semantics/model/types/BErrorType.java | 4 +- .../semantics/model/types/BIntSubType.java | 6 +- .../model/types/BIntersectionType.java | 4 +- .../semantics/model/types/BNeverType.java | 2 +- .../semantics/model/types/BNilType.java | 2 +- .../semantics/model/types/BRegexpType.java | 6 +- .../semantics/model/types/BStringSubType.java | 6 +- .../semantics/model/types/BStructureType.java | 2 +- .../semantics/model/types/BUnionType.java | 2 +- .../semantics/model/types/BXMLSubType.java | 6 +- .../semantics/model/types/BXMLType.java | 4 +- .../compiler/tree/BLangSimpleVariable.java | 2 +- .../tree/expressions/BLangConstant.java | 4 +- .../tree/expressions/BLangSimpleVarRef.java | 4 +- .../compiler/tree/statements/BLangLock.java | 2 +- .../compiler/util/CompilerUtils.java | 9 +- .../compiler/util/ImmutableTypeCloner.java | 20 +- .../ballerinalang/compiler/util/Name.java | 3 +- .../ballerinalang/compiler/util/Names.java | 2 +- .../compiler/util/ProjectDirs.java | 2 +- .../compiler/util/TypeDefBuilderHelper.java | 26 +-- .../ballerinalang/compiler/util/Unifier.java | 22 +-- .../util/diagnotic/DiagnosticPos.java | 6 +- .../ballerinalang/birspec/BIRTestUtils.java | 46 ++--- .../context/ImportDeclarationNodeContext.java | 4 +- .../context/ImportOrgNameNodeContext.java | 4 +- .../java/io/ballerina/utils/ParserUtil.java | 4 +- .../core/MockAnnotationProcessor.java | 5 +- .../testerina/core/TestProcessor.java | 6 +- .../api/test/util/SemanticAPITestUtils.java | 4 +- .../java/org/ballerinalang/test/BRunUtil.java | 4 +- .../AnnotationAttachmentSymbolsTest.java | 16 +- .../annotations/AnnotationAttachmentTest.java | 6 +- .../test/bala/annotation/AnnotationTests.java | 174 +++++++++--------- .../object/ObjectIncludeOverrideBalaTest.java | 8 +- .../test/bir/RecordDesugarTest.java | 6 +- .../isolation/IsolationInferenceTest.java | 2 +- 158 files changed, 989 insertions(+), 965 deletions(-) diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/BallerinaSemanticModel.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/BallerinaSemanticModel.java index 73bf9e881f9b..a8bb84b7a0f7 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/BallerinaSemanticModel.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/BallerinaSemanticModel.java @@ -684,7 +684,7 @@ private boolean isResourceFunction(BSymbol symbol) { } private boolean isIgnorableSelfSymbol(Name name, BSymbol symbol, BSymbol symbolEnvScopeOwner) { - return name.value.equals("self") && !symbol.owner.owner.equals(symbolEnvScopeOwner.owner); + return name.getValue().equals("self") && !symbol.owner.owner.equals(symbolEnvScopeOwner.owner); } private boolean isFilteredVarSymbol(BSymbol symbol, Set states) { diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/ExpectedTypeFinder.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/ExpectedTypeFinder.java index c19429826ce3..6a9fed200813 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/ExpectedTypeFinder.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/ExpectedTypeFinder.java @@ -1099,7 +1099,7 @@ private Optional getParamType(BLangInvocation bLangNode, int argumen //Skip the first n arguments where n is the number of positional arguments specified by the user. int numOfPositionalArgs = argumentIndex - namedArgs.size(); return invokableSymbol.params.subList(numOfPositionalArgs, paramsSize) - .stream().filter(param -> !namedArgs.contains(param.name.value)) + .stream().filter(param -> !namedArgs.contains(param.name.getValue())) .findFirst().flatMap(this::getSymbolType); } if (invokableSymbol.restParam != null) { diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/LangLibrary.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/LangLibrary.java index 98dd7af33a89..1020eb85a8f2 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/LangLibrary.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/LangLibrary.java @@ -75,8 +75,8 @@ private LangLibrary(CompilerContext context) { PackageID moduleID = module.pkgID; if (isLangLibModule(moduleID)) { - if (!LANG_VALUE.equals(moduleID.nameComps.get(1).value)) { - addLangLibMethods(moduleID.nameComps.get(1).value, module, this.langLibMethods, types); + if (!LANG_VALUE.equals(moduleID.nameComps.get(1).getValue())) { + addLangLibMethods(moduleID.nameComps.get(1).getValue(), module, this.langLibMethods, types); } else { populateLangValueLibrary(module, this.langLibMethods); } @@ -186,7 +186,7 @@ private static void addLangLibMethods(String basicType, BPackageSymbol langLibMo (!invSymbol.params.isEmpty() && equalsToBasicType(invSymbol.params.get(0).type, basicType) || invSymbol.restParam != null && equalsToBasicType(((BArrayType) invSymbol.restParam.type).eType, basicType))) { - methods.put(invSymbol.name.value, invSymbol); + methods.put(invSymbol.name.getValue(), invSymbol); } } @@ -204,7 +204,7 @@ private static void populateLangValueLibrary(BPackageSymbol langValue, continue; } - methods.put(symbol.name.value, (BInvokableSymbol) symbol); + methods.put(symbol.name.getValue(), (BInvokableSymbol) symbol); } langLibMethods.put(LANG_VALUE, methods); diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/ReferenceFinder.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/ReferenceFinder.java index 902bb75932b8..28239dca70d6 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/ReferenceFinder.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/ReferenceFinder.java @@ -1479,7 +1479,7 @@ private void findRefsInResourceAccessPathSegments(BLangInvocation.BLangResourceA } BLangLiteral literal = (BLangLiteral) expr; - if (literal.value.equals(pathSymbol.name.value) && addIfSameSymbol(pathSymbol, expr.pos)) { + if (literal.value.equals(pathSymbol.name.getValue()) && addIfSameSymbol(pathSymbol, expr.pos)) { return; } } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFactory.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFactory.java index c457b9a5f73f..7751c740fd9e 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFactory.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/SymbolFactory.java @@ -524,7 +524,7 @@ public BallerinaEnumSymbol createEnumSymbol(BEnumSymbol enumSymbol, String name) List members = new ArrayList<>(); for (BConstantSymbol member : enumSymbol.members) { - members.add(this.createConstantSymbol(member, member.name.value)); + members.add(this.createConstantSymbol(member, member.name.getValue())); } for (AnnotationAttachmentSymbol annot : enumSymbol.getAnnotations()) { @@ -766,7 +766,7 @@ private String getMethodName(BInvokableSymbol method, BObjectTypeSymbol owner) { for (BAttachedFunction mthd : methods) { if (method == mthd.symbol) { if (mthd instanceof BResourceFunction bResourceFunction) { - return bResourceFunction.accessor.value; + return bResourceFunction.accessor.getValue(); } return mthd.symbol.getOriginalName().getValue(); } @@ -788,7 +788,7 @@ private void addIfFlagSet(BallerinaClassSymbol.ClassSymbolBuilder symbolBuilder, } private BField getBField(BVarSymbol symbol) { - String fieldName = symbol.name.value; + String fieldName = symbol.name.getValue(); BStructureType type = (BStructureType) symbol.owner.type; return type.fields.get(fieldName); } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/AbstractIntSubTypeSymbol.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/AbstractIntSubTypeSymbol.java index ccb710cf79b0..1726084e7bc7 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/AbstractIntSubTypeSymbol.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/AbstractIntSubTypeSymbol.java @@ -48,8 +48,8 @@ public Optional getModule() { SymbolTable symTable = SymbolTable.getInstance(this.context); SymbolFactory symFactory = SymbolFactory.getInstance(this.context); this.module = (ModuleSymbol) symFactory.getBCompiledSymbol(symTable.langIntModuleSymbol, - symTable.langIntModuleSymbol - .getOriginalName().value); + symTable.langIntModuleSymbol + .getOriginalName().getValue()); return Optional.of(this.module); } } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/AbstractXMLSubTypeSymbol.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/AbstractXMLSubTypeSymbol.java index 541b9cda9fdb..cd7825c06cf3 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/AbstractXMLSubTypeSymbol.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/AbstractXMLSubTypeSymbol.java @@ -48,8 +48,8 @@ public Optional getModule() { SymbolTable symTable = SymbolTable.getInstance(this.context); SymbolFactory symFactory = SymbolFactory.getInstance(this.context); this.module = (ModuleSymbol) symFactory.getBCompiledSymbol(symTable.langXmlModuleSymbol, - symTable.langXmlModuleSymbol - .getOriginalName().value); + symTable.langXmlModuleSymbol + .getOriginalName().getValue()); return Optional.of(this.module); } } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaClassSymbol.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaClassSymbol.java index 7d2bf8583143..23a5b2440ab0 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaClassSymbol.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaClassSymbol.java @@ -91,7 +91,7 @@ public Map fieldDescriptors() { BObjectType type = (BObjectType) this.getBType(); for (BField field : type.fields.values()) { - fields.put(field.symbol.getOriginalName().value, new BallerinaClassFieldSymbol(this.context, field)); + fields.put(field.symbol.getOriginalName().getValue(), new BallerinaClassFieldSymbol(this.context, field)); } this.classFields = Collections.unmodifiableMap(fields); @@ -108,8 +108,8 @@ public Optional initMethod() { if (this.initMethod == null && this.internalSymbol.initializerFunc != null) { SymbolFactory symbolFactory = SymbolFactory.getInstance(this.context); this.initMethod = symbolFactory.createMethodSymbol(internalSymbol.initializerFunc.symbol, - internalSymbol.initializerFunc.symbol - .getOriginalName().value); + internalSymbol.initializerFunc.symbol + .getOriginalName().getValue()); } return Optional.ofNullable(this.initMethod); diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaConstantSymbol.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaConstantSymbol.java index 9e0a696feecd..381e2fe61e7c 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaConstantSymbol.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaConstantSymbol.java @@ -91,7 +91,7 @@ public TypeDescKind typeKind() { @Override public String signature() { - return this.getInternalSymbol().name.value; + return this.getInternalSymbol().name.getValue(); } @Override diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaErrorTypeSymbol.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaErrorTypeSymbol.java index 85ab4492d850..66132d25f235 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaErrorTypeSymbol.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaErrorTypeSymbol.java @@ -83,7 +83,7 @@ public Optional getModule() { } SymbolFactory symbolFactory = SymbolFactory.getInstance(this.context); - this.module = symbolFactory.createModuleSymbol((BPackageSymbol) symbol, symbol.name.value); + this.module = symbolFactory.createModuleSymbol((BPackageSymbol) symbol, symbol.name.getValue()); return Optional.of(this.module); } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaObjectFieldSymbol.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaObjectFieldSymbol.java index 14ae5d9f7c04..2f3a67886cfc 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaObjectFieldSymbol.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaObjectFieldSymbol.java @@ -59,7 +59,7 @@ public class BallerinaObjectFieldSymbol extends BallerinaSymbol implements Objec private List annotAttachments; public BallerinaObjectFieldSymbol(CompilerContext context, BField bField, SymbolKind kind) { - super(bField.symbol.getOriginalName().value, kind, bField.symbol, context); + super(bField.symbol.getOriginalName().getValue(), kind, bField.symbol, context); this.bField = bField; this.docAttachment = new BallerinaDocumentation(bField.symbol.markdownDocumentation); this.deprecated = Symbols.isFlagOn(bField.symbol.flags, Flags.DEPRECATED); diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaObjectTypeSymbol.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaObjectTypeSymbol.java index c7eb00b3a536..910de0c65b4d 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaObjectTypeSymbol.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaObjectTypeSymbol.java @@ -94,7 +94,7 @@ public Map fieldDescriptors() { BObjectType type = (BObjectType) this.getBType(); for (BField field : type.fields.values()) { - fields.put(field.symbol.getOriginalName().value, new BallerinaObjectFieldSymbol(this.context, field)); + fields.put(field.symbol.getOriginalName().getValue(), new BallerinaObjectFieldSymbol(this.context, field)); } this.objectFields = Collections.unmodifiableMap(fields); @@ -113,11 +113,11 @@ public Map methods() { for (BAttachedFunction attachedFunc : ((BObjectTypeSymbol) this.getBType().tsymbol).attachedFuncs) { if (attachedFunc instanceof BResourceFunction resFn) { String resPath = resFn.pathSegmentSymbols.stream() - .map(p -> p.name.value).collect(Collectors.joining("/")); - methods.put(resFn.accessor.value + " " + resPath, + .map(p -> p.name.getValue()).collect(Collectors.joining("/")); + methods.put(resFn.accessor.getValue() + " " + resPath, symbolFactory.createResourceMethodSymbol(attachedFunc.symbol)); } else { - methods.put(attachedFunc.funcName.value, + methods.put(attachedFunc.funcName.getValue(), symbolFactory.createMethodSymbol(attachedFunc.symbol, attachedFunc.symbol.getOriginalName().getValue())); } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaRecordFieldSymbol.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaRecordFieldSymbol.java index e5962a1116c0..0f55d6f40bd6 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaRecordFieldSymbol.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaRecordFieldSymbol.java @@ -58,7 +58,7 @@ public class BallerinaRecordFieldSymbol extends BallerinaSymbol implements Recor private boolean deprecated; public BallerinaRecordFieldSymbol(CompilerContext context, BField bField) { - super(bField.symbol.getOriginalName().value, SymbolKind.RECORD_FIELD, bField.symbol, context); + super(bField.symbol.getOriginalName().getValue(), SymbolKind.RECORD_FIELD, bField.symbol, context); this.bField = bField; this.docAttachment = new BallerinaDocumentation(bField.symbol.markdownDocumentation); this.deprecated = Symbols.isFlagOn(bField.symbol.flags, Flags.DEPRECATED); diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaRecordTypeSymbol.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaRecordTypeSymbol.java index a288bb882344..366a5c4b6fb4 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaRecordTypeSymbol.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaRecordTypeSymbol.java @@ -61,7 +61,7 @@ public Map fieldDescriptors() { BRecordType type = (BRecordType) this.getBType(); for (BField field : type.fields.values()) { - fields.put(field.symbol.getOriginalName().value, new BallerinaRecordFieldSymbol(this.context, field)); + fields.put(field.symbol.getOriginalName().getValue(), new BallerinaRecordFieldSymbol(this.context, field)); } this.fieldSymbols = Collections.unmodifiableMap(fields); diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaRegexpTypeSymbol.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaRegexpTypeSymbol.java index 4c5f43a6447d..a2b9bc5421a5 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaRegexpTypeSymbol.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaRegexpTypeSymbol.java @@ -56,7 +56,7 @@ public Optional getModule() { SymbolTable symTable = SymbolTable.getInstance(this.context); SymbolFactory symFactory = SymbolFactory.getInstance(this.context); this.module = (ModuleSymbol) symFactory.getBCompiledSymbol(symTable.langRegexpModuleSymbol, - symTable.langRegexpModuleSymbol.getOriginalName().value); + symTable.langRegexpModuleSymbol.getOriginalName().getValue()); } return Optional.ofNullable(this.module); } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaResourceMethodSymbol.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaResourceMethodSymbol.java index 370a20a6c2f4..994e7a0cff33 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaResourceMethodSymbol.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaResourceMethodSymbol.java @@ -150,6 +150,6 @@ private BResourceFunction getBResourceFunction(List methods, } throw new IllegalStateException( - "Matching BResourceFunction not found for internal symbol: " + internalSymbol.name.value); + "Matching BResourceFunction not found for internal symbol: " + internalSymbol.name.getValue()); } } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaServiceDeclarationSymbol.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaServiceDeclarationSymbol.java index df06197ba142..72246fb19953 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaServiceDeclarationSymbol.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaServiceDeclarationSymbol.java @@ -123,7 +123,7 @@ public Map fieldDescriptors() { Map fields = new LinkedHashMap<>(); for (BField field : classType.fields.values()) { - fields.put(field.name.value, new BallerinaClassFieldSymbol(this.context, field)); + fields.put(field.name.getValue(), new BallerinaClassFieldSymbol(this.context, field)); } this.fields = Collections.unmodifiableMap(fields); @@ -146,14 +146,15 @@ public Map fieldDescriptors() { StringJoiner stringJoiner = new StringJoiner("/"); for (BResourcePathSegmentSymbol pathSegmentSym : resFn.pathSegmentSymbols) { - stringJoiner.add(pathSegmentSym.name.value); + stringJoiner.add(pathSegmentSym.name.getValue()); } - methods.put(resFn.accessor.value + " " + stringJoiner.toString(), + methods.put(resFn.accessor.getValue() + " " + stringJoiner.toString(), symbolFactory.createResourceMethodSymbol(method.symbol)); } else { - methods.put(method.funcName.value, - symbolFactory.createMethodSymbol(method.symbol, method.symbol.getOriginalName().value)); + methods.put( + method.funcName.getValue(), + symbolFactory.createMethodSymbol(method.symbol, method.symbol.getOriginalName().getValue())); } } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaStringCharTypeSymbol.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaStringCharTypeSymbol.java index 6e493c8f74c4..66800da9759d 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaStringCharTypeSymbol.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaStringCharTypeSymbol.java @@ -62,8 +62,8 @@ public Optional getModule() { SymbolTable symTable = SymbolTable.getInstance(this.context); SymbolFactory symFactory = SymbolFactory.getInstance(this.context); this.module = (ModuleSymbol) symFactory.getBCompiledSymbol(symTable.langStringModuleSymbol, - symTable.langStringModuleSymbol - .getOriginalName().value); + symTable.langStringModuleSymbol + .getOriginalName().getValue()); return Optional.of(this.module); } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaSymbol.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaSymbol.java index 2c30110360ff..8cdb2de8e5bc 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaSymbol.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/BallerinaSymbol.java @@ -98,7 +98,7 @@ public Optional getModule() { } SymbolFactory symbolFactory = SymbolFactory.getInstance(this.context); - this.module = symbolFactory.createModuleSymbol((BPackageSymbol) symbol, symbol.name.value); + this.module = symbolFactory.createModuleSymbol((BPackageSymbol) symbol, symbol.name.getValue()); return Optional.of(this.module); } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/TypesFactory.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/TypesFactory.java index 3c0705554eda..05ff03257d6d 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/TypesFactory.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/TypesFactory.java @@ -209,7 +209,7 @@ private TypeSymbol createTypeDescriptor(BType bType, BTypeSymbol tSymbol) { case OBJECT: ObjectTypeSymbol objType = new BallerinaObjectTypeSymbol(this.context, (BObjectType) bType); if (Symbols.isFlagOn(tSymbol.flags, Flags.CLASS)) { - return symbolFactory.createClassSymbol((BClassSymbol) tSymbol, tSymbol.name.value, objType); + return symbolFactory.createClassSymbol((BClassSymbol) tSymbol, tSymbol.name.getValue(), objType); } return objType; case RECORD: @@ -302,7 +302,7 @@ public boolean isTypeReference(BType bType, BSymbol tSymbol, boolean rawTypeOnly return false; } - if (!isBuiltinNamedType(bType.tag) && !(tSymbol.name.value.isEmpty() + if (!isBuiltinNamedType(bType.tag) && !(tSymbol.name.getValue().isEmpty() || anonymousModelHelper.isAnonymousType(tSymbol))) { return true; } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/resourcepath/BallerinaPathSegmentList.java b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/resourcepath/BallerinaPathSegmentList.java index f9c96bff3ad7..07bf716bb854 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/resourcepath/BallerinaPathSegmentList.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/compiler/api/impl/symbols/resourcepath/BallerinaPathSegmentList.java @@ -72,7 +72,7 @@ public List pathParameters() { for (int i = 0; i < segments.size(); i++) { Name internalSegment = segments.get(i); BResourcePathSegmentSymbol pathSegSymbol = this.internalPathSegmentSymbols.get(i); - switch (internalSegment.value) { + switch (internalSegment.getValue()) { case "^": BVarSymbol paramVarSymbol = this.internalPathParams.get(internalPathParamCount++); pathParams.add(symbolFactory.createPathParamSymbol(paramVarSymbol.getOriginalName().getValue(), diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ConfigReader.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ConfigReader.java index fc35b719b2de..2b9f2c1eafe2 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ConfigReader.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/ConfigReader.java @@ -203,7 +203,7 @@ private static void getConfigVars(Module module, Collection sc // Get description String description = getDescriptionValue(varSymbol, module); configVariables.add(new ConfigVariable( - varSymbol.name.value.replace("\\", ""), varSymbol.type, + varSymbol.name.getValue().replace("\\", ""), varSymbol.type, Symbols.isFlagOn(varSymbol.flags, Flags.REQUIRED), description)); } } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/DocumentContext.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/DocumentContext.java index c219679275d7..16b25065b896 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/DocumentContext.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/DocumentContext.java @@ -144,10 +144,10 @@ private Set getModuleLoadRequests(ModuleDescriptor currentMod TransactionImportValidator trxImportValidator = new TransactionImportValidator(); if (trxImportValidator.shouldImportTransactionPackage(modulePartNode) && - !currentModuleDesc.name().toString().equals(Names.TRANSACTION.value)) { - String moduleName = Names.TRANSACTION.value; + !currentModuleDesc.name().toString().equals(Names.TRANSACTION.getValue())) { + String moduleName = Names.TRANSACTION.getValue(); ModuleLoadRequest ballerinaiLoadReq = new ModuleLoadRequest( - PackageOrg.from(Names.BALLERINA_INTERNAL_ORG.value), + PackageOrg.from(Names.BALLERINA_INTERNAL_ORG.getValue()), moduleName, scope, DependencyResolutionType.PLATFORM_PROVIDED); moduleLoadRequestSet.add(ballerinaiLoadReq); } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/JBallerinaBalaWriter.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/JBallerinaBalaWriter.java index 25aeaefb1914..a4d0815aa9ec 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/JBallerinaBalaWriter.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/JBallerinaBalaWriter.java @@ -247,8 +247,8 @@ private CompilerBackend.TargetPlatform getTargetPlatform(PackageResolution pkgRe // 1) Check direct dependencies of imports in the package have any `ballerina/java` dependency for (ResolvedPackageDependency dependency : resolvedPackageDependencies) { - if (dependency.packageInstance().packageOrg().value().equals(Names.BALLERINA_ORG.value) && - dependency.packageInstance().packageName().value().equals(Names.JAVA.value) && + if (dependency.packageInstance().packageOrg().value().equals(Names.BALLERINA_ORG.getValue()) && + dependency.packageInstance().packageName().value().equals(Names.JAVA.getValue()) && !dependency.scope().equals(PackageDependencyScope.TEST_ONLY)) { return this.backend.targetPlatform(); } diff --git a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/PackageResolution.java b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/PackageResolution.java index c59091c276ba..3e103a8b3435 100644 --- a/compiler/ballerina-lang/src/main/java/io/ballerina/projects/PackageResolution.java +++ b/compiler/ballerina-lang/src/main/java/io/ballerina/projects/PackageResolution.java @@ -327,7 +327,7 @@ private LinkedHashSet getModuleLoadRequestsOfDirectDependenci { String moduleName = Names.OBSERVE.getValue(); ModuleLoadRequest observeModuleLoadReq = new ModuleLoadRequest( - PackageOrg.from(Names.BALLERINA_INTERNAL_ORG.value), moduleName, + PackageOrg.from(Names.BALLERINA_INTERNAL_ORG.getValue()), moduleName, PackageDependencyScope.DEFAULT, DependencyResolutionType.PLATFORM_PROVIDED); allModuleLoadRequests.add(observeModuleLoadReq); } @@ -338,7 +338,7 @@ private LinkedHashSet getModuleLoadRequestsOfDirectDependenci "choreo".equals(compilationOptions.getCloud())) { String moduleName = Names.CLOUD.getValue(); ModuleLoadRequest c2cModuleLoadReq = new ModuleLoadRequest( - PackageOrg.from(Names.BALLERINA_ORG.value), moduleName, + PackageOrg.from(Names.BALLERINA_ORG.getValue()), moduleName, PackageDependencyScope.DEFAULT, DependencyResolutionType.COMPILER_PLUGIN); allModuleLoadRequests.add(c2cModuleLoadReq); } diff --git a/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/elements/PackageID.java b/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/elements/PackageID.java index 3c2f49be0890..1591badf6801 100644 --- a/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/elements/PackageID.java +++ b/compiler/ballerina-lang/src/main/java/org/ballerinalang/model/elements/PackageID.java @@ -166,7 +166,7 @@ private List createNameComps(Name name) { if (name == Names.DEFAULT_PACKAGE) { return Lists.of(Names.DEFAULT_PACKAGE); } - return Arrays.stream(name.value.split("\\.")).map(Name::new).toList(); + return Arrays.stream(name.getValue().split("\\.")).map(Name::new).toList(); } /** @@ -256,19 +256,19 @@ public int hashCode() { @Override public String toString() { if (Names.DOT.equals(this.name)) { - return this.name.value; + return this.name.getValue(); } String org = ""; if (this.orgName != null && !this.orgName.equals(Names.ANON_ORG)) { - org = this.orgName + Names.ORG_NAME_SEPARATOR.value; + org = this.orgName + Names.ORG_NAME_SEPARATOR.getValue(); } if (version.equals(Names.EMPTY)) { - return org + this.name.value; + return org + this.name.getValue(); } - return org + this.name + Names.VERSION_SEPARATOR.value + this.version; + return org + this.name + Names.VERSION_SEPARATOR.getValue() + this.version; } public Name getOrgName() { diff --git a/compiler/ballerina-lang/src/main/java/org/ballerinalang/repository/fs/GeneralFSPackageRepository.java b/compiler/ballerina-lang/src/main/java/org/ballerinalang/repository/fs/GeneralFSPackageRepository.java index a7ddf1f68c7f..5d6b744fd6f1 100644 --- a/compiler/ballerina-lang/src/main/java/org/ballerinalang/repository/fs/GeneralFSPackageRepository.java +++ b/compiler/ballerina-lang/src/main/java/org/ballerinalang/repository/fs/GeneralFSPackageRepository.java @@ -167,7 +167,7 @@ protected Path generatePathOld(PackageID pkgID) { Path pkgDirPath = this.basePath; for (Name comp : pkgID.getNameComps()) { - pkgDirPath = pkgDirPath.resolve(comp.value); + pkgDirPath = pkgDirPath.resolve(comp.getValue()); } return pkgDirPath; } @@ -183,7 +183,7 @@ public Path generatePath(PackageID pkgID) { } private Path generatePathNew(PackageID pkgID) { - Path pkgDirPath = this.basePath.resolve(pkgID.getOrgName().value); + Path pkgDirPath = this.basePath.resolve(pkgID.getOrgName().getValue()); return pkgDirPath.resolve(createPackageNameWithDots(pkgID)); } @@ -194,7 +194,7 @@ private String createPackageNameWithDots(PackageID pkgID) { if (i != 0) { builder.append("."); } - builder.append(nameComps.get(i).value); + builder.append(nameComps.get(i).getValue()); } return builder.toString(); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/BIRPackageSymbolEnter.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/BIRPackageSymbolEnter.java index 7887e9ae7f9e..d2b628cc8c6f 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/BIRPackageSymbolEnter.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/BIRPackageSymbolEnter.java @@ -281,9 +281,10 @@ private void populateReferencedFunctions() { // we should not copy private functions. continue; } - String referencedFuncName = function.funcName.value; + String referencedFuncName = function.funcName.getValue(); Name funcName = Names.fromString( - Symbols.getAttachedFuncSymbolName(structureTypeSymbol.name.value, referencedFuncName)); + Symbols.getAttachedFuncSymbolName(structureTypeSymbol.name.getValue(), + referencedFuncName)); Scope.ScopeEntry matchingObjFuncSym = objectType.tsymbol.scope.lookup(funcName); if (matchingObjFuncSym == NOT_FOUND_ENTRY) { structureTypeSymbol.attachedFuncs.add(function); @@ -416,7 +417,7 @@ private void defineFunction(DataInputStream dataInStream) throws IOException { // Update the symbol invokableSymbol.owner = attachedType.tsymbol; invokableSymbol.name = - Names.fromString(Symbols.getAttachedFuncSymbolName(attachedType.tsymbol.name.value, funcName)); + Names.fromString(Symbols.getAttachedFuncSymbolName(attachedType.tsymbol.name.getValue(), funcName)); if (attachedType.tag == TypeTags.OBJECT || attachedType.tag == TypeTags.RECORD) { scopeToDefine = attachedType.tsymbol.scope; if (isResourceFunction) { @@ -478,10 +479,10 @@ private void defineFunction(DataInputStream dataInStream) throws IOException { new BAttachedFunction(Names.fromString(funcName), invokableSymbol, funcType, symTable.builtinPos); BStructureTypeSymbol structureTypeSymbol = (BStructureTypeSymbol) attachedType.tsymbol; - if (Names.USER_DEFINED_INIT_SUFFIX.value.equals(funcName) || - funcName.equals(Names.INIT_FUNCTION_SUFFIX.value)) { + if (Names.USER_DEFINED_INIT_SUFFIX.getValue().equals(funcName) || + funcName.equals(Names.INIT_FUNCTION_SUFFIX.getValue())) { ((BObjectTypeSymbol) structureTypeSymbol).initializerFunc = attachedFunc; - } else if (funcName.equals(Names.GENERATED_INIT_SUFFIX.value)) { + } else if (funcName.equals(Names.GENERATED_INIT_SUFFIX.getValue())) { ((BObjectTypeSymbol) structureTypeSymbol).generatedInitializerFunc = attachedFunc; } else { structureTypeSymbol.attachedFuncs.add(attachedFunc); @@ -541,7 +542,7 @@ private void defineTypeDef(DataInputStream dataInStream) throws IOException { BTypeReferenceType referenceType = null; boolean hasReferenceType = dataInStream.readBoolean(); if (hasReferenceType) { - if (type.tag == TypeTags.TYPEREFDESC && Objects.equals(type.tsymbol.name.value, typeDefName) + if (type.tag == TypeTags.TYPEREFDESC && Objects.equals(type.tsymbol.name.getValue(), typeDefName) && type.tsymbol.owner == this.env.pkgSymbol) { referenceType = (BTypeReferenceType) type; referenceType.tsymbol.pos = pos; @@ -1298,7 +1299,7 @@ public BType readType(int cpI) throws IOException { defineMarkDownDocAttachment(varSymbol, docBytes); BField structField = new BField(varSymbol.name, varSymbol.pos, varSymbol); - recordType.fields.put(structField.name.value, structField); + recordType.fields.put(structField.name.getValue(), structField); recordSymbol.scope.define(varSymbol.name, varSymbol); } @@ -1654,7 +1655,7 @@ public BType readType(int cpI) throws IOException { defineMarkDownDocAttachment(objectVarSymbol, docBytes); BField structField = new BField(objectVarSymbol.name, null, objectVarSymbol); - objectType.fields.put(structField.name.value, structField); + objectType.fields.put(structField.name.getValue(), structField); objectSymbol.scope.define(objectVarSymbol.name, objectVarSymbol); } boolean generatedConstructorPresent = inputStream.readBoolean(); @@ -1804,7 +1805,7 @@ private void populateIntersectionTypeReferencedFunctions(DataInputStream inputSt long attachedFuncFlags = inputStream.readLong(); BInvokableType attachedFuncType = (BInvokableType) readTypeFromCp(); Name funcName = Names.fromString(Symbols.getAttachedFuncSymbolName( - objectSymbol.name.value, attachedFuncName)); + objectSymbol.name.getValue(), attachedFuncName)); Name funcOrigName = Names.fromString(attachedFuncOrigName); BInvokableSymbol attachedFuncSymbol = Symbols.createFunctionSymbol(attachedFuncFlags, funcName, funcOrigName, @@ -1832,7 +1833,8 @@ private void populateIntersectionTypeReferencedFunctions(DataInputStream inputSt private BType getType(BType readShape, SymbolEnv pkgEnv, Name name) { BType type = symbolResolver.lookupSymbolInMainSpace(pkgEnv, name).type; - if (type != symTable.noType && (!name.value.contains(ANON_PREFIX) || types.isSameBIRShape(readShape, type))) { + if (type != symTable.noType && (!name.getValue().contains(ANON_PREFIX) || + types.isSameBIRShape(readShape, type))) { return type; } @@ -1847,7 +1849,7 @@ private BType getType(BType readShape, SymbolEnv pkgEnv, Name name) { if (types.isSameBIRShape(readShape, anonType)) { return anonType; } - } else if (typeDefName.equals(name.value)) { + } else if (typeDefName.equals(name.getValue())) { return symbol.type; } } @@ -1855,7 +1857,7 @@ private BType getType(BType readShape, SymbolEnv pkgEnv, Name name) { for (Map.Entry value : pkgEnv.scope.entries.entrySet()) { BSymbol symbol = value.getValue().symbol; - if (value.getKey().value.contains(ANON_PREFIX)) { + if (value.getKey().getValue().contains(ANON_PREFIX)) { BType anonType = symbol.type; if (types.isSameBIRShape(readShape, anonType)) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/PackageCache.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/PackageCache.java index 146c3f5a4353..92e340bb181e 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/PackageCache.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/PackageCache.java @@ -78,7 +78,7 @@ public void put(PackageID packageID, BLangPackage bLangPackage) { public void remove(PackageID packageID) { packageMap.remove(getCacheID(packageID)); - String[] packageElements = packageID.toString().split(Names.VERSION_SEPARATOR.value); + String[] packageElements = packageID.toString().split(Names.VERSION_SEPARATOR.getValue()); packageSymbolMap.remove(packageElements[0]); } @@ -106,7 +106,7 @@ public BPackageSymbol getSymbol(PackageID packageID) { } public BPackageSymbol getSymbol(String bvmAlias) { - String[] packageElements = bvmAlias.split(Names.VERSION_SEPARATOR.value); + String[] packageElements = bvmAlias.split(Names.VERSION_SEPARATOR.getValue()); Map versionMap = packageSymbolMap.get(packageElements[0]); if (versionMap != null) { if (packageElements.length > 1) { @@ -122,13 +122,13 @@ public BPackageSymbol getSymbol(String bvmAlias) { } public void putSymbol(PackageID packageID, BPackageSymbol packageSymbol) { - String[] packageElements = packageID.toString().split(Names.VERSION_SEPARATOR.value); + String[] packageElements = packageID.toString().split(Names.VERSION_SEPARATOR.getValue()); Map versionMap = packageSymbolMap.computeIfAbsent(packageElements[0], k -> new LinkedHashMap<>()); if (packageElements.length > 1) { versionMap.put(getMajorVersion(packageElements[1]), packageSymbol); } else { - versionMap.put(Names.DEFAULT_VERSION.value, packageSymbol); + versionMap.put(Names.DEFAULT_VERSION.getValue(), packageSymbol); } } } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/SourceDirectoryManager.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/SourceDirectoryManager.java index 4673f6f1f0a6..a89a34783e23 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/SourceDirectoryManager.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/SourceDirectoryManager.java @@ -236,9 +236,9 @@ boolean checkIfSourcesExists(String pkg) { @Override public boolean isModuleExists(PackageID moduleId) { - if (this.sourceDirectory.getSourcePackageNames().contains(moduleId.name.value) && - this.manifest.getProject().getOrgName().equals(moduleId.orgName.value) && - this.manifest.getProject().getVersion().equals(moduleId.version.value)) { + if (this.sourceDirectory.getSourcePackageNames().contains(moduleId.name.getValue()) && + this.manifest.getProject().getOrgName().equals(moduleId.orgName.getValue()) && + this.manifest.getProject().getVersion().equals(moduleId.version.getValue())) { return true; } else { return false; @@ -253,11 +253,11 @@ public Path getBalaPath(PackageID moduleId) throws InvalidModuleException { // Get the version of the project. String versionNo = manifest.getProject().getVersion(); // Identify the platform version - String platform = manifest.getTargetPlatform(moduleId.name.value); + String platform = manifest.getTargetPlatform(moduleId.name.getValue()); // {module}-{lang spec version}-{platform}-{version}.bala //+ "2019R2" + ProjectDirConstants.FILE_NAME_DELIMITER - String balaFileName = moduleId.name.value + "-" - + moduleId.orgName.value + "-" + String balaFileName = moduleId.name.getValue() + "-" + + moduleId.orgName.getValue() + "-" + platform + "-" + versionNo + BLANG_COMPILED_PKG_BINARY_EXT; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java index 9186c3a0bfbf..7624f5c87c0f 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/BIRGen.java @@ -364,7 +364,7 @@ public void visit(BLangTypeDefinition astTypeDefinition) { BType type = getDefinedType(astTypeDefinition); BType referredType = Types.getImpliedType(type); BSymbol symbol = astTypeDefinition.symbol; - String displayName = symbol.name.value; + String displayName = symbol.name.getValue(); if (referredType.tag == TypeTags.RECORD) { BRecordType recordType = (BRecordType) referredType; if (recordType.shouldPrintShape()) { @@ -579,12 +579,12 @@ public void visit(BLangFunction astFunc) { this.env.unlockVars.push(new BIRLockDetailsHolder()); Name funcName; if (isTypeAttachedFunction) { - funcName = Names.fromString(astFunc.symbol.name.value); + funcName = Names.fromString(astFunc.symbol.name.getValue()); } else { funcName = getFuncName(astFunc.symbol); } BIRFunction birFunc = new BIRFunction(astFunc.pos, funcName, - Names.fromString(astFunc.symbol.getOriginalName().value), astFunc.symbol.flags, type, workerName, + Names.fromString(astFunc.symbol.getOriginalName().getValue()), astFunc.symbol.flags, type, workerName, astFunc.sendsToThis.size(), astFunc.symbol.origin.toBIROrigin()); this.currentScope = new BirScope(0, null); if (astFunc.receiver != null) { @@ -651,7 +651,7 @@ public void visit(BLangFunction astFunc) { // Parent symbol will always be BObjectTypeSymbol for resource functions BObjectTypeSymbol objectTypeSymbol = (BObjectTypeSymbol) parentTSymbol; for (BAttachedFunction func : objectTypeSymbol.attachedFuncs) { - if (func.funcName.value.equals(funcName.value)) { + if (func.funcName.getValue().equals(funcName.getValue())) { BResourceFunction resourceFunction = (BResourceFunction) func; List pathParamSymbols = resourceFunction.pathParams; @@ -715,7 +715,7 @@ public void visit(BLangFunction astFunc) { private BIRVariableDcl createBIRVarDeclForPathParam(BVarSymbol pathParamSym) { return new BIRVariableDcl(pathParamSym.pos, pathParamSym.type, this.env.nextLocalVarId(), - VarScope.FUNCTION, VarKind.ARG, pathParamSym.name.value); + VarScope.FUNCTION, VarKind.ARG, pathParamSym.name.getValue()); } private BIRVariableDcl getSelf(BSymbol receiver) { @@ -832,7 +832,7 @@ public void visit(BLangLambdaFunction lambdaExpr) { } PackageID pkgID = lambdaExpr.function.symbol.pkgID; - PackageID boundMethodPkgId = getPackageIdForBoundMethod(lambdaExpr, funcName.value); + PackageID boundMethodPkgId = getPackageIdForBoundMethod(lambdaExpr, funcName.getValue()); boolean isWorker = lambdaExpr.function.flagSet.contains(Flag.WORKER); List closureMapOperands = getClosureMapOperands(lambdaExpr); @@ -841,14 +841,14 @@ public void visit(BLangLambdaFunction lambdaExpr) { lambdaExpr.getBType(), lambdaExpr.function.symbol.strandName, lambdaExpr.function.symbol.schedulerPolicy, isWorker); setScopeAndEmit(fpLoad); - BType targetType = getRecordTargetType(funcName.value); + BType targetType = getRecordTargetType(funcName.getValue()); if (lambdaExpr.function.flagSet.contains(Flag.RECORD) && targetType != null && targetType.tag == TypeTags.RECORD) { // If the function is for record type and has captured variables, then we need to create a // temp value in the type and keep it setScopeAndEmit( new BIRNonTerminator.RecordDefaultFPLoad(lhsOp.pos, lhsOp, targetType, - getFieldName(funcName.value, targetType.tsymbol.name.value))); + getFieldName(funcName.getValue(), targetType.tsymbol.name.getValue()))); } this.env.targetOperand = lhsOp; } @@ -865,7 +865,7 @@ private BType getRecordTargetType(String funcName) { String[] split = funcName.split(Pattern.quote(RECORD_DELIMITER)); String typeName = split[split.length - 2]; for (BIRTypeDefinition type : this.env.enclPkg.typeDefs) { - if (typeName.equals(type.originalName.value)) { + if (typeName.equals(type.originalName.getValue())) { return type.type; } } @@ -889,11 +889,11 @@ private List getClosureMapOperands(BLangLambdaFunction lambdaExpr) { private Name getFuncName(BInvokableSymbol symbol) { if (symbol.receiverSymbol == null) { - return Names.fromString(symbol.name.value); + return Names.fromString(symbol.name.getValue()); } - int offset = symbol.receiverSymbol.type.tsymbol.name.value.length() + 1; - String attachedFuncName = symbol.name.value; + int offset = symbol.receiverSymbol.type.tsymbol.name.getValue().length() + 1; + String attachedFuncName = symbol.name.getValue(); return Names.fromString(attachedFuncName.substring(offset)); } @@ -912,7 +912,7 @@ private void addParam(BIRFunction birFunc, BVarSymbol paramSymbol, BLangExpressi paramSymbol.kind == SymbolKind.PATH_REST_PARAMETER; BIRFunctionParameter birVarDcl = new BIRFunctionParameter(pos, paramSymbol.type, this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.ARG, - paramSymbol.name.value, defaultValExpr != null, isPathParam); + paramSymbol.name.getValue(), defaultValExpr != null, isPathParam); birFunc.localVars.add(birVarDcl); @@ -928,7 +928,7 @@ private void addParam(BIRFunction birFunc, BVarSymbol paramSymbol, BLangExpressi private void addRestParam(BIRFunction birFunc, BVarSymbol paramSymbol, Location pos) { BIRFunctionParameter birVarDcl = new BIRFunctionParameter(pos, paramSymbol.type, - this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.ARG, paramSymbol.name.value, false, + this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.ARG, paramSymbol.name.getValue(), false, paramSymbol.kind == SymbolKind.PATH_REST_PARAMETER); birFunc.parameters.add(birVarDcl); birFunc.localVars.add(birVarDcl); @@ -946,7 +946,7 @@ private void addRequiredParam(BIRFunction birFunc, BVarSymbol paramSymbol, Locat boolean isPathParam = paramSymbol.kind == SymbolKind.PATH_PARAMETER || paramSymbol.kind == SymbolKind.PATH_REST_PARAMETER; BIRFunctionParameter birVarDcl = new BIRFunctionParameter(pos, paramSymbol.type, - this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.ARG, paramSymbol.name.value, + this.env.nextLocalVarId(), VarScope.FUNCTION, VarKind.ARG, paramSymbol.name.getValue(), false, isPathParam); birFunc.parameters.add(birVarDcl); birFunc.localVars.add(birVarDcl); @@ -1101,8 +1101,8 @@ public void visit(BLangSimpleVariableDef astVarDefStmt) { @Override public void visit(BLangSimpleVariable varNode) { - String name = ANNOTATION_DATA.equals(varNode.symbol.name.value) ? ANNOTATION_DATA : varNode.name.value; - String originalName = ANNOTATION_DATA.equals(varNode.symbol.getOriginalName().value) ? + String name = ANNOTATION_DATA.equals(varNode.symbol.name.getValue()) ? ANNOTATION_DATA : varNode.name.value; + String originalName = ANNOTATION_DATA.equals(varNode.symbol.getOriginalName().getValue()) ? ANNOTATION_DATA : varNode.name.originalValue; BIRGlobalVariableDcl birVarDcl = new BIRGlobalVariableDcl(varNode.pos, varNode.symbol.flags, varNode.symbol.type, varNode.symbol.pkgID, @@ -1183,7 +1183,7 @@ public void visit(BLangAlternateWorkerReceive altWorkerReceive) { BIROperand lhsOp = new BIROperand(tempVarDcl); this.env.targetOperand = lhsOp; - boolean isOnSameStrand = DEFAULT_WORKER_NAME.equals(this.env.enclFunc.workerName.value); + boolean isOnSameStrand = DEFAULT_WORKER_NAME.equals(this.env.enclFunc.workerName.getValue()); this.env.enclBB.terminator = new BIRTerminator.WorkerAlternateReceive(altWorkerReceive.pos, getChannelList(altWorkerReceive), lhsOp, isOnSameStrand, thenBB, this.currentScope); @@ -1218,7 +1218,7 @@ public void visit(BLangMultipleWorkerReceive multipleWorkerReceive) { this.env.enclFunc.localVars.add(tempVarDcl); BIROperand lhsOp = new BIROperand(tempVarDcl); this.env.targetOperand = lhsOp; - boolean isOnSameStrand = DEFAULT_WORKER_NAME.equals(this.env.enclFunc.workerName.value); + boolean isOnSameStrand = DEFAULT_WORKER_NAME.equals(this.env.enclFunc.workerName.getValue()); this.env.enclBB.terminator = new BIRTerminator.WorkerMultipleReceive(multipleWorkerReceive.pos, getChannelList(multipleWorkerReceive), lhsOp, isOnSameStrand, thenBB, this.currentScope); @@ -1237,7 +1237,7 @@ public void visit(BLangWorkerReceive workerReceive) { BIROperand lhsOp = new BIROperand(tempVarDcl); this.env.targetOperand = lhsOp; - boolean isOnSameStrand = DEFAULT_WORKER_NAME.equals(this.env.enclFunc.workerName.value); + boolean isOnSameStrand = DEFAULT_WORKER_NAME.equals(this.env.enclFunc.workerName.getValue()); this.env.enclBB.terminator = new BIRTerminator.WorkerReceive(workerReceive.pos, Names.fromString(workerReceive.getChannel().channelId()), lhsOp, isOnSameStrand, thenBB, @@ -1259,7 +1259,7 @@ public void visit(BLangWorkerAsyncSendExpr asyncSendExpr) { this.env.enclFunc.localVars.add(tempVarDcl); BIROperand lhsOp = new BIROperand(tempVarDcl); this.env.targetOperand = lhsOp; - boolean isOnSameStrand = DEFAULT_WORKER_NAME.equals(this.env.enclFunc.workerName.value); + boolean isOnSameStrand = DEFAULT_WORKER_NAME.equals(this.env.enclFunc.workerName.getValue()); this.env.enclBB.terminator = new BIRTerminator.WorkerSend( asyncSendExpr.pos, Names.fromString(asyncSendExpr.getChannel().channelId()), dataOp, isOnSameStrand, @@ -1282,7 +1282,7 @@ public void visit(BLangWorkerSyncSendExpr syncSend) { BIROperand lhsOp = new BIROperand(tempVarDcl); this.env.targetOperand = lhsOp; - boolean isOnSameStrand = DEFAULT_WORKER_NAME.equals(this.env.enclFunc.workerName.value); + boolean isOnSameStrand = DEFAULT_WORKER_NAME.equals(this.env.enclFunc.workerName.getValue()); this.env.enclBB.terminator = new BIRTerminator.WorkerSend( syncSend.pos, Names.fromString(syncSend.getChannel().channelId()), dataOp, isOnSameStrand, true, lhsOp, @@ -1300,7 +1300,7 @@ public void visit(BLangWorkerFlushExpr flushExpr) { //create channelDetails array BIRNode.ChannelDetails[] channels = new BIRNode.ChannelDetails[flushExpr.cachedWorkerSendStmts.size()]; int i = 0; - boolean isOnSameStrand = DEFAULT_WORKER_NAME.equals(this.env.enclFunc.workerName.value); + boolean isOnSameStrand = DEFAULT_WORKER_NAME.equals(this.env.enclFunc.workerName.getValue()); for (BLangWorkerAsyncSendExpr sendStmt : flushExpr.cachedWorkerSendStmts) { channels[i] = new BIRNode.ChannelDetails(sendStmt.getChannel().channelId(), isOnSameStrand, true); i++; @@ -1687,7 +1687,7 @@ public void visit(BLangTypeInit connectorInitExpr) { BIRTypeDefinition def = typeDefs.get(objectTypeSymbol); instruction = new BIRNonTerminator.NewInstance(connectorInitExpr.pos, def, toVarRef, objectType); } else { - String objectName = objectTypeSymbol.name.value; + String objectName = objectTypeSymbol.name.getValue(); instruction = new BIRNonTerminator.NewInstance(connectorInitExpr.pos, objectTypeSymbol.pkgID, objectName, toVarRef, objectType); } @@ -2394,7 +2394,7 @@ private void populateBirLockWithGlobalVars(BLangLockStmt lockStmt) { birGlobalVar = dummyGlobalVarMapForLocks.computeIfAbsent(globalVar, k -> new BIRGlobalVariableDcl(null, globalVar.flags, globalVar.type, globalVar.pkgID, globalVar.name, globalVar.getOriginalName(), VarScope.GLOBAL, - VarKind.GLOBAL, globalVar.name.value, + VarKind.GLOBAL, globalVar.name.getValue(), globalVar.origin.toBIROrigin())); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmCodeGenUtil.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmCodeGenUtil.java index 9792e04c39fb..76c2279d892e 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmCodeGenUtil.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmCodeGenUtil.java @@ -203,8 +203,8 @@ public static String rewriteVirtualCallTypeName(String value, BType objectType) objectType = getImpliedType(objectType); // The call name will be in the format of`objectTypeName.funcName` for attached functions of imported modules. // Therefore, We need to remove the type name. - if (!objectType.tsymbol.name.value.isEmpty() && value.startsWith(objectType.tsymbol.name.value)) { - value = value.replace(objectType.tsymbol.name.value + ".", "").trim(); + if (!objectType.tsymbol.name.getValue().isEmpty() && value.startsWith(objectType.tsymbol.name.getValue())) { + value = value.replace(objectType.tsymbol.name.getValue() + ".", "").trim(); } return Utils.encodeFunctionIdentifier(value); } @@ -281,16 +281,16 @@ public static String getPackageName(PackageID packageID) { private static String getPackageNameWithSeparator(PackageID packageID, String separator) { String packageName = ""; - String orgName = Utils.encodeNonFunctionIdentifier(packageID.orgName.value); + String orgName = Utils.encodeNonFunctionIdentifier(packageID.orgName.getValue()); String moduleName; if (!packageID.isTestPkg) { - moduleName = Utils.encodeNonFunctionIdentifier(packageID.name.value); + moduleName = Utils.encodeNonFunctionIdentifier(packageID.name.getValue()); } else { - moduleName = Utils.encodeNonFunctionIdentifier(packageID.name.value) + Names.TEST_PACKAGE.value; + moduleName = Utils.encodeNonFunctionIdentifier(packageID.name.getValue()) + Names.TEST_PACKAGE.getValue(); } if (!moduleName.equals(ENCODED_DOT_CHARACTER)) { - if (!packageID.version.value.isEmpty()) { - packageName = getMajorVersion(packageID.version.value) + separator; + if (!packageID.version.getValue().isEmpty()) { + packageName = getMajorVersion(packageID.version.getValue()) + separator; } packageName = moduleName + separator + packageName; } @@ -471,9 +471,9 @@ public static String toNameString(BType t) { if ((typeSymbol.kind == SymbolKind.RECORD || typeSymbol.kind == SymbolKind.OBJECT) && ((BStructureTypeSymbol) typeSymbol).typeDefinitionSymbol != null) { return Utils.encodeNonFunctionIdentifier(((BStructureTypeSymbol) typeSymbol) - .typeDefinitionSymbol.name.value); + .typeDefinitionSymbol.name.getValue()); } - return Utils.encodeNonFunctionIdentifier(typeSymbol.name.value); + return Utils.encodeNonFunctionIdentifier(typeSymbol.name.getValue()); } public static boolean isBallerinaBuiltinModule(String orgName, String moduleName) { @@ -487,7 +487,7 @@ public static BirScope getLastScopeFromBBInsGen(MethodVisitor mv, LabelGenerator int insCount = bb.instructions.size(); for (int i = 0; i < insCount; i++) { - Label insLabel = labelGen.getLabel(funcName + bb.id.value + "ins" + i); + Label insLabel = labelGen.getLabel(funcName + bb.id.getValue() + "ins" + i); mv.visitLabel(insLabel); BIRAbstractInstruction inst = bb.instructions.get(i); if (inst != null) { @@ -556,7 +556,7 @@ public static void genYieldCheck(MethodVisitor mv, LabelGenerator labelGen, BIRN mv.visitMethodInsn(INVOKEVIRTUAL, STRAND_CLASS, "isYielded", "()Z", false); generateSetYieldedStatus(mv, labelGen, funcName, yieldLocationVarIndex, terminatorPos, fullyQualifiedFuncName, yieldStatus, yieldStatusVarIndex); - Label gotoLabel = labelGen.getLabel(funcName + thenBB.id.value); + Label gotoLabel = labelGen.getLabel(funcName + thenBB.id.getValue()); mv.visitJumpInsn(GOTO, gotoLabel); } @@ -583,24 +583,25 @@ static void generateSetYieldedStatus(MethodVisitor mv, LabelGenerator labelGen, } public static PackageID cleanupPackageID(PackageID pkgID) { - Name org = new Name(Utils.encodeNonFunctionIdentifier(pkgID.orgName.value)); - Name module = new Name(Utils.encodeNonFunctionIdentifier(pkgID.name.value)); + Name org = new Name(Utils.encodeNonFunctionIdentifier(pkgID.orgName.getValue())); + Name module = new Name(Utils.encodeNonFunctionIdentifier(pkgID.name.getValue())); return new PackageID(org, module, pkgID.version); } public static boolean isBuiltInPackage(PackageID packageID) { packageID = cleanupPackageID(packageID); - return BALLERINA.equals(packageID.orgName.value) && BUILT_IN_PACKAGE_NAME.equals(packageID.name.value); + return BALLERINA.equals(packageID.orgName.getValue()) && + BUILT_IN_PACKAGE_NAME.equals(packageID.name.getValue()); } public static boolean isSameModule(PackageID moduleId, PackageID importModule) { PackageID cleanedPkg = cleanupPackageID(importModule); - if (!moduleId.orgName.value.equals(cleanedPkg.orgName.value)) { + if (!moduleId.orgName.getValue().equals(cleanedPkg.orgName.getValue())) { return false; - } else if (!moduleId.name.value.equals(cleanedPkg.name.value)) { + } else if (!moduleId.name.getValue().equals(cleanedPkg.name.getValue())) { return false; } else { - return getMajorVersion(moduleId.version.value).equals(getMajorVersion(cleanedPkg.version.value)); + return getMajorVersion(moduleId.version.getValue()).equals(getMajorVersion(cleanedPkg.version.getValue())); } } @@ -745,7 +746,7 @@ private JvmCodeGenUtil() { } public static String getRefTypeConstantName(BTypeReferenceType type) { - return JvmConstants.TYPEREF_TYPE_VAR_PREFIX + Utils.encodeNonFunctionIdentifier(type.tsymbol.name.value); + return JvmConstants.TYPEREF_TYPE_VAR_PREFIX + Utils.encodeNonFunctionIdentifier(type.tsymbol.name.getValue()); } public static void visitMaxStackForMethod(MethodVisitor mv, String funcName, String className) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmDesugarPhase.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmDesugarPhase.java index 7d00e3cf63ae..e647de3dab5f 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmDesugarPhase.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmDesugarPhase.java @@ -113,14 +113,14 @@ private static void rewriteRecordInitFunction(BIRFunction func, BRecordType reco // Rename the function name by appending the record name to it. // This done to avoid frame class name overlapping. - func.name = new Name(toNameString(recordType) + func.name.value); + func.name = new Name(toNameString(recordType) + func.name.getValue()); // change the kind of receiver to 'ARG' receiver.kind = VarKind.ARG; // Update the name of the reciever. Then any instruction that was refering to the receiver will // now refer to the injected parameter. - String paramName = "$_" + receiver.name.value; + String paramName = "$_" + receiver.name.getValue(); receiver.name = new Name(paramName); // Inject an additional parameter to accept the self-record value into the init function @@ -154,22 +154,22 @@ static HashMap encodeModuleIdentifiers(BIRNode.BIRPackage module } private static void encodePackageIdentifiers(PackageID packageID, HashMap encodedVsInitialIds) { - packageID.orgName = Names.fromString(encodeNonFunctionIdentifier(packageID.orgName.value, + packageID.orgName = Names.fromString(encodeNonFunctionIdentifier(packageID.orgName.getValue(), encodedVsInitialIds)); - packageID.name = Names.fromString(encodeNonFunctionIdentifier(packageID.name.value, encodedVsInitialIds)); + packageID.name = Names.fromString(encodeNonFunctionIdentifier(packageID.name.getValue(), encodedVsInitialIds)); } private static void encodeTypeDefIdentifiers(List typeDefs, HashMap encodedVsInitialIds) { for (BIRTypeDefinition typeDefinition : typeDefs) { typeDefinition.type.tsymbol.name = Names.fromString(encodeNonFunctionIdentifier( - typeDefinition.type.tsymbol.name.value, encodedVsInitialIds)); + typeDefinition.type.tsymbol.name.getValue(), encodedVsInitialIds)); typeDefinition.internalName = - Names.fromString(encodeNonFunctionIdentifier(typeDefinition.internalName.value, + Names.fromString(encodeNonFunctionIdentifier(typeDefinition.internalName.getValue(), encodedVsInitialIds)); if (typeDefinition.referenceType != null) { typeDefinition.referenceType.tsymbol.name = Names.fromString(encodeNonFunctionIdentifier( - typeDefinition.referenceType.tsymbol.name.value, encodedVsInitialIds)); + typeDefinition.referenceType.tsymbol.name.getValue(), encodedVsInitialIds)); } encodeFunctionIdentifiers(typeDefinition.attachedFuncs, encodedVsInitialIds); @@ -181,13 +181,15 @@ private static void encodeTypeDefIdentifiers(List typeDefs, encodeAttachedFunctionIdentifiers(objectTypeSymbol.attachedFuncs, encodedVsInitialIds); } for (BField field : objectType.fields.values()) { - field.name = Names.fromString(encodeNonFunctionIdentifier(field.name.value, encodedVsInitialIds)); + field.name = Names.fromString( + encodeNonFunctionIdentifier(field.name.getValue(), encodedVsInitialIds)); } } if (bType.tag == TypeTags.RECORD) { BRecordType recordType = (BRecordType) bType; for (BField field : recordType.fields.values()) { - field.name = Names.fromString(encodeNonFunctionIdentifier(field.name.value, encodedVsInitialIds)); + field.name = Names.fromString( + encodeNonFunctionIdentifier(field.name.getValue(), encodedVsInitialIds)); } } } @@ -196,7 +198,7 @@ private static void encodeTypeDefIdentifiers(List typeDefs, private static void encodeFunctionIdentifiers(List functions, HashMap encodedVsInitialIds) { for (BIRFunction function : functions) { - function.name = Names.fromString(encodeFunctionIdentifier(function.name.value, encodedVsInitialIds)); + function.name = Names.fromString(encodeFunctionIdentifier(function.name.getValue(), encodedVsInitialIds)); for (BIRNode.BIRVariableDcl localVar : function.localVars) { if (localVar.metaVarName == null) { continue; @@ -204,12 +206,12 @@ private static void encodeFunctionIdentifiers(List functions, localVar.metaVarName = encodeNonFunctionIdentifier(localVar.metaVarName, encodedVsInitialIds); } for (BIRNode.BIRParameter parameter : function.requiredParams) { - parameter.name = Names.fromString(encodeNonFunctionIdentifier(parameter.name.value, + parameter.name = Names.fromString(encodeNonFunctionIdentifier(parameter.name.getValue(), encodedVsInitialIds)); } if (function.type.tsymbol != null) { for (BVarSymbol parameter : ((BInvokableTypeSymbol) function.type.tsymbol).params) { - parameter.name = Names.fromString(encodeNonFunctionIdentifier(parameter.name.value, + parameter.name = Names.fromString(encodeNonFunctionIdentifier(parameter.name.getValue(), encodedVsInitialIds)); } } @@ -224,7 +226,7 @@ private static void encodeDefaultFunctionName(BInvokableType type, HashMap encodedVsInitialIds) { if (function.workerName != null) { - function.workerName = Names.fromString(encodeNonFunctionIdentifier(function.workerName.value, + function.workerName = Names.fromString(encodeNonFunctionIdentifier(function.workerName.getValue(), encodedVsInitialIds)); } } @@ -240,7 +242,7 @@ private static void encodeWorkerName(BIRFunction function, private static void encodeAttachedFunctionIdentifiers(List functions, HashMap encodedVsInitialIds) { for (BAttachedFunction function : functions) { - function.funcName = Names.fromString(encodeFunctionIdentifier(function.funcName.value, + function.funcName = Names.fromString(encodeFunctionIdentifier(function.funcName.getValue(), encodedVsInitialIds)); } } @@ -248,14 +250,16 @@ private static void encodeAttachedFunctionIdentifiers(List fu private static void encodeGlobalVariableIdentifiers(List globalVars, HashMap encodedVsInitialIds) { for (BIRNode.BIRGlobalVariableDcl globalVar : globalVars) { - globalVar.name = Names.fromString(encodeNonFunctionIdentifier(globalVar.name.value, encodedVsInitialIds)); + globalVar.name = Names.fromString( + encodeNonFunctionIdentifier(globalVar.name.getValue(), encodedVsInitialIds)); } } private static void encodeImportedGlobalVariableIdentifiers(Set globalVars, HashMap encodedVsInitialIds) { for (BIRNode.BIRGlobalVariableDcl globalVar : globalVars) { - globalVar.name = Names.fromString(encodeNonFunctionIdentifier(globalVar.name.value, encodedVsInitialIds)); + globalVar.name = Names.fromString( + encodeNonFunctionIdentifier(globalVar.name.getValue(), encodedVsInitialIds)); } } @@ -369,7 +373,7 @@ private static String encodeNonFunctionIdentifier(String identifier, HashMap encodedVsInitialIds) { - String initialString = encodedVsInitialIds.get(encodedIdString.value); + String initialString = encodedVsInitialIds.get(encodedIdString.getValue()); if (initialString != null) { return Names.fromString(initialString); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmErrorGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmErrorGen.java index c77ba0bd9e8f..a7792c44d0ab 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmErrorGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmErrorGen.java @@ -64,7 +64,7 @@ public JvmErrorGen(MethodVisitor mv, BIRVarToJVMIndexMap indexMap, JvmInstructio private BIRNode.BIRErrorEntry findErrorEntry(List errors, BIRNode.BIRBasicBlock currentBB) { for (BIRNode.BIRErrorEntry err : errors) { - if (err != null && err.endBB.id.value.equals(currentBB.id.value)) { + if (err != null && err.endBB.id.getValue().equals(currentBB.id.getValue())) { return err; } } @@ -88,7 +88,7 @@ public void generateTryCatch(BIRNode.BIRFunction func, String funcName, BIRNode. return; } - Label startLabel = labelGen.getLabel(funcName + currentEE.trapBB.id.value); + Label startLabel = labelGen.getLabel(funcName + currentEE.trapBB.id.getValue()); Label endLabel = new Label(); Label jumpLabel = new Label(); @@ -96,7 +96,7 @@ public void generateTryCatch(BIRNode.BIRFunction func, String funcName, BIRNode. this.mv.visitJumpInsn(GOTO, jumpLabel); if (currentEE instanceof JErrorEntry jCurrentEE) { BIRNode.BIRVariableDcl retVarDcl = currentEE.errorOp.variableDcl; - int retIndex = this.indexMap.addIfNotExists(retVarDcl.name.value, retVarDcl.type); + int retIndex = this.indexMap.addIfNotExists(retVarDcl.name.getValue(), retVarDcl.type); boolean exeptionExist = false; for (CatchIns catchIns : jCurrentEE.catchIns) { if (ERROR_VALUE.equals(catchIns.errorClass)) { @@ -138,7 +138,7 @@ public void generateTryCatch(BIRNode.BIRFunction func, String funcName, BIRNode. this.mv.visitLabel(errorValueLabel); BIRNode.BIRVariableDcl varDcl = currentEE.errorOp.variableDcl; - int lhsIndex = this.indexMap.addIfNotExists(varDcl.name.value, varDcl.type); + int lhsIndex = this.indexMap.addIfNotExists(varDcl.name.getValue(), varDcl.type); jvmInstructionGen.generateVarStore(this.mv, varDcl, lhsIndex); this.mv.visitJumpInsn(GOTO, jumpLabel); this.mv.visitLabel(otherErrorLabel); @@ -149,6 +149,6 @@ public void generateTryCatch(BIRNode.BIRFunction func, String funcName, BIRNode. } private int getJVMIndexOfVarRef(BIRNode.BIRVariableDcl varDcl) { - return this.indexMap.addIfNotExists(varDcl.name.value, varDcl.type); + return this.indexMap.addIfNotExists(varDcl.name.getValue(), varDcl.type); } } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java index 1f18e04c03ae..367289f5b064 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmInstructionGen.java @@ -395,7 +395,7 @@ public void generateVarLoad(MethodVisitor mv, BIRNode.BIRVariableDcl varDcl, int return; } case CONSTANT, GLOBAL -> { - String varName = varDcl.name.value; + String varName = varDcl.name.getValue(); PackageID moduleId = ((BIRNode.BIRGlobalVariableDcl) varDcl).pkgId; String pkgName = JvmCodeGenUtil.getPackageName(moduleId); String className = jvmPackageGen.lookupGlobalVarClassName(pkgName, varName); @@ -443,7 +443,7 @@ public void generateVarStore(MethodVisitor mv, BIRNode.BIRVariableDcl varDcl, in BType bType = JvmCodeGenUtil.getImpliedType(varDcl.type); if (varDcl.kind == VarKind.GLOBAL || varDcl.kind == VarKind.CONSTANT) { - String varName = varDcl.name.value; + String varName = varDcl.name.getValue(); PackageID moduleId = ((BIRNode.BIRGlobalVariableDcl) varDcl).pkgId; String pkgName = JvmCodeGenUtil.getPackageName(moduleId); String className = jvmPackageGen.lookupGlobalVarClassName(pkgName, varName); @@ -1224,7 +1224,7 @@ private void generateBitwiseUnsignedRightShiftIns(BIRNonTerminator.BinaryOp bina } private int getJVMIndexOfVarRef(BIRNode.BIRVariableDcl varDcl) { - return this.indexMap.addIfNotExists(varDcl.name.value, varDcl.type); + return this.indexMap.addIfNotExists(varDcl.name.getValue(), varDcl.type); } void generateMapNewIns(BIRNonTerminator.NewStructure mapNewIns, int localVarOffset) { @@ -1636,7 +1636,7 @@ void generateObjectNewIns(BIRNonTerminator.NewInstance objectNewIns, int strandI objectNewIns.objectName); } else { className = getTypeValueClassName(JvmCodeGenUtil.getPackageName(type.tsymbol.pkgID), - objectNewIns.def.internalName.value); + objectNewIns.def.internalName.getValue()); } this.mv.visitTypeInsn(NEW, className); @@ -1668,7 +1668,7 @@ private void reloadObjectCtorAnnots(BType type, int strandIndex) { void generateFPLoadIns(BIRNonTerminator.FPLoad inst) { this.mv.visitTypeInsn(NEW, FUNCTION_POINTER); this.mv.visitInsn(DUP); - String name = inst.funcName.value; + String name = inst.funcName.getValue(); String funcKey = inst.pkgId.toString() + ":" + name; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmPackageGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmPackageGen.java index f6316475a157..e25b62412d1c 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmPackageGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmPackageGen.java @@ -115,11 +115,11 @@ import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.MODULE_INIT_CLASS_NAME; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.MODULE_STARTED; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.MODULE_START_ATTEMPTED; -import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.PARENT_MODULE_START_ATTEMPTED; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.MODULE_STOP_METHOD; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.MODULE_TYPES_CLASS_NAME; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.NO_OF_DEPENDANT_MODULES; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.OBJECT; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.PARENT_MODULE_START_ATTEMPTED; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.SERVICE_EP_AVAILABLE; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.TEST_EXECUTE_METHOD; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.VALUE_CREATOR; @@ -169,7 +169,7 @@ public class JvmPackageGen { } private static String getBvmAlias(String orgName, String moduleName) { - if (Names.ANON_ORG.value.equals(orgName)) { + if (Names.ANON_ORG.getValue().equals(orgName)) { return moduleName; } return orgName + "/" + moduleName; @@ -219,15 +219,15 @@ private static void addBuiltinImports(PackageID currentModule, Set de } public static boolean isLangModule(PackageID moduleId) { - if (!BALLERINA.equals(moduleId.orgName.value)) { + if (!BALLERINA.equals(moduleId.orgName.getValue())) { return false; } - return moduleId.name.value.startsWith("lang" + ENCODED_DOT_CHARACTER) || - moduleId.name.value.equals(ENCODED_JAVA_MODULE); + return moduleId.name.getValue().startsWith("lang" + ENCODED_DOT_CHARACTER) || + moduleId.name.getValue().equals(ENCODED_JAVA_MODULE); } private static void generatePackageVariable(BIRGlobalVariableDcl globalVar, ClassWriter cw) { - String varName = globalVar.name.value; + String varName = globalVar.name.getValue(); BType bType = globalVar.type; String descriptor = JvmCodeGenUtil.getFieldTypeSignature(bType); FieldVisitor fv = cw.visitField(ACC_PUBLIC + ACC_STATIC, varName, descriptor, null, null); @@ -363,7 +363,7 @@ private static BIRFunction findFunction(BIRNode parentNode, String funcName) { private static BIRFunction findFunction(List functions, String funcName) { for (BIRFunction func : functions) { - if (func.name.value.equals(funcName)) { + if (func.name.getValue().equals(funcName)) { return func; } } @@ -474,7 +474,7 @@ private void linkGlobalVars(BIRPackage module, String initClass, boolean isEntry String pkgName = JvmCodeGenUtil.getPackageName(module.packageID); for (BIRGlobalVariableDcl globalVar : module.globalVars) { if (globalVar != null) { - globalVarClassMap.put(pkgName + globalVar.name.value, initClass); + globalVarClassMap.put(pkgName + globalVar.name.getValue(), initClass); } } @@ -497,7 +497,7 @@ private void linkTypeDefinitions(BIRPackage module, boolean isEntry) { for (BIRFunction func : attachedFuncs) { // link the bir function for lookup - String functionName = func.name.value; + String functionName = func.name.getValue(); String lookupKey = typeName + "." + functionName; String pkgName = JvmCodeGenUtil.getPackageName(module.packageID); String className = JvmValueGen.getTypeValueClassName(pkgName, typeName); @@ -533,7 +533,7 @@ private void linkModuleFunctions(BIRPackage birPackage, String initClass, boolea // Generate init class. Init function should be the first function of the package, hence check first // function. BIRFunction initFunc = functions.get(0); - String functionName = Utils.encodeFunctionIdentifier(initFunc.name.value); + String functionName = Utils.encodeFunctionIdentifier(initFunc.name.getValue()); String fileName = initFunc.pos.lineRange().fileName(); JavaClass klass = new JavaClass(fileName, fileName); klass.functions.add(0, initFunc); @@ -545,14 +545,14 @@ private void linkModuleFunctions(BIRPackage birPackage, String initClass, boolea // Add start function BIRFunction startFunc = functions.get(1); - functionName = Utils.encodeFunctionIdentifier(startFunc.name.value); + functionName = Utils.encodeFunctionIdentifier(startFunc.name.getValue()); birFunctionMap.put(pkgName + functionName, getFunctionWrapper(startFunc, packageID, initClass)); klass.functions.add(1, startFunc); count += 1; // Add stop function BIRFunction stopFunc = functions.get(2); - functionName = Utils.encodeFunctionIdentifier(stopFunc.name.value); + functionName = Utils.encodeFunctionIdentifier(stopFunc.name.getValue()); birFunctionMap.put(pkgName + functionName, getFunctionWrapper(stopFunc, packageID, initClass)); klass.functions.add(2, stopFunc); count += 1; @@ -564,7 +564,7 @@ private void linkModuleFunctions(BIRPackage birPackage, String initClass, boolea BIRFunction birFunc = functions.get(count); count = count + 1; // link the bir function for lookup - String birFuncName = birFunc.name.value; + String birFuncName = birFunc.name.getValue(); String balFileName; if (birFunc.pos == symbolTable.builtinPos) { balFileName = MODULE_INIT_CLASS_NAME; @@ -581,14 +581,14 @@ private void linkModuleFunctions(BIRPackage birPackage, String initClass, boolea } String cleanedBalFileName = balFileName; - if (!birFunc.name.value.startsWith(MethodGenUtils.encodeModuleSpecialFuncName(".` brakes because, // it's "file name" may end in `.bal` due to module. see #27201 cleanedBalFileName = JvmCodeGenUtil.cleanupPathSeparators(balFileName); } String birModuleClassName = getModuleLevelClassName(packageID, cleanedBalFileName); - if (!JvmCodeGenUtil.isBallerinaBuiltinModule(packageID.orgName.value, packageID.name.value)) { + if (!JvmCodeGenUtil.isBallerinaBuiltinModule(packageID.orgName.getValue(), packageID.name.getValue())) { JavaClass javaClass = jvmClassMap.get(birModuleClassName); if (javaClass != null) { javaClass.functions.add(birFunc); @@ -632,7 +632,7 @@ public byte[] getBytes(ClassWriter cw, BIRNode node) { BIRFunction func = findFunction(node, funcName); if (func != null && func.pos != null) { dlog.error(func.pos, DiagnosticErrorCode.METHOD_TOO_LARGE, - Utils.decodeIdentifier(func.name.value)); + Utils.decodeIdentifier(func.name.getValue())); } else { dlog.error(node.pos, DiagnosticErrorCode.METHOD_TOO_LARGE, Utils.decodeIdentifier(funcName)); @@ -699,7 +699,7 @@ CompiledJarFile generate(BIRPackage module) { boolean serviceEPAvailable = module.isListenerAvailable; for (BIRNode.BIRImportModule importModule : module.importModules) { BPackageSymbol pkgSymbol = packageCache.getSymbol( - getBvmAlias(importModule.packageID.orgName.value, importModule.packageID.name.value)); + getBvmAlias(importModule.packageID.orgName.getValue(), importModule.packageID.name.getValue())); if (pkgSymbol.bir != null) { String moduleInitClass = JvmCodeGenUtil.getModuleLevelClassName(pkgSymbol.bir.packageID, MODULE_INIT_CLASS_NAME); @@ -727,7 +727,8 @@ CompiledJarFile generate(BIRPackage module) { addBuiltinImports(module.packageID, immediateImports); for (BIRNode.BIRImportModule immediateImport : module.importModules) { BPackageSymbol pkgSymbol = packageCache.getSymbol( - getBvmAlias(immediateImport.packageID.orgName.value, immediateImport.packageID.name.value)); + getBvmAlias(immediateImport.packageID.orgName.getValue(), + immediateImport.packageID.name.getValue())); immediateImports.add(pkgSymbol.pkgID); } @@ -799,7 +800,7 @@ private BIRFunction getTestExecuteFunction(BIRPackage module) { private BIRFunction getFunction(BIRPackage module, String funcName) { BIRFunction function = null; for (BIRFunction birFunc : module.functions) { - if (birFunc.name.value.equals(funcName)) { + if (birFunc.name.getValue().equals(funcName)) { function = birFunc; break; } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTerminatorGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTerminatorGen.java index 27938d6c9f82..1c037923e055 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTerminatorGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTerminatorGen.java @@ -129,7 +129,6 @@ import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.LOCK_VALUE; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.MAKE_CONCAT_WITH_CONSTANTS; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.MAP; -import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.MODULE_INITIALIZER; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.MODULE_INIT_CLASS_NAME; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.OBJECT; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.PANIC_FIELD; @@ -190,6 +189,7 @@ import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.LOAD_JOBJECT_TYPE; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.LOCK; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.MAP_PUT; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.MODULE_INITIALIZER; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.MULTIPLE_RECEIVE_CALL; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.PANIC_IF_IN_LOCK; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmSignatures.PASS_OBJECT_RETURN_OBJECT; @@ -352,7 +352,7 @@ private void genGoToTerm(BIRTerminator.GOTO gotoIns, String funcName, BIRNode.BI int currentBBNumber = currentBB.number; int gotoBBNumber = gotoIns.targetBB.number; if (currentBBNumber <= gotoBBNumber) { - Label gotoLabel = this.labelGen.getLabel(funcName + gotoIns.targetBB.id.value); + Label gotoLabel = this.labelGen.getLabel(funcName + gotoIns.targetBB.id.getValue()); this.mv.visitJumpInsn(GOTO, gotoLabel); return; } @@ -366,7 +366,7 @@ private void genGoToTerm(BIRTerminator.GOTO gotoIns, String funcName, BIRNode.BI private void genLockTerm(BIRTerminator.Lock lockIns, String funcName, int localVarOffset, int yieldLocationVarIndex, Location terminatorPos, String fullyQualifiedFuncName, int yieldStatusVarIndex) { - Label gotoLabel = this.labelGen.getLabel(funcName + lockIns.lockedBB.id.value); + Label gotoLabel = this.labelGen.getLabel(funcName + lockIns.lockedBB.id.getValue()); String lockStore = "L" + LOCK_STORE + ";"; String initClassName = jvmPackageGen.lookupGlobalVarClassName(this.currentPackageName, LOCK_STORE_VAR_NAME); String lockName = GLOBAL_LOCK_NAME + lockIns.lockId; @@ -383,7 +383,7 @@ private void genLockTerm(BIRTerminator.Lock lockIns, String funcName, int localV private void genUnlockTerm(BIRTerminator.Unlock unlockIns, String funcName) { - Label gotoLabel = this.labelGen.getLabel(funcName + unlockIns.unlockBB.id.value); + Label gotoLabel = this.labelGen.getLabel(funcName + unlockIns.unlockBB.id.getValue()); // unlocked in the same order https://yarchive.net/comp/linux/lock_ordering.html String lockStore = "L" + LOCK_STORE + ";"; @@ -436,9 +436,9 @@ private void notifyChannels(List channels, int retIndex, private void genBranchTerm(BIRTerminator.Branch branchIns, String funcName) { this.loadVar(branchIns.op.variableDcl); - Label trueBBLabel = this.labelGen.getLabel(funcName + branchIns.trueBB.id.value); + Label trueBBLabel = this.labelGen.getLabel(funcName + branchIns.trueBB.id.getValue()); this.mv.visitJumpInsn(IFGT, trueBBLabel); - Label falseBBLabel = this.labelGen.getLabel(funcName + branchIns.falseBB.id.value); + Label falseBBLabel = this.labelGen.getLabel(funcName + branchIns.falseBB.id.getValue()); this.mv.visitJumpInsn(GOTO, falseBBLabel); } @@ -629,7 +629,7 @@ private void genJICallTerm(JIMethodCall callIns, int localVarOffset, BIRNode.BIR } if (callIns.varArgExist) { BIROperand arg = callIns.args.get(argIndex); - int localVarIndex = this.indexMap.addIfNotExists(arg.variableDcl.name.value, arg.variableDcl.type); + int localVarIndex = this.indexMap.addIfNotExists(arg.variableDcl.name.getValue(), arg.variableDcl.type); genVarArg(this.mv, this.indexMap, arg.variableDcl.type, callIns.varArgType, localVarIndex, symbolTable, jvmCastGen); } @@ -759,13 +759,13 @@ private void genCall(BIRTerminator.Call callIns, PackageID packageID, int localV } private void genFuncCall(BIRTerminator.Call callIns, PackageID packageID, int localVarOffset) { - String methodName = callIns.name.value; + String methodName = callIns.name.getValue(); this.genStaticCall(callIns, packageID, localVarOffset, methodName, methodName); } private void genBuiltinTypeAttachedFuncCall(BIRTerminator.Call callIns, PackageID packageID, int localVarOffset) { - String methodLookupName = callIns.name.value; + String methodLookupName = callIns.name.getValue(); int optionalIndex = methodLookupName.indexOf("."); int index = optionalIndex != -1 ? optionalIndex + 1 : 0; String methodName = methodLookupName.substring(index); @@ -803,7 +803,7 @@ private void genStaticCall(BIRTerminator.Call callIns, PackageID packageID, int packageID.orgName.getValue() + "/" + packageID.name.getValue()); Name decodedMethodName = new Name(Utils.decodeIdentifier(methodName)); BInvokableSymbol funcSymbol = (BInvokableSymbol) symbol.scope.lookup(decodedMethodName).symbol; - if (funcSymbol == null && JvmCodeGenUtil.isModuleInitializerMethod(decodedMethodName.value)) { + if (funcSymbol == null && JvmCodeGenUtil.isModuleInitializerMethod(decodedMethodName.getValue())) { // moduleInit() and moduleStart() functions are not present in the BIR cache because they are generated // in CodeGen phase. Therefore, they are not found inside the packageSymbol scope. jvmClass = JvmCodeGenUtil.getModuleLevelClassName(packageID, @@ -841,7 +841,7 @@ private void genVirtualCall(BIRTerminator.Call callIns, int localVarOffset) { this.mv.visitVarInsn(ALOAD, localVarOffset); // load the function name as the second argument - this.mv.visitLdcInsn(JvmCodeGenUtil.rewriteVirtualCallTypeName(callIns.name.value, selfArg.type)); + this.mv.visitLdcInsn(JvmCodeGenUtil.rewriteVirtualCallTypeName(callIns.name.getValue(), selfArg.type)); // create an Object[] for the rest params int argsCount = callIns.args.size() - 1; this.mv.visitLdcInsn((long) (argsCount)); @@ -905,7 +905,7 @@ private void genAsyncCallTerm(BIRTerminator.AsyncCall callIns, int localVarOffse paramIndex += 1; } - LambdaFunction lambdaFunction = asyncDataCollector.addAndGetLambda(callIns.name.value, callIns, true); + LambdaFunction lambdaFunction = asyncDataCollector.addAndGetLambda(callIns.name.getValue(), callIns, true); JvmCodeGenUtil.createFunctionPointer(this.mv, lambdaFunction.enclosingClass, lambdaFunction.lambdaName); boolean concurrent = false; @@ -914,7 +914,7 @@ private void genAsyncCallTerm(BIRTerminator.AsyncCall callIns, int localVarOffse if (!callIns.annotAttachments.isEmpty()) { for (BIRNode.BIRAnnotationAttachment annotationAttachment : callIns.annotAttachments) { if (annotationAttachment == null || - !STRAND.equals(annotationAttachment.annotTagRef.value) || + !STRAND.equals(annotationAttachment.annotTagRef.getValue()) || !JvmCodeGenUtil.isBuiltInPackage(annotationAttachment.annotPkgId)) { continue; } @@ -1149,7 +1149,7 @@ private void genWorkerSendIns(BIRTerminator.WorkerSend ins, int localVarOffset, this.mv.visitInvokeDynamicInsn(MAKE_CONCAT_WITH_CONSTANTS, INT_TO_STRING, new Handle(H_INVOKESTATIC, STRING_CONCAT_FACTORY, MAKE_CONCAT_WITH_CONSTANTS, HANDLE_DESCRIPTOR_FOR_STRING_CONCAT, false), - ins.channel.value + START_OF_HEADING_WITH_SEMICOLON); + ins.channel.getValue() + START_OF_HEADING_WITH_SEMICOLON); this.mv.visitMethodInsn(INVOKEVIRTUAL, WD_CHANNELS, "getWorkerDataChannel", GET_WORKER_DATA_CHANNEL, false); this.loadVar(ins.data.variableDcl); jvmCastGen.addBoxInsn(this.mv, ins.data.variableDcl.type); @@ -1251,7 +1251,7 @@ private void genWorkerReceiveIns(BIRTerminator.WorkerReceive ins, int localVarOf this.mv.visitInvokeDynamicInsn(MAKE_CONCAT_WITH_CONSTANTS, INT_TO_STRING, new Handle(H_INVOKESTATIC, STRING_CONCAT_FACTORY, MAKE_CONCAT_WITH_CONSTANTS, HANDLE_DESCRIPTOR_FOR_STRING_CONCAT, false), - ins.workerName.value + START_OF_HEADING_WITH_SEMICOLON); + ins.workerName.getValue() + START_OF_HEADING_WITH_SEMICOLON); this.mv.visitMethodInsn(INVOKEVIRTUAL, WD_CHANNELS, "getWorkerDataChannel", GET_WORKER_DATA_CHANNEL, false); this.mv.visitVarInsn(ALOAD, localVarOffset); @@ -1290,7 +1290,7 @@ private void submitToScheduler(BIROperand lhsOp, BType attachedType, String pare String metaDataVarName; if (attachedType != null) { - metaDataVarName = setAndGetStrandMetadataVarName(attachedType.tsymbol.name.value, parentFunction, + metaDataVarName = setAndGetStrandMetadataVarName(attachedType.tsymbol.name.getValue(), parentFunction, asyncDataCollector); } else { metaDataVarName = JvmCodeGenUtil.setAndGetStrandMetadataVarName(parentFunction, asyncDataCollector); @@ -1330,7 +1330,7 @@ private void loadFpReturnType(BIROperand lhsOp) { } private int getJVMIndexOfVarRef(BIRNode.BIRVariableDcl varDcl) { - return this.indexMap.addIfNotExists(varDcl.name.value, varDcl.type); + return this.indexMap.addIfNotExists(varDcl.name.getValue(), varDcl.type); } private void loadVar(BIRNode.BIRVariableDcl varDcl) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeGen.java index e6d31db01347..f150f2207313 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeGen.java @@ -231,7 +231,7 @@ void generateUserDefinedTypeFields(ClassWriter cw, List typeD // do not generate anything for other types (e.g.: finite type, type reference types etc.) continue; } - String name = typeDef.internalName.value; + String name = typeDef.internalName.getValue(); generateTypeField(cw, name); generateTypedescField(cw, name); } @@ -730,7 +730,7 @@ private void loadIntersectionType(MethodVisitor mv, BIntersectionType bType) { mv.visitTypeInsn(NEW, INTERSECTION_TYPE_IMPL); mv.visitInsn(DUP); - mv.visitLdcInsn(Utils.decodeIdentifier(bType.tsymbol.name.value)); + mv.visitLdcInsn(Utils.decodeIdentifier(bType.tsymbol.name.getValue())); String varName = jvmConstantsGen.getModuleConstantVar(bType.tsymbol.pkgID); mv.visitFieldInsn(GETSTATIC, jvmConstantsGen.getModuleConstantClass(), varName, GET_MODULE); // Create the constituent types array. @@ -785,9 +785,9 @@ private void loadUserDefinedType(MethodVisitor mv, BType bType) { String typeOwner = JvmCodeGenUtil.getPackageName(pkgID) + MODULE_INIT_CLASS_NAME; String defName = ""; if ((typeSymbol.kind == SymbolKind.RECORD || typeSymbol.kind == SymbolKind.OBJECT) - && typeSymbol.name.value.isEmpty()) { - defName = Utils - .encodeNonFunctionIdentifier(((BStructureTypeSymbol) typeSymbol).typeDefinitionSymbol.name.value); + && typeSymbol.name.getValue().isEmpty()) { + defName = Utils.encodeNonFunctionIdentifier( + ((BStructureTypeSymbol) typeSymbol).typeDefinitionSymbol.name.getValue()); } //class symbols String fieldName = defName.isEmpty() ? getTypeFieldName(toNameString(typeToLoad)) : defName; @@ -906,18 +906,18 @@ private void populateFunctionParameters(MethodVisitor mv, BInvokableTypeSymbol i mv.visitInsn(L2I); mv.visitTypeInsn(NEW, FUNCTION_PARAMETER); mv.visitInsn(DUP); - mv.visitLdcInsn(paramSymbol.name.value); + mv.visitLdcInsn(paramSymbol.name.getValue()); if (paramSymbol.isDefaultable) { mv.visitInsn(ICONST_1); } else { mv.visitInsn(ICONST_0); } BInvokableSymbol bInvokableSymbol = invokableSymbol.defaultValues.get( - Utils.decodeIdentifier(paramSymbol.name.value)); + Utils.decodeIdentifier(paramSymbol.name.getValue())); if (bInvokableSymbol == null) { mv.visitInsn(ACONST_NULL); } else { - mv.visitLdcInsn(bInvokableSymbol.name.value); + mv.visitLdcInsn(bInvokableSymbol.name.getValue()); } loadType(mv, paramSymbol.type); mv.visitMethodInsn(INVOKESPECIAL, FUNCTION_PARAMETER, JVM_INIT_METHOD, INIT_FUNCTION_PARAM, false); @@ -1013,7 +1013,7 @@ private void loadFiniteType(MethodVisitor mv, BFiniteType finiteType) { String name = Utils.decodeIdentifier(toNameString(finiteType)); mv.visitLdcInsn(name); // load original type name - mv.visitLdcInsn(finiteType.tsymbol.originalName.value); + mv.visitLdcInsn(finiteType.tsymbol.originalName.getValue()); mv.visitTypeInsn(NEW, LINKED_HASH_SET); mv.visitInsn(DUP); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeTestGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeTestGen.java index cd3a61752802..0fd50ef0968a 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeTestGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmTypeTestGen.java @@ -68,7 +68,7 @@ void generateTypeTestIns(BIRNonTerminator.TypeTest typeTestIns) { // instanceof operator. if (canOptimizeNilCheck(sourceType, targetType) || canOptimizeNilUnionCheck(sourceType, targetType) || - sourceValue.name.value.startsWith(MAIN_ARG_VAR_PREFIX)) { + sourceValue.name.getValue().startsWith(MAIN_ARG_VAR_PREFIX)) { handleNilUnionType(typeTestIns); return; } @@ -146,7 +146,7 @@ private boolean canOptimizeErrorCheck(BType sourceType, BType targetType) { } } return (foundError == 1 && types.isAssignable(errorType, targetType)) || (foundError > 0 && "error".equals( - targetType.tsymbol.name.value)); + targetType.tsymbol.name.getValue())); } /** diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmValueGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmValueGen.java index f0802f68060d..a1bb8818dd46 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmValueGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/JvmValueGen.java @@ -190,8 +190,8 @@ void generateValueClasses(JarEntries jarEntries, JvmConstantsGen jvmConstantsGen return; } BType bType = optionalTypeDef.type; - String className = getTypeValueClassName(packageName, optionalTypeDef.internalName.value); - String valueClass = VALUE_CLASS_PREFIX + optionalTypeDef.internalName.value; + String className = getTypeValueClassName(packageName, optionalTypeDef.internalName.getValue()); + String valueClass = VALUE_CLASS_PREFIX + optionalTypeDef.internalName.getValue(); asyncDataCollector.setCurrentSourceFileName(valueClass); asyncDataCollector.setCurrentSourceFileWithoutExt(valueClass); if (optionalTypeDef.type.tag == TypeTags.OBJECT && @@ -204,7 +204,7 @@ void generateValueClasses(JarEntries jarEntries, JvmConstantsGen jvmConstantsGen byte[] bytes = this.createRecordValueClass(recordType, className, optionalTypeDef, asyncDataCollector, jvmTypeGen); jarEntries.put(className + CLASS_FILE_SUFFIX, bytes); - String typedescClass = getTypeDescClassName(packageName, optionalTypeDef.internalName.value); + String typedescClass = getTypeDescClassName(packageName, optionalTypeDef.internalName.getValue()); bytes = this.createRecordTypeDescClass(recordType, typedescClass, optionalTypeDef, jvmTypeGen); jarEntries.put(typedescClass + CLASS_FILE_SUFFIX, bytes); } @@ -316,7 +316,7 @@ private byte[] createRecordValueClass(BRecordType recordType, String className, jvmRecordGen.createAndSplitContainsKeyMethod(cw, fields, className); jvmRecordGen.createAndSplitGetValuesMethod(cw, fields, className, jvmCastGen); this.createGetSizeMethod(cw, fields, className); - this.createRecordClearMethod(cw, typeDef.name.value); + this.createRecordClearMethod(cw, typeDef.name.getValue()); jvmRecordGen.createAndSplitRemoveMethod(cw, fields, className, jvmCastGen); jvmRecordGen.createAndSplitGetKeysMethod(cw, fields, className); this.createRecordPopulateInitialValuesMethod(cw, className); @@ -393,7 +393,7 @@ private void createRecordFields(ClassWriter cw, Map fields) { if (field == null) { continue; } - String fieldName = field.name.value; + String fieldName = field.name.getValue(); FieldVisitor fv = cw.visitField(0, fieldName, getTypeDesc(field.type), null, null); fv.visitEnd(); @@ -418,7 +418,7 @@ private void createGetSizeMethod(ClassWriter cw, Map fields, Str int requiredFieldsCount = 0; for (BField optionalField : fields.values()) { - String fieldName = optionalField.name.value; + String fieldName = optionalField.name.getValue(); if (isOptionalRecordField(optionalField)) { mv.visitVarInsn(ALOAD, 0); mv.visitFieldInsn(GETFIELD, className, getFieldIsPresentFlagName(fieldName), @@ -490,10 +490,10 @@ private void createObjectFields(ClassWriter cw, Map fields) { if (field == null) { continue; } - FieldVisitor fvb = cw.visitField(0, field.name.value, getTypeDesc(field.type), null, null); + FieldVisitor fvb = cw.visitField(0, field.name.getValue(), getTypeDesc(field.type), null, null); fvb.visitEnd(); String lockClass = "L" + LOCK_VALUE + ";"; - FieldVisitor fv = cw.visitField(ACC_PUBLIC, computeLockNameFromString(field.name.value), + FieldVisitor fv = cw.visitField(ACC_PUBLIC, computeLockNameFromString(field.name.getValue()), lockClass, null, null); fv.visitEnd(); } @@ -524,7 +524,7 @@ private void createObjectMethodsWithSplitClasses(ClassWriter cw, List fields, String mv.visitTypeInsn(NEW, LOCK_VALUE); mv.visitInsn(DUP); mv.visitMethodInsn(INVOKESPECIAL, LOCK_VALUE, JVM_INIT_METHOD, VOID_METHOD_DESC, false); - mv.visitFieldInsn(PUTFIELD, className, computeLockNameFromString(field.name.value), lockClass); + mv.visitFieldInsn(PUTFIELD, className, computeLockNameFromString(field.name.getValue()), lockClass); } mv.visitInsn(RETURN); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/internal/FieldNameHashComparator.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/internal/FieldNameHashComparator.java index ab6a4db5d4ac..567d7d79a222 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/internal/FieldNameHashComparator.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/internal/FieldNameHashComparator.java @@ -32,8 +32,8 @@ public class FieldNameHashComparator implements Comparator { @Override public int compare(NamedNode o1, NamedNode o2) { - String name1 = Utils.decodeIdentifier(o1.getName().value); - String name2 = Utils.decodeIdentifier(o2.getName().value); + String name1 = Utils.decodeIdentifier(o1.getName().getValue()); + String name2 = Utils.decodeIdentifier(o2.getName().getValue()); return Integer.compare(name1.hashCode(), name2.hashCode()); } } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/internal/FunctionParamComparator.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/internal/FunctionParamComparator.java index 55bb1b2450d0..0e8a902ce701 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/internal/FunctionParamComparator.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/internal/FunctionParamComparator.java @@ -35,7 +35,7 @@ public int compare(BIRNode.BIRVariableDcl o1, BIRNode.BIRVariableDcl o2) { return Integer.compare(getWeight(o1), getWeight(o2)); } if (o1.kind == VarKind.TEMP) { - return Integer.compare(o1.name.value.hashCode(), o2.name.value.hashCode()); + return Integer.compare(o1.name.getValue().hashCode(), o2.name.getValue().hashCode()); } return 0; } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/internal/NameHashComparator.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/internal/NameHashComparator.java index f2ba568c7512..d1818a7165f3 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/internal/NameHashComparator.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/internal/NameHashComparator.java @@ -30,8 +30,8 @@ public class NameHashComparator implements Comparator { @Override public int compare(NamedNode o1, NamedNode o2) { - String name1 = o1.getName().value; - String name2 = o2.getName().value; + String name1 = o1.getName().getValue(); + String name2 = o2.getName().getValue(); return Integer.compare(name1.hashCode(), name2.hashCode()); } } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/interop/AnnotationProc.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/interop/AnnotationProc.java index bba8a1a8a9b1..8cadebf11e77 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/interop/AnnotationProc.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/interop/AnnotationProc.java @@ -60,7 +60,7 @@ static InteropValidationRequest getInteropAnnotValue(BIRFunction birFunc) { return null; } - String annotTagRef = annotAttach.annotTagRef.value; + String annotTagRef = annotAttach.annotTagRef.getValue(); return createJInteropValidationRequest(annotTagRef, annotAttach, birFunc); } @@ -76,9 +76,9 @@ private static BIRAnnotationAttachment getInteropAnnotAttachment(BIRFunction bir private static boolean isInteropAnnotAttachment(BIRAnnotationAttachment annotAttach) { - return INTEROP_ANNOT_ORG.equals(annotAttach.annotPkgId.orgName.value) && - INTEROP_ANNOT_MODULE.equals(annotAttach.annotPkgId.name.value) && - isInteropAnnotationTag(annotAttach.annotTagRef.value); + return INTEROP_ANNOT_ORG.equals(annotAttach.annotPkgId.orgName.getValue()) && + INTEROP_ANNOT_MODULE.equals(annotAttach.annotPkgId.name.getValue()) && + isInteropAnnotationTag(annotAttach.annotTagRef.getValue()); } private static InteropValidationRequest createJInteropValidationRequest(String annotTagRef, @@ -177,7 +177,7 @@ private static String getJMethodNameFromAnnot(String annotTagRef, return JVM_INIT_METHOD; } else { String methodName = (String) getLiteralValueFromAnnotValue(jNameValueEntry); - return methodName != null ? methodName : birFunc.name.value; + return methodName != null ? methodName : birFunc.name.getValue(); } } @@ -185,6 +185,6 @@ private static String getJFieldNameFromAnnot(BIRNode.ConstValue jNameValueEntry, BIRFunction birFunc) { String fieldName = (String) getLiteralValueFromAnnotValue(jNameValueEntry); - return fieldName != null ? fieldName : birFunc.name.value; + return fieldName != null ? fieldName : birFunc.name.getValue(); } } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/interop/InteropMethodGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/interop/InteropMethodGen.java index 4d30424e3221..8e7e6281996e 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/interop/InteropMethodGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/interop/InteropMethodGen.java @@ -147,7 +147,7 @@ static void genJFieldForInteropField(JFieldBIRFunction birFunc, ClassWriter clas String desc = JvmCodeGenUtil.getMethodDesc(birFunc.type.paramTypes, retType); int access = birFunc.receiver != null ? ACC_PUBLIC : ACC_PUBLIC + ACC_STATIC; - MethodVisitor mv = classWriter.visitMethod(access, birFunc.name.value, desc, null, null); + MethodVisitor mv = classWriter.visitMethod(access, birFunc.name.getValue(), desc, null, null); JvmInstructionGen instGen = new JvmInstructionGen(mv, indexMap, birModule, jvmPackageGen, jvmTypeGen, jvmCastGen, jvmConstantsGen, asyncDataCollector, types); JvmErrorGen errorGen = new JvmErrorGen(mv, indexMap, instGen); @@ -166,7 +166,7 @@ static void genJFieldForInteropField(JFieldBIRFunction birFunc, ClassWriter clas for (BIRVariableDcl birLocalVarOptional : birFunc.localVars) { if (birLocalVarOptional instanceof BIRNode.BIRFunctionParameter functionParameter) { birFuncParams.add(functionParameter); - indexMap.addIfNotExists(functionParameter.name.value, functionParameter.type); + indexMap.addIfNotExists(functionParameter.name.getValue(), functionParameter.type); } } @@ -176,7 +176,7 @@ static void genJFieldForInteropField(JFieldBIRFunction birFunc, ClassWriter clas // Load receiver which is the 0th parameter in the birFunc if (!jField.isStatic()) { BIRNode.BIRVariableDcl var = birFuncParams.get(0); - int receiverLocalVarIndex = indexMap.addIfNotExists(var.name.value, var.type); + int receiverLocalVarIndex = indexMap.addIfNotExists(var.name.getValue(), var.type); mv.visitVarInsn(ALOAD, receiverLocalVarIndex); mv.visitMethodInsn(INVOKEVIRTUAL, HANDLE_VALUE, GET_VALUE_METHOD, "()Ljava/lang/Object;", false); mv.visitTypeInsn(CHECKCAST, jField.getDeclaringClassName()); @@ -203,7 +203,7 @@ static void genJFieldForInteropField(JFieldBIRFunction birFunc, ClassWriter clas int birFuncParamIndex = jField.isStatic() ? 0 : 1; if (birFuncParamIndex < birFuncParams.size()) { BIRNode.BIRFunctionParameter birFuncParam = birFuncParams.get(birFuncParamIndex); - int paramLocalVarIndex = indexMap.addIfNotExists(birFuncParam.name.value, birFuncParam.type); + int paramLocalVarIndex = indexMap.addIfNotExists(birFuncParam.name.getValue(), birFuncParam.type); loadMethodParamToStackInInteropFunction(mv, birFuncParam, jFieldType, paramLocalVarIndex, instGen, jvmCastGen); } @@ -224,7 +224,7 @@ static void genJFieldForInteropField(JFieldBIRFunction birFunc, ClassWriter clas // Handle return type BIRVariableDcl retVarDcl = new BIRVariableDcl(retType, new Name("$_ret_var_$"), null, VarKind.LOCAL); - int returnVarRefIndex = indexMap.addIfNotExists(retVarDcl.name.value, retType); + int returnVarRefIndex = indexMap.addIfNotExists(retVarDcl.name.getValue(), retType); int retTypeTag = JvmCodeGenUtil.getImpliedType(retType).tag; if (retTypeTag == TypeTags.NIL) { @@ -253,7 +253,7 @@ static void genJFieldForInteropField(JFieldBIRFunction birFunc, ClassWriter clas mv.visitLabel(retLabel); mv.visitLineNumber(birFunc.pos.lineRange().endLine().line() + 1, retLabel); termGen.genReturnTerm(returnVarRefIndex, birFunc, -1, 0); - JvmCodeGenUtil.visitMaxStackForMethod(mv, birFunc.name.value, birFunc.javaField.getDeclaringClassName()); + JvmCodeGenUtil.visitMaxStackForMethod(mv, birFunc.name.getValue(), birFunc.javaField.getDeclaringClassName()); mv.visitEnd(); } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/interop/JMethodResolver.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/interop/JMethodResolver.java index 29c69a942619..73086e8e49f6 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/interop/JMethodResolver.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/interop/JMethodResolver.java @@ -551,7 +551,8 @@ private void validateReturnTypes(JMethodRequest jMethodRequest, JMethod jMethod) jMethodRequest.declaringClass.getName() + "': Java type '" + jReturnType.getName() + "' will not be matched to ballerina type '" + - (bReturnType.tag == TypeTags.FINITE ? bReturnType.tsymbol.name.value : + (bReturnType.tag == TypeTags.FINITE ? + bReturnType.tsymbol.name.getValue() : bReturnType) + "'"); } } @@ -1095,7 +1096,7 @@ private void throwNoSuchMethodError(String methodName, Class jType, BType bTy throw new JInteropException(DiagnosticErrorCode.METHOD_SIGNATURE_DOES_NOT_MATCH, "Incompatible param type for method '" + methodName + "' in class '" + declaringClass.getName() + "': Java type '" + jType.getName() + "' will not be matched to ballerina type '" + - (bType.tag == TypeTags.FINITE ? bType.tsymbol.name.value : bType) + "'"); + (bType.tag == TypeTags.FINITE ? bType.tsymbol.name.getValue() : bType) + "'"); } private void throwParamCountMismatchError(JMethodRequest jMethodRequest) throws JInteropException { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/ConfigMethodGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/ConfigMethodGen.java index 1618d381a41d..614324c8ab7e 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/ConfigMethodGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/ConfigMethodGen.java @@ -196,7 +196,7 @@ private void populateConfigDataMethod(ClassWriter cw, String moduleClass, mv.visitInsn(DUP); mv.visitFieldInsn(GETSTATIC, moduleClass, CURRENT_MODULE_VAR_NAME, "L" + MODULE + ";"); - mv.visitLdcInsn(globalVar.name.value); + mv.visitLdcInsn(globalVar.name.getValue()); jvmTypeGen.loadType(mv, globalVar.type); mv.visitLdcInsn(getOneBasedLocationString(module, globalVar.pos)); if (Symbols.isFlagOn(globalVarFlags, Flags.REQUIRED)) { diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/FrameClassGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/FrameClassGen.java index 3a116ac0efba..e15d04359fd0 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/FrameClassGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/FrameClassGen.java @@ -73,7 +73,7 @@ private void generateFrameClassForFunction(PackageID packageID, BIRNode.BIRFunct JarEntries pkgEntries, BType attachedType) { String frameClassName = MethodGenUtils.getFrameClassName(JvmCodeGenUtil.getPackageName(packageID), - func.name.value, attachedType); + func.name.getValue(), attachedType); ClassWriter cw = new BallerinaClassWriter(COMPUTE_FRAMES); if (func.pos != null && func.pos.lineRange().fileName() != null) { cw.visitSource(func.pos.lineRange().fileName(), null); diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/InitMethodGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/InitMethodGen.java index 4393d2ae2c46..d45ba12e51e7 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/InitMethodGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/InitMethodGen.java @@ -521,7 +521,7 @@ private BIRNode.BIRGlobalVariableDcl getDefaultFuncFPGlobalVar(Name name, List globalVars) { for (BIRNode.BIRGlobalVariableDcl globalVar : globalVars) { - if (globalVar.name.value.equals(name.value)) { + if (globalVar.name.getValue().equals(name.getValue())) { return globalVar; } } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/LambdaGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/LambdaGen.java index db6a0d634707..d1f6f127baa5 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/LambdaGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/LambdaGen.java @@ -228,7 +228,7 @@ private void genLoadDataForObjectAttachedLambdas(BIRTerminator.AsyncCall ins, Me mv.visitInsn(AALOAD); mv.visitTypeInsn(CHECKCAST, STRAND_CLASS); - mv.visitLdcInsn(JvmCodeGenUtil.rewriteVirtualCallTypeName(ins.name.value, ref.variableDcl.type)); + mv.visitLdcInsn(JvmCodeGenUtil.rewriteVirtualCallTypeName(ins.name.getValue(), ref.variableDcl.type)); int objectArrayLength = paramTypes.size() - 1; mv.visitIntInsn(BIPUSH, objectArrayLength); mv.visitTypeInsn(ANEWARRAY, OBJECT); @@ -461,17 +461,17 @@ private boolean isExternStaticFunctionCall(BIRInstruction callIns) { if (call.isVirtual) { return false; } - methodName = call.name.value; + methodName = call.name.getValue(); packageID = call.calleePkg; } case ASYNC_CALL -> { BIRTerminator.AsyncCall asyncCall = (BIRTerminator.AsyncCall) callIns; - methodName = asyncCall.name.value; + methodName = asyncCall.name.getValue(); packageID = asyncCall.calleePkg; } case FP_LOAD -> { BIRNonTerminator.FPLoad fpLoad = (BIRNonTerminator.FPLoad) callIns; - methodName = fpLoad.funcName.value; + methodName = fpLoad.funcName.getValue(); packageID = fpLoad.pkgId; } default -> throw new BLangCompilerException("JVM static function call generation is not supported for " + diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/MainMethodGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/MainMethodGen.java index e4bd8a182f6c..34fdba0b97c7 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/MainMethodGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/MainMethodGen.java @@ -438,7 +438,8 @@ private List getDefaultableNames(List a List defaultableNames = new ArrayList<>(); int defaultableIndex = 0; for (BIRNode.BIRAnnotationAttachment attachment : annotAttachments) { - if (attachment != null && attachment.annotTagRef.value.equals(JvmConstants.DEFAULTABLE_ARGS_ANOT_NAME)) { + if (attachment != null && + attachment.annotTagRef.getValue().equals(JvmConstants.DEFAULTABLE_ARGS_ANOT_NAME)) { Map annotFieldMap = (Map) ((BIRNode.BIRConstAnnotationAttachment) attachment).annotValue.value; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/MethodGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/MethodGen.java index 003e3869bb48..354118d688ce 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/MethodGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/MethodGen.java @@ -118,9 +118,9 @@ import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.MODULE_INIT_CLASS_NAME; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.MODULE_STARTED; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.MODULE_START_ATTEMPTED; -import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.PARENT_MODULE_START_ATTEMPTED; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.NO_OF_DEPENDANT_MODULES; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.OBJECT_SELF_INSTANCE; +import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.PARENT_MODULE_START_ATTEMPTED; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.STACK; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.STRAND; import static org.wso2.ballerinalang.compiler.bir.codegen.JvmConstants.STRAND_CLASS; @@ -196,7 +196,7 @@ public void genJMethodWithBObjectMethodCall(BIRFunction func, ClassWriter cw, BI BIRVarToJVMIndexMap indexMap = new BIRVarToJVMIndexMap(); indexMap.addIfNotExists(OBJECT_SELF_INSTANCE, symbolTable.anyType); indexMap.addIfNotExists(STRAND, symbolTable.stringType); - String funcName = func.name.value; + String funcName = func.name.getValue(); BType retType = getReturnType(func); String desc = JvmCodeGenUtil.getMethodDesc(func.type.paramTypes, retType); MethodVisitor mv = cw.visitMethod(Opcodes.ACC_PUBLIC, funcName, desc, null, null); @@ -209,7 +209,7 @@ public void genJMethodWithBObjectMethodCall(BIRFunction func, ClassWriter cw, BI mv.visitVarInsn(ALOAD, 0); // load self String encodedMethodName = Utils.encodeFunctionIdentifier(funcName); for (BIRNode.BIRFunctionParameter parameter : func.parameters) { - instGen.generateVarLoad(mv, parameter, indexMap.addIfNotExists(parameter.name.value, parameter.type)); + instGen.generateVarLoad(mv, parameter, indexMap.addIfNotExists(parameter.name.getValue(), parameter.type)); } String methodDesc = JvmCodeGenUtil.getMethodDesc(func.type.paramTypes, retType, moduleClassName); mv.visitMethodInsn(INVOKESTATIC, splitClassName, encodedMethodName, methodDesc, false); @@ -222,7 +222,7 @@ public void genJMethodWithBObjectMethodCall(BIRFunction func, ClassWriter cw, BI String metaVarName = parameter.metaVarName; if (isValidArg(parameter) && isCompilerAddedVars(metaVarName)) { mv.visitLocalVariable(metaVarName, getJVMTypeSign(parameter.type), null, methodStartLabel, - methodEndLabel, indexMap.addIfNotExists(parameter.name.value, parameter.type)); + methodEndLabel, indexMap.addIfNotExists(parameter.name.getValue(), parameter.type)); } } JvmCodeGenUtil.visitMaxStackForMethod(mv, funcName, moduleClassName); @@ -269,7 +269,7 @@ public void genJMethodForBFunc(BIRFunction func, ClassWriter cw, BIRPackage modu indexMap.addIfNotExists(OBJECT_SELF_INSTANCE, symbolTable.anyType); } - String funcName = func.name.value; + String funcName = func.name.getValue(); BType retType = getReturnType(func); String desc; int invocationCountArgVarIndex = -1; @@ -489,7 +489,7 @@ private void genLocalVars(BIRVarToJVMIndexMap indexMap, MethodVisitor mv, List visitedScopesSet = new HashSet<>(); @@ -617,7 +617,7 @@ void generateBasicBlocks(MethodVisitor mv, LabelGenerator labelGen, JvmErrorGen for (int i = 0; i < func.basicBlocks.size(); i++) { BIRBasicBlock bb = func.basicBlocks.get(i); // create jvm label - Label bbLabel = labelGen.getLabel(funcName + bb.id.value); + Label bbLabel = labelGen.getLabel(funcName + bb.id.getValue()); mv.visitLabel(bbLabel); if (i == 0) { pushShort(mv, stateVarIndex, caseIndex); @@ -629,7 +629,7 @@ void generateBasicBlocks(MethodVisitor mv, LabelGenerator labelGen, JvmErrorGen .getLastScopeFromBBInsGen(mv, labelGen, instGen, localVarOffset, funcName, bb, visitedScopesSet, lastScope); - Label bbEndLabel = labelGen.getLabel(funcName + bb.id.value + "beforeTerm"); + Label bbEndLabel = labelGen.getLabel(funcName + bb.id.getValue() + "beforeTerm"); mv.visitLabel(bbEndLabel); String fullyQualifiedFuncName = getFullyQualifiedFuncName(func.type.tsymbol, funcName); @@ -714,7 +714,7 @@ private void processTerminator(MethodVisitor mv, BIRFunction func, BIRPackage mo } private boolean isModuleTestInitFunction(BIRFunction func) { - return func.name.value.equals( + return func.name.getValue().equals( MethodGenUtils .encodeModuleSpecialFuncName(".")); } @@ -754,7 +754,7 @@ private void generateFrameClassFieldLoad(List localVars, MethodV continue; } BType bType = JvmCodeGenUtil.getImpliedType(localVar.type); - int index = indexMap.addIfNotExists(localVar.name.value, bType); + int index = indexMap.addIfNotExists(localVar.name.getValue(), bType); mv.visitInsn(DUP); if (TypeTags.isIntegerTypeTag(bType.tag)) { @@ -893,7 +893,7 @@ private void generateFrameClassFieldUpdate(List localVars, Metho continue; } BType bType = JvmCodeGenUtil.getImpliedType(localVar.type); - int index = indexMap.addIfNotExists(localVar.name.value, bType); + int index = indexMap.addIfNotExists(localVar.name.getValue(), bType); mv.visitInsn(DUP); if (TypeTags.isIntegerTypeTag(bType.tag)) { @@ -1053,7 +1053,7 @@ private void generateGetFrame(BIRVarToJVMIndexMap indexMap, int localVarOffset, private void createLocalVariableTable(BIRFunction func, BIRVarToJVMIndexMap indexMap, int localVarOffset, MethodVisitor mv, Label methodStartLabel, LabelGenerator labelGen, Label methodEndLabel, boolean isObjectMethodSplit) { - String funcName = func.name.value; + String funcName = func.name.getValue(); // Add strand variable to LVT mv.visitLocalVariable(STRAND_LOCAL_VARIABLE_NAME, GET_STRAND, null, methodStartLabel, methodEndLabel, localVarOffset); @@ -1075,14 +1075,14 @@ private void createLocalVariableTable(BIRFunction func, BIRVarToJVMIndexMap inde startLabel = labelGen.getLabel(funcName + SCOPE_PREFIX + localVar.insScope.id()); } if (localVar.endBB != null) { - endLabel = labelGen.getLabel(funcName + localVar.endBB.id.value + "beforeTerm"); + endLabel = labelGen.getLabel(funcName + localVar.endBB.id.getValue() + "beforeTerm"); } } String metaVarName = localVar.metaVarName; if (isCompilerAddedVars(metaVarName)) { mv.visitLocalVariable(metaVarName, getJVMTypeSign(localVar.type), null, startLabel, endLabel, - indexMap.addIfNotExists(localVar.name.value, localVar.type)); + indexMap.addIfNotExists(localVar.name.getValue(), localVar.type)); } } } @@ -1090,7 +1090,7 @@ private void createLocalVariableTable(BIRFunction func, BIRVarToJVMIndexMap inde private boolean isValidArg(BIRVariableDcl localVar) { boolean localArg = localVar.kind == VarKind.LOCAL || localVar.kind == VarKind.ARG; boolean synArg = JvmCodeGenUtil.getImpliedType(localVar.type).tag == TypeTags.BOOLEAN && - localVar.name.value.startsWith("%syn"); + localVar.name.getValue().startsWith("%syn"); boolean lambdaMapArg = localVar.metaVarName != null && localVar.metaVarName.startsWith("$map$block$") && localVar.kind == VarKind.SYNTHETIC; return (localArg && !synArg) || lambdaMapArg; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/MethodGenUtils.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/MethodGenUtils.java index 57aab825ef70..125199958f21 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/MethodGenUtils.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/methodgen/MethodGenUtils.java @@ -70,7 +70,7 @@ static boolean hasInitFunction(BIRNode.BIRPackage pkg) { } static boolean isModuleInitFunction(BIRNode.BIRFunction func) { - return func.name.value.equals(encodeModuleSpecialFuncName(INIT_FUNCTION_SUFFIX)); + return func.name.getValue().equals(encodeModuleSpecialFuncName(INIT_FUNCTION_SUFFIX)); } public static void submitToScheduler(MethodVisitor mv, String strandMetadataClass, String workerName, @@ -92,14 +92,14 @@ public static String encodeModuleSpecialFuncName(String funcSuffix) { } static String calculateLambdaStopFuncName(PackageID id) { - String orgName = id.orgName.value; + String orgName = id.orgName.getValue(); String moduleName; if (id.isTestPkg) { - moduleName = id.name.value + Names.TEST_PACKAGE; + moduleName = id.name.getValue() + Names.TEST_PACKAGE; } else { - moduleName = id.name.value; + moduleName = id.name.getValue(); } - String version = getMajorVersion(id.version.value); + String version = getMajorVersion(id.version.getValue()); String funcSuffix = MethodGenUtils.STOP_FUNCTION_SUFFIX; String funcName; diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/optimizer/LargeMethodOptimizer.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/optimizer/LargeMethodOptimizer.java index 20aa3d646e15..997a1e2581a4 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/optimizer/LargeMethodOptimizer.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/optimizer/LargeMethodOptimizer.java @@ -490,7 +490,7 @@ private int getLastInsNumAndHandleTerminator(List bbs, Set possibleSplits, } currentBB.terminator = basicBlocks.get(bbNum).terminator; newBBList.add(currentBB); - changedLocalVarStartBB.put(basicBlocks.get(bbNum).id.value, currentBB.id.value); - changedLocalVarEndBB.put(basicBlocks.get(bbNum).id.value, currentBB.id.value); + changedLocalVarStartBB.put(basicBlocks.get(bbNum).id.getValue(), currentBB.id.getValue()); + changedLocalVarEndBB.put(basicBlocks.get(bbNum).id.getValue(), currentBB.id.getValue()); startInsNum = 0; bbNum += 1; continue; @@ -1398,7 +1398,7 @@ private void generateSplits(BIRFunction function, List possibleSplits, if (currentBB == null) { throw new IllegalStateException("currentBB cannot be null"); } - changedLocalVarStartBB.put(basicBlocks.get(bbNum).id.value, currentBB.id.value); + changedLocalVarStartBB.put(basicBlocks.get(bbNum).id.getValue(), currentBB.id.getValue()); if (!splitsInSameBBList.isEmpty()) { // current unfinished BB is passed to the function and a new one is returned from it currentBB = generateSplitsInSameBB(function, bbNum, splitsInSameBBList, newlyAddedFunctions, @@ -1415,7 +1415,7 @@ private void generateSplits(BIRFunction function, List possibleSplits, } currentBB.terminator = basicBlocks.get(bbNum).terminator; newBBList.add(currentBB); - changedLocalVarEndBB.put(basicBlocks.get(bbNum).id.value, currentBB.id.value); + changedLocalVarEndBB.put(basicBlocks.get(bbNum).id.getValue(), currentBB.id.getValue()); startInsNum = 0; bbNum += 1; if (splitNum < possibleSplits.size() && (possibleSplits.get(splitNum).startBBNum == bbNum)) { @@ -1468,7 +1468,7 @@ private void generateSplits(BIRFunction function, List possibleSplits, currentPackageId, newFuncName, args, splitFuncCallResultOp, parentFuncNewBB, Collections.emptyList(), Collections.emptySet(), lastInstruction.scope); newBBList.add(currentBB); - changedLocalVarEndBB.put(basicBlocks.get(bbNum).id.value, currentBB.id.value); + changedLocalVarEndBB.put(basicBlocks.get(bbNum).id.getValue(), currentBB.id.getValue()); currentBB = parentFuncNewBB; if (currSplit.returnValAssigned) { currentBB = handleNewFuncReturnVal(function, splitFuncCallResultOp, lastInstruction.scope, currentBB, @@ -1622,22 +1622,22 @@ private void setLocalVarStartEndBB(BIRFunction birFunction, List Map newBBs = new HashMap<>(); for (BIRBasicBlock newBB : newBBList) { - newBBs.put(newBB.id.value, newBB); + newBBs.put(newBB.id.getValue(), newBB); } for (BIRVariableDcl localVar : birFunction.localVars) { if (localVar.kind == VarKind.LOCAL) { if (localVar.startBB != null) { - if (changedLocalVarStartBB.containsKey(localVar.startBB.id.value)) { - localVar.startBB = newBBs.get(changedLocalVarStartBB.get(localVar.startBB.id.value)); + if (changedLocalVarStartBB.containsKey(localVar.startBB.id.getValue())) { + localVar.startBB = newBBs.get(changedLocalVarStartBB.get(localVar.startBB.id.getValue())); } else { - localVar.startBB = newBBs.get(localVar.startBB.id.value); + localVar.startBB = newBBs.get(localVar.startBB.id.getValue()); } } if (localVar.endBB != null) { - if (changedLocalVarEndBB.containsKey(localVar.endBB.id.value)) { - localVar.endBB = newBBs.get(changedLocalVarEndBB.get(localVar.endBB.id.value)); + if (changedLocalVarEndBB.containsKey(localVar.endBB.id.getValue())) { + localVar.endBB = newBBs.get(changedLocalVarEndBB.get(localVar.endBB.id.getValue())); } else { - localVar.endBB = newBBs.get(localVar.endBB.id.value); + localVar.endBB = newBBs.get(localVar.endBB.id.getValue()); } } } diff --git a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmCreateTypeGen.java b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmCreateTypeGen.java index dd383de6ed93..6765412801f4 100644 --- a/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmCreateTypeGen.java +++ b/compiler/ballerina-lang/src/main/java/org/wso2/ballerinalang/compiler/bir/codegen/split/JvmCreateTypeGen.java @@ -266,7 +266,7 @@ private int createTypesInstanceSplits(ClassWriter cw, List ty // Create the type for (BIRTypeDefinition optionalTypeDef : typeDefs) { - String name = optionalTypeDef.internalName.value; + String name = optionalTypeDef.internalName.getValue(); BType bType = optionalTypeDef.type; int bTypeTag = bType.tag; if (JvmCodeGenUtil.needNoTypeGeneration(bTypeTag)) { @@ -284,7 +284,7 @@ private int createTypesInstanceSplits(ClassWriter cw, List ty jvmRecordTypeGen.createRecordType(mv, (BRecordType) bType, typeOwnerClass, name); case TypeTags.OBJECT -> jvmObjectTypeGen.createObjectType(mv, (BObjectType) bType); case TypeTags.ERROR -> - jvmErrorTypeGen.createErrorType(mv, (BErrorType) bType, bType.tsymbol.name.value); + jvmErrorTypeGen.createErrorType(mv, (BErrorType) bType, bType.tsymbol.name.getValue()); case TypeTags.TUPLE -> jvmTupleTypeGen.createTupleType(mv, (BTupleType) bType); default -> jvmUnionTypeGen.createUnionType(mv, (BUnionType) bType); } @@ -318,7 +318,7 @@ private Map populateTypes(ClassWriter cw, List createLabelsForSwitch(MethodVisitor mv, int nameRegInd labels.add(i, new Label()); String name; if (decodeCase) { - name = decodeIdentifier(node.getName().value); + name = decodeIdentifier(node.getName().getValue()); } else { - name = node.getName().value; + name = node.getName().getValue(); } hashCodes[i] = name.hashCode(); i += 1; @@ -466,9 +466,9 @@ public static List