Skip to content

Commit

Permalink
Rename ParameterDesugar class as ClosureGenerator
Browse files Browse the repository at this point in the history
  • Loading branch information
chiranSachintha committed Nov 14, 2022
1 parent e084377 commit b88ddd0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public class AnnotationDesugar {
private final Names names;
private SymbolResolver symResolver;
private ConstantValueResolver constantValueResolver;
private ParameterDesugar parameterDesugar;
private ClosureGenerator closureGenerator;

public static AnnotationDesugar getInstance(CompilerContext context) {
AnnotationDesugar annotationDesugar = context.get(ANNOTATION_DESUGAR_KEY);
Expand All @@ -157,7 +157,7 @@ private AnnotationDesugar(CompilerContext context) {
this.names = Names.getInstance(context);
this.symResolver = SymbolResolver.getInstance(context);
this.constantValueResolver = ConstantValueResolver.getInstance(context);
this.parameterDesugar = ParameterDesugar.getInstance(context);
this.closureGenerator = ClosureGenerator.getInstance(context);
}

/**
Expand Down Expand Up @@ -648,7 +648,7 @@ public BLangLambdaFunction defineAnnotationsForLocalRecords(BLangRecordTypeNode
pkgID, owner, false);
if (fieldAnnotLambda != null) {
BInvokableSymbol invokableSymbol =
parameterDesugar.createSimpleVariable(fieldAnnotLambda.function, fieldAnnotLambda);
closureGenerator.createSimpleVariable(fieldAnnotLambda.function, fieldAnnotLambda);
env.scope.define(invokableSymbol.name, invokableSymbol);
if (!annotFunctionDefined) {
function = defineFunction(recordTypeNode.pos, pkgID, owner);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@
*
* @since 2201.3.0
*/
public class ParameterDesugar extends BLangNodeVisitor {
private static final CompilerContext.Key<ParameterDesugar> PARAMETER_DESUGAR_KEY = new CompilerContext.Key<>();
public class ClosureGenerator extends BLangNodeVisitor {
private static final CompilerContext.Key<ClosureGenerator> CLOSURE_GENERATOR_KEY = new CompilerContext.Key<>();
private Queue<BLangSimpleVariableDef> queue;

private SymbolTable symTable;
Expand All @@ -205,17 +205,17 @@ public class ParameterDesugar extends BLangNodeVisitor {
private SymbolResolver symResolver;
private AnnotationDesugar annotationDesugar;

public static ParameterDesugar getInstance(CompilerContext context) {
ParameterDesugar parameterDesugar = context.get(PARAMETER_DESUGAR_KEY);
if (parameterDesugar == null) {
parameterDesugar = new ParameterDesugar(context);
public static ClosureGenerator getInstance(CompilerContext context) {
ClosureGenerator closureGenerator = context.get(CLOSURE_GENERATOR_KEY);
if (closureGenerator == null) {
closureGenerator = new ClosureGenerator(context);
}

return parameterDesugar;
return closureGenerator;
}

private ParameterDesugar(CompilerContext context) {
context.put(PARAMETER_DESUGAR_KEY, this);
private ClosureGenerator(CompilerContext context) {
context.put(CLOSURE_GENERATOR_KEY, this);
this.symTable = SymbolTable.getInstance(context);
this.queue = new LinkedList<>();
this.symResolver = SymbolResolver.getInstance(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ public class Desugar extends BLangNodeVisitor {
private SymbolResolver symResolver;
private final SymbolEnter symbolEnter;
private ClosureDesugar closureDesugar;
private ParameterDesugar parameterDesugar;
private ClosureGenerator closureGenerator;
private QueryDesugar queryDesugar;
private TransactionDesugar transactionDesugar;
private ObservabilityDesugar observabilityDesugar;
Expand Down Expand Up @@ -446,7 +446,7 @@ private Desugar(CompilerContext context) {
this.symResolver = SymbolResolver.getInstance(context);
this.symbolEnter = SymbolEnter.getInstance(context);
this.closureDesugar = ClosureDesugar.getInstance(context);
this.parameterDesugar = ParameterDesugar.getInstance(context);
this.closureGenerator = ClosureGenerator.getInstance(context);
this.queryDesugar = QueryDesugar.getInstance(context);
this.transactionDesugar = TransactionDesugar.getInstance(context);
this.observabilityDesugar = ObservabilityDesugar.getInstance(context);
Expand Down Expand Up @@ -773,7 +773,7 @@ public void visit(BLangPackage pkgNode) {
}

// create closures for default values
parameterDesugar.visit(pkgNode);
closureGenerator.visit(pkgNode);

// Initialize the annotation map
annotationDesugar.initializeAnnotationMap(pkgNode);
Expand Down

0 comments on commit b88ddd0

Please sign in to comment.