Ejemplo n.º 1
0
RawLocation::Actions 
RawLocation::do_conform_to(int my_index, RawLocation* other, int other_index, 
                           RawLocation::Actions allowed_actions) {
  // make sure object registers and locations have object values 
  if (other->stack_type() == T_OBJECT && stack_type() != T_OBJECT) {
    // Conformance code makes it so that this is no longer necessary.
    SHOULD_NOT_REACH_HERE();

#if NOT_CURRENTLY_USED
    // if we clear an cached object location there's no need to clear
    // any registers, since the register cache (due to type conflicts) is 
    // guaranteed never to be used again
    if (other.is_flushed() || other.is_cached()) {
      code_generator()->clear_object_location(index());
    } else {
      GUARANTEE(other.is_changed(), "only case left");
      Value other_value(other.type());
      other.read_value(other_value);
      Oop::Raw null_obj;      
      code_generator()->move(other_value, &null_obj);
    }
    return;
#endif
  }
  // compute the merge action
  const Actions required_actions = merge_actions(other);

  const Actions actions = required_actions & allowed_actions;

  // handle loads/stores from/to locations
  if (actions & LOC_LOAD)  {
    other->update_cache(other_index);
  }
  if (actions & LOC_STORE) {
    write_changes(my_index);
  }
  
  // handle register stores
  if (actions & REG_STORE && other->in_register()) {
    // declare & read values for both source and destination
    const Value this_value (this,  my_index   );
    const Value other_value(other, other_index);

    // do the register store 
    if (!other->is_register_identical_to(my_index, this, other_index)) {
      code_generator()->move(other_value, this_value);
    }
  }

  return required_actions & ~allowed_actions;
}
Ejemplo n.º 2
0
jsonpack_token_type scanner::next()
{
    switch ( _c )
    {
    case '{':
        advance();
        return JTK_OPEN_KEY;
        break;
    case '}':
        advance();
        return JTK_CLOSE_KEY;
        break;
    case '[':
        advance();
        return JTK_OPEN_BRACKET;
        break;
    case ']':
        advance();
        return JTK_CLOSE_BRACKET;
        break;
    case ':':
        advance();
        return JTK_COLON;
        break;
    case ',':
        advance();
        return JTK_COMMA;
        break;
    case '\'':
        return string_literal();
        break;
    case '"':
        return string_literal();
        break;

    default:
        if(std::isspace(  _c ) )
        {
            advance();
            return next();
        }
        else
        {
            return other_value();
        }
    }
}