def compute_assign(self, env, rvalue): l = self.left() if isinstance(l, literal.Name): l.eval_for_assign(env, rvalue) return rvalue else: return super(BinaryEx2, self).compute_assign(env, rvalue)
def compute_assign(self, env, rvalue): le = self.left() if isinstance(le, expression.PrimaryExpr): p = le if p.has_postfix(0) and isinstance(p.postfix(0), cls.Dot): t = le.eval_sub_expr(env, 1) if isinstance(t, stone_object.StoneObject): return self.set_field(t, p.postfix(0), rvalue) return super(AssignEx, self).compute_assign(env, rvalue)
def eval(self, caller_env, value): if not value.__class__ == native_function.NativeFunction: return super(NativeArgEx, self).eval(caller_env, value) func = value nparams = func.num_of_parameters() if self.size() != nparams: raise exception.StoneException("bad number of arguments", self) args = [] for a in self.children(): args.append(a.eval(caller_env)) return func.invoke(args, self)
def eval(self, env, value): if isinstance(value, opt_stone_object.OptStoneObject): target = value if target.class_info() != self.class_info: self.update_cache(target) if self.is_field: return target.read(self.index) else: return target.method(self.index) else: return super(DotEx2, self).eval(env, value)
def compute_assign(self, env, rvalue): le = self.left() if isinstance(le, expression.PrimaryExpr): p = le if p.has_postfix(0) and isinstance(p.postfix(0), fun.ArrayRef): a = le.eval_sub_expr(env, 1) if isinstance(a, list): aref = p.postfix(0) index = aref.index().eval(env) if isinstance(index, int): a[index] = rvalue return rvalue raise exception.StoneException("bad array access", self) return super(AssignEx, self).compute_assign(env, rvalue)
def __init__(self, list_of_astree): super(BinaryEx2, self).__init__(list_of_astree)
def __init__(self, list_of_astree): super(ParamsEx, self).__init__(list_of_astree)
def __init__(self, list_of_astree): super(ArgumentsEx, self).__init__(list_of_astree)
def __init__(self, list_of_astree): super(PostfixEx, self).__init__(list_of_astree)
def __init__(self, list_of_astree): super(ParamsEx, self).__init__(list_of_astree) self.offsets = None
def __init__(self, list_of_astree): super(DefStmntEx, self).__init__(list_of_astree)
def __init__(self, list_of_astree): super(ClassBodyEx, self).__init__(list_of_astree)
def __init__(self, list_of_astree): super(NativeArgEx, self).__init__(list_of_astree)
def __init__(self, list_of_astree): super(DotEx2, self).__init__(list_of_astree) self.class_info = None self.is_field = False self.index = 0
def __init__(self, list_of_astree): super(AssignEx2, self).__init__(self, list_of_astree) self.class_info = None self.index = 0
def __init__(self, t): super(NameEx2, self).__init__(t)
def __init__(self, list_of_astree): super(ASTListEx, self).__init__(list_of_astree)
def __init__(self, list_of_astree): super(AssignEx, self).__init__(list_of_astree)
def __init__(self, list_of_astree): super(FunEx, self).__init__(list_of_astree) self.size = -1
def __init__(self, list_of_astree): super(PrimaryEx, self).__init__(list_of_astree)
def __init__(self, token): super(NameEx, self).__init__(token)
def __init__(self, list_of_astree): super(ArrayRefEx, self).__init__(list_of_astree)