Exemplo n.º 1
0
def _get_to_final(ids, annotation):
  '''Resolve to the final part of the identifier

  Returns (ASTType, asm_code)'''

  # Figure out where the field accesses or method invocations start.
  #   - If it's off of a static variable, e.g. ClassName.static_var.f,
  #     the annotation will start with static_var
  #   - If it's off a local variable or field, e.g. v.f, the annotation
  #     will start with v
  name, decl = annotation[0]
  t = _get_type_from_decl(decl)
  code = []
  if str(ids).startswith(name):
    # The first part matches the ID, which means we're going off a local var
    code = get_simple_var(decl)
  else:
    # The first part is a static variable access.
    code = common.get_static_field('eax', decl)

  if t.is_array:
    # Crazy hack for arrays!
    # If the type is an array, it's going to be the last part (because the
    # next part will be .length or one of J.L.O's methods.
    return t, code

  return _get_to_final_from_type(t, annotation, code)
Exemplo n.º 2
0
def get_simple_static_field(ids):
  '''Store the static field from an ASTIdentifier in $eax.'''
  f = _resolve_simple_static_fields(ids)
  return common.get_static_field('eax', f)