Пример #1
0
 /** 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);
 }
Пример #2
0
 /** 12.6.4 check for more properties of 'for-in' statement. */
 @Override
 public void visit(HasNextPropertyNode n, State state) {
   Value v =
       UnknownValueResolver.getRealValue(state.readRegister(n.getPropertyListRegister()), state);
   Value res =
       !v.isNotStr()
           ? Value.makeBool(true)
           : Value.makeNone(); // string values represent property names
   if (v.isMaybeNull()) // null marks end-of-list
   res = res.joinBool(false);
   state.writeRegister(n.getResultRegister(), res);
 }