/* * Transfer functions */ public static Value evaluate( DOMObjects nativeObject, FunctionCalls.CallInfo call, State s, Solver.SolverInterface c) { switch (nativeObject) { case ACTIVE_X_OBJECT_OPEN: { NativeFunctions.expectParameters(nativeObject, call, c, 2, 5); /* Value method =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c); /* Value url =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 1), c); return Value.makeUndef(); } case ACTIVE_X_OBJECT_SET_REQUEST_HEADER: { NativeFunctions.expectParameters(nativeObject, call, c, 2, 2); /* Value header =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c); /* Value value =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 1), c); return Value.makeUndef(); } case ACTIVE_X_OBJECT_SEND: { NativeFunctions.expectParameters(nativeObject, call, c, 0, 1); return Value.makeUndef(); } case ACTIVE_X_OBJECT_ABORT: { NativeFunctions.expectParameters(nativeObject, call, c, 0, 0); return Value.makeUndef(); } case ACTIVE_X_OBJECT_GET_RESPONSE_HEADER: { NativeFunctions.expectParameters(nativeObject, call, c, 1, 1); /* Value header =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c); return Value.makeAnyStr(); } case ACTIVE_X_OBJECT_GET_ALL_RESPONSE_HEADERS: { NativeFunctions.expectParameters(nativeObject, call, c, 0, 0); return Value.makeAnyStr(); } case ACTIVE_X_OBJECT_CONSTRUCTOR: { // TODO: Check if this is sound. return Value.makeObject(INSTANCES).joinUndef(); } default: { throw new AnalysisException("Unknown Native Object: " + nativeObject); } } }
/** 11.13 and 7.8 assignment with literal. */ @Override public void visit(ConstantNode n, State state) { Value v; switch (n.getType()) { case NULL: v = Value.makeNull(); break; case UNDEFINED: v = Value.makeUndef(); break; case BOOLEAN: v = Value.makeBool(n.getBoolean()); break; case NUMBER: v = Value.makeNum(n.getNumber()); break; case STRING: v = Value.makeStr(n.getString()); break; default: throw new AnalysisException(); } if (n.getResultRegister() != AbstractNode.NO_VALUE) state.writeRegister(n.getResultRegister(), v); }
public static Value evaluate( DOMObjects nativeObject, FunctionCalls.CallInfo call, State s, Solver.SolverInterface c) { switch (nativeObject) { case MOUSE_EVENT_INIT_MOUSE_EVENT: { NativeFunctions.expectParameters(nativeObject, call, c, 15, 15); /* Value typeArg =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c); /* Value canBubbleArg =*/ Conversion.toBoolean(NativeFunctions.readParameter(call, s, 1)); /* Value cancelableArg =*/ Conversion.toBoolean( NativeFunctions.readParameter(call, s, 2)); // View arg not checked /* Value detailArg =*/ Conversion.toNumber(NativeFunctions.readParameter(call, s, 4), c); /* Value screenXArg =*/ Conversion.toNumber(NativeFunctions.readParameter(call, s, 5), c); /* Value screenYArg =*/ Conversion.toNumber(NativeFunctions.readParameter(call, s, 6), c); /* Value clientXArg =*/ Conversion.toNumber(NativeFunctions.readParameter(call, s, 7), c); /* Value clientYArg =*/ Conversion.toNumber(NativeFunctions.readParameter(call, s, 8), c); /* Value ctrlKeyArg =*/ Conversion.toBoolean(NativeFunctions.readParameter(call, s, 9)); /* Value altKeyArg =*/ Conversion.toBoolean(NativeFunctions.readParameter(call, s, 10)); /* Value shiftKeyArg =*/ Conversion.toBoolean(NativeFunctions.readParameter(call, s, 11)); /* Value metaKeyArg =*/ Conversion.toBoolean(NativeFunctions.readParameter(call, s, 12)); /* Value buttonArg =*/ Conversion.toNumber(NativeFunctions.readParameter(call, s, 13), c); /* Value relatedTargetArg =*/ DOMConversion.toEventTarget( NativeFunctions.readParameter(call, s, 14), c); return Value.makeUndef(); } default: throw new UnsupportedOperationException("Unsupported Native Object: " + nativeObject); } }
/** * Transfer for a return statement. * * @param caller if non-null, only consider this caller */ public void transferReturn( int valueReg, BasicBlock block, State state, NodeAndContext<Context> caller, Context edge_context) { Value v; if (valueReg != AbstractNode.NO_VALUE) v = state.readRegister(valueReg); else v = Value.makeUndef(); UserFunctionCalls.leaveUserFunction( v, false, block.getFunction(), state, c, caller, edge_context); }
/** 12.2 variable declaration. */ @Override public void visit(DeclareVariableNode n, State state) { state.declareAndWriteVariable(n.getVariableName(), Value.makeUndef(), false); }
/** Transfer Functions. */ public static Value evaluate(DOMObjects nativeObject, CallInfo call, Solver.SolverInterface c) { State s = c.getState(); switch (nativeObject) { case ELEMENT_GET_ATTRIBUTE: { NativeFunctions.expectParameters(nativeObject, call, c, 1, 1); /* Value name =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c); return Value.makeAnyStr(); } case ELEMENT_SET_ATTRIBUTE: { NativeFunctions.expectParameters(nativeObject, call, c, 2, 2); /* Value name =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c); /* Value value =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 1), c); return Value.makeUndef(); } case ELEMENT_REMOVE_ATTRIBUTE: { NativeFunctions.expectParameters(nativeObject, call, c, 1, 1); /* Value name =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c); return Value.makeUndef(); } case ELEMENT_GET_ATTRIBUTE_NS: { NativeFunctions.expectParameters(nativeObject, call, c, 2, 2); /* Value namespace =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c); /* Value name =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 1), c); return Value.makeAnyStr(); } case ELEMENT_GET_ATTRIBUTE_NODE: { NativeFunctions.expectParameters(nativeObject, call, c, 1, 1); /* Value name =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c); return Value.makeObject(DOMAttr.INSTANCES); } case ELEMENT_GET_ATTRIBUTE_NODE_NS: { NativeFunctions.expectParameters(nativeObject, call, c, 2, 2); /* Value namespace =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c); /* Value name =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 1), c); return Value.makeObject(DOMAttr.INSTANCES); } case ELEMENT_GET_BOUNDING_CLIENT_RECT: { NativeFunctions.expectParameters(nativeObject, call, c, 0, 0); return Value.makeObject(ClientBoundingRect.INSTANCES); } case ELEMENT_GET_ELEMENTS_BY_TAGNAME: { // TODO: needs precision, but cannot do like document.getElementsByTagName() bc. State is // for everything NativeFunctions.expectParameters(nativeObject, call, c, 1, 1); /* Value name =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c); return Value.makeObject(DOMNodeList.INSTANCES); } case ELEMENT_GET_ELEMENTS_BY_TAGNAME_NS: { NativeFunctions.expectParameters(nativeObject, call, c, 2, 2); /* Value namespace =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c); /* Value name =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 1), c); return Value.makeObject(DOMNodeList.INSTANCES); } case ELEMENT_HAS_ATTRIBUTE: { NativeFunctions.expectParameters(nativeObject, call, c, 1, 1); /* Value name =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c); return Value.makeAnyBool(); } case ELEMENT_HAS_ATTRIBUTE_NS: { NativeFunctions.expectParameters(nativeObject, call, c, 2, 2); /* Value namespace =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c); /* Value name =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 1), c); return Value.makeAnyBool(); } case ELEMENT_REMOVE_ATTRIBUTE_NS: { NativeFunctions.expectParameters(nativeObject, call, c, 2, 2); /* Value namespaceURI =*/ Conversion.toString( NativeFunctions.readParameter(call, s, 0), c); /* Value localName =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 1), c); return Value.makeUndef(); } case ELEMENT_REMOVE_ATTRIBUTE_NODE: { NativeFunctions.expectParameters(nativeObject, call, c, 1, 1); return DOMConversion.toAttr(NativeFunctions.readParameter(call, s, 0), c); } case ELEMENT_SET_ATTRIBUTE_NS: { NativeFunctions.expectParameters(nativeObject, call, c, 3, 3); /* Value namespace =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c) .joinNull(); /* Value name =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 1), c); /* Value value =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 2), c); return Value.makeUndef(); } case ELEMENT_SET_ATTRIBUTE_NODE: { NativeFunctions.expectParameters(nativeObject, call, c, 1, 1); /* Value newAttr =*/ DOMConversion.toAttr(NativeFunctions.readParameter(call, s, 0), c); return Value.makeObject(DOMAttr.INSTANCES).joinNull(); } case ELEMENT_SET_ATTRIBUTE_NODE_NS: { NativeFunctions.expectParameters(nativeObject, call, c, 1, 1); /* Value newAttr =*/ DOMConversion.toAttr(NativeFunctions.readParameter(call, s, 0), c); return Value.makeObject(DOMAttr.INSTANCES).joinNull(); } case ELEMENT_SET_ID_ATTRIBUTE: { NativeFunctions.expectParameters(nativeObject, call, c, 2, 2); /* Value name =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 0), c); /* Value isId =*/ Conversion.toBoolean(NativeFunctions.readParameter(call, s, 1)); return Value.makeUndef(); } case ELEMENT_SET_ID_ATTRIBUTE_NS: { NativeFunctions.expectParameters(nativeObject, call, c, 3, 3); /* Value namespaceURI =*/ Conversion.toString( NativeFunctions.readParameter(call, s, 0), c); /* Value localName =*/ Conversion.toString(NativeFunctions.readParameter(call, s, 1), c); /* Value isId =*/ Conversion.toBoolean(NativeFunctions.readParameter(call, s, 2)); return Value.makeUndef(); } case ELEMENT_SET_ID_ATTRIBUTE_NODE: { NativeFunctions.expectParameters(nativeObject, call, c, 2, 2); /* Value idAttr =*/ DOMConversion.toAttr(NativeFunctions.readParameter(call, s, 0), c); /* Value isId =*/ Conversion.toBoolean(NativeFunctions.readParameter(call, s, 1)); return Value.makeUndef(); } case ELEMENT_QUERY_SELECTOR_ALL: { NativeFunctions.expectParameters(nativeObject, call, c, 1, 1); return Value.makeObject(DOMNodeList.INSTANCES); } default: { throw new AnalysisException("Unknown Native Object: " + nativeObject); } } }