@Override public void visitAssignmentStatement(AssignmentStatement assignmentStatement) { LocalReference localReference = assignmentStatement.getLocalReference(); String referenceName = localReference.getName(); if (!localReference.isModuleState()) { if (!stack.isEmpty()) { assignmentStatement.setLocalReference( context().referenceTableStack.peek().get(referenceName)); } if (assignmentStatement.isDeclaring()) { locallyDeclared(referenceName); } } else { locallyDeclared(referenceName); } locallyAssigned(referenceName); assignmentStatement.getExpressionStatement().accept(this); if (assignmentStatement.getExpressionStatement() instanceof ClosureReference) { ClosureReference closure = (ClosureReference) assignmentStatement.getExpressionStatement(); GoloFunction target = closure.getTarget(); if (target.getSyntheticParameterNames().contains(referenceName)) { target.removeSyntheticParameter(referenceName); target.setSyntheticSelfName(referenceName); } } }
@Override public void visitClosureReference(ClosureReference closureReference) { closureReference.getTarget().accept(this); if (closureReference.getTarget().isSynthetic()) { Context context = context(); if (context != null) { for (String refName : closureReference.getTarget().getParameterNames()) { ReferenceTable referenceTable = context.referenceTableStack.peek(); if (referenceTable.hasReferenceFor(refName)) { // ...else it's a regular parameter accessed(refName); } } } } }