コード例 #1
0
ファイル: CompilerTest.cpp プロジェクト: sfsy1989/j2me
bool CompilerTest::may_be_initialized(InstanceClass *klass) {
 if (klass->is_initialized()) {
    return false;
  }

  // All super classes and super interfaces must be initialized
  InstanceClass ic;
  for (ic = klass->obj(); !ic.is_null(); ic = ic.super()) {
    if (!ic.equals(klass) && !ic.is_initialized()) {
      return false;
    }

    TypeArray interfaces = ic.local_interfaces();
    int n_interfaces = interfaces.length();

    for (int i = 0; i < n_interfaces; i++) {
      int intf_id = interfaces.ushort_at(i);
      InstanceClass intf = Universe::class_from_id(intf_id);
      if (!intf.is_initialized()) {
        return false;
      }
    }
  }

  return true;
}
コード例 #2
0
static void iterate_fields(InstanceClass* ic, OopVisitor* visitor, 
                           bool visit_value) {
  InstanceClass s = ic->super();
  // Print fields defined by super class
  if (!s.is_null()) {
    iterate_fields(&s, visitor, visit_value);
  }
  // Print fields define by local class
  TypeArray fields = ic->original_fields(); 
  int last_field_offset = -1;
  for (;;) {
    int next_field_index = -1;
    int min_offset = 0x7fffffff;

    for(int index = 0; index < fields.length(); index += 5) {
      OriginalField f(ic, index);
      if (!f.is_static() &&
          f.offset() > last_field_offset && 
          f.offset() < min_offset) {
        next_field_index = index;
        min_offset = f.offset();
      }
    }

    last_field_offset = min_offset;
    if (next_field_index < 0) {
      break;
    }

    OriginalField f(ic, next_field_index);
    Symbol name = f.name();
    SymbolField field(&name, false);
    switch(f.type()) {
    case T_BOOLEAN:
      visitor->do_bool(&field, f.offset(), visit_value);
      break;
    case T_CHAR:
      visitor->do_char(&field, f.offset(), visit_value);
      break;
    case T_FLOAT :
      visitor->do_float(&field, f.offset(), visit_value);
      break;
    case T_DOUBLE:
      visitor->do_double(&field, f.offset(), visit_value);
      break;
    case T_BYTE:
      visitor->do_byte(&field, f.offset(), visit_value);
      break;
    case T_SHORT:
      visitor->do_short(&field, f.offset(), visit_value);
      break;
    case T_INT:
      visitor->do_int(&field, f.offset(), visit_value);
      break;
    case T_LONG:
      visitor->do_long(&field, f.offset(), visit_value);
      break;
    case T_OBJECT:
      visitor->do_oop(&field, f.offset(), visit_value);
      break;
    case T_ARRAY:
      visitor->do_oop(&field, f.offset(), visit_value);
      break;
    }
  }
}