Package org.mozilla.javascript.optimizer

Examples of org.mozilla.javascript.optimizer.OptFunctionNode


            // wrap source in function
            ScriptNode tree = compile("function f(o, fn){" + source + "}");

            FunctionNode fnode = tree.getFunctionNode(0);
            assertNotNull(fnode);
            OptFunctionNode opt = OptFunctionNode.get(fnode);
            assertNotNull(opt);
            assertSame(fnode, opt.fnode);

            for (int i = 0, c = fnode.getParamCount(); i < c; ++i) {
                assertTrue(opt.isParameter(i));
                assertFalse(opt.isNumberVar(i));
            }

            Set<String> set = new HashSet<String>(asList(numbers));
            for (int i = fnode.getParamCount(), c = fnode.getParamAndVarCount(); i < c; ++i) {
                assertFalse(opt.isParameter(i));
                String name = fnode.getParamOrVarName(i);
                String msg = format("{%s -> number? = %b}", name, opt.isNumberVar(i));
                assertEquals(msg, set.contains(name), opt.isNumberVar(i));
            }
        }
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.optimizer.OptFunctionNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.