Search in sources :

Example 1 with VariableScopeAnalyzerState

use of st.gravel.support.compiler.ast.VariableScopeAnalyzerState in project gravel by gravel-st.

the class NonLocalTempAccessToHolderConverter method visitSequenceNode_.

@Override
public SequenceNode visitSequenceNode_(final SequenceNode _anObject) {
    final SequenceNode[] _node;
    _node = new SequenceNode[1];
    _node[0] = SequenceNode.factory.temporaries_statements_(st.gravel.support.jvm.ArrayExtensions.collect_(_anObject.temporaries(), ((st.gravel.support.jvm.Block1<VariableDeclarationNode, VariableDeclarationNode>) (new st.gravel.support.jvm.Block1<VariableDeclarationNode, VariableDeclarationNode>() {

        @Override
        public VariableDeclarationNode value_(final VariableDeclarationNode _each) {
            _temps.put(_each.name(), VariableScopeAnalyzerStateDefined.factory.basicNew());
            return (VariableDeclarationNode) NonLocalTempAccessToHolderConverter.this.visit_(_each);
        }
    }))), st.gravel.support.jvm.ArrayExtensions.collect_(_anObject.statements(), ((st.gravel.support.jvm.Block1<Statement, Statement>) (new st.gravel.support.jvm.Block1<Statement, Statement>() {

        @Override
        public Statement value_(final Statement _each) {
            return (Statement) NonLocalTempAccessToHolderConverter.this.visit_(_each);
        }
    }))));
    for (final Map.Entry<String, VariableScopeAnalyzerState> _temp1 : _temps.entrySet()) {
        String _varName = _temp1.getKey();
        VariableScopeAnalyzerState _state = _temp1.getValue();
        if (NonLocalTempAccessToHolderConverter.this.needsRewrite_(_state)) {
            _node[0] = ((SequenceNode) VariableToHolderRewriter.factory.varName_(_varName).visit_(_node[0]));
        }
    }
    return _node[0];
}
Also used : VariableScopeAnalyzerState(st.gravel.support.compiler.ast.VariableScopeAnalyzerState) VariableDeclarationNode(st.gravel.support.compiler.ast.VariableDeclarationNode) Statement(st.gravel.support.compiler.ast.Statement) HashMap(java.util.HashMap) Map(java.util.Map) SequenceNode(st.gravel.support.compiler.ast.SequenceNode)

Aggregations

HashMap (java.util.HashMap)1 Map (java.util.Map)1 SequenceNode (st.gravel.support.compiler.ast.SequenceNode)1 Statement (st.gravel.support.compiler.ast.Statement)1 VariableDeclarationNode (st.gravel.support.compiler.ast.VariableDeclarationNode)1 VariableScopeAnalyzerState (st.gravel.support.compiler.ast.VariableScopeAnalyzerState)1