@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); } } }
private void definedInBlock(Set<String> references, Block block) { if (!stack.isEmpty()) { for (String ref : references) { context().definingBlock.put(ref, block); } context().allReferences.addAll(references); } }
private void pushBlockTable(Block block) { if (!stack.isEmpty()) { if (!context().referenceTableStack.isEmpty()) { block.getReferenceTable().relink(context().referenceTableStack.peek()); } context().referenceTableStack.push(block.getReferenceTable()); } }
private void accessed(String name) { if (!stack.isEmpty()) { context().accessedReferences.add(name); } }
private void locallyDeclared(String name) { if (!stack.isEmpty()) { context().localReferences.add(name); } }
private void dropBlockTable() { if (!stack.isEmpty()) { context().referenceTableStack.pop(); } }