private void assertNotLiveBeforeX(String src, String var) { FlowState<LiveVariablesAnalysis.LiveVariableLattice> state = getFlowStateAtX(src); assertTrue("Label X should be in the input program.", state != null); assertTrue( "Variable" + var + " should not be live before X", !state.getIn().isLive(liveness.getVarIndex(var))); }
private void assertLiveBeforeX(String src, String var) { FlowState<LiveVariablesAnalysis.LiveVariableLattice> state = getFlowStateAtX(src); assertNotNull(src + " should contain a label 'X:'", state); assertTrue( "Variable" + var + " should be live before X", state.getIn().isLive(liveness.getVarIndex(var))); }
private static LiveVariablesAnalysis computeLiveness(String src) { Compiler compiler = new Compiler(); CompilerOptions options = new CompilerOptions(); options.setCodingConvention(new GoogleCodingConvention()); compiler.initOptions(options); src = "function _FUNCTION(param1, param2){" + src + "}"; Node n = compiler.parseTestCode(src).removeFirstChild(); Node script = new Node(Token.SCRIPT, n); assertEquals(0, compiler.getErrorCount()); Scope scope = new SyntacticScopeCreator(compiler).createScope(n, new Scope(script, compiler)); ControlFlowAnalysis cfa = new ControlFlowAnalysis(compiler, false, true); cfa.process(null, n); ControlFlowGraph<Node> cfg = cfa.getCfg(); LiveVariablesAnalysis analysis = new LiveVariablesAnalysis(cfg, scope, compiler); analysis.analyze(); return analysis; }
private FlowState<LiveVariablesAnalysis.LiveVariableLattice> getFlowStateAtX(String src) { liveness = computeLiveness(src); return getFlowStateAtX(liveness.getCfg().getEntry().getValue(), liveness.getCfg()); }