wala / WALA

T.J. Watson Libraries for Analysis, with frontends for Java, Android, and JavaScript, and may common static program analyses
http://github.com/wala/WALA
Eclipse Public License 2.0
750 stars 221 forks source link

Problem with getNumberOfParameters #314

Open Ameerah89 opened 6 years ago

Ameerah89 commented 6 years ago

Hi, I have a code that works properly before the update version of WALA. But after I updated to the new version, getNumberOfParameters does not work. It give me error _

The method getNumberOfParameters() is undefined for the type JavaScriptInvoke

_.

The previous version of WALA does not give me error like this. When I check the library com.ibm.wala.cast.js.ssa.JavaScriptInvoke I realize that the method getNumberOfParameters was not available under that libaray. Are there any equivalance method that can be used?

Below is the code

@Override
            public IntSet getTargets(int d1) {
                if (!(domain.getMappedObject(d1) instanceof FlowFact)) return EmptyIntSet.instance;
                FlowFact fact = (FlowFact) domain.getMappedObject(d1);

                MutableIntSet result = MutableSparseIntSet.makeEmpty();
                if (AnalysisUtil.isRelated(fact, call, src, dest)) result.add(d1);

                if (call.getLastInstruction() instanceof JavaScriptInvoke && src.getNode() == fact.getNode()) {
                    // An object that was given to a function was modified in that function
                    // -> also track the object in the caller scope
                    // call ExplodedBlock[36](original:BB[SSA:35..35]13 - test2.nodejsModule.moduleSource.do()LRoot;)
                    //      43 = invoke 16@35 44,40,31,46 exception:47
                    // src  ExplodedBlock[3](exit:<Code body of function Ltest2/nodejsModule/moduleSource/obfuscate>)
                    //      null
                    JavaScriptInvoke instr = (JavaScriptInvoke) call.getLastInstruction();

                    // Make sure that the modified variable is one of the parameters and not
                    // a local variable within the called function
                    if (fact.getVar() <= instr.getNumberOfParameters()) {
                        FlowFact factToAdd = new FlowFact(call.getNode(), instr.getUse(fact.getVar() - 1), fact.getFields());
                        AnalysisUtil.addFact(domain, result, factToAdd);
                    }
                }

                return result;
juliandolby commented 6 years ago

We are moving to support Python, which has both positional and keyword arguments, hence that method has been renamed to getNumberOfPositionalParameters.