def eval(self, context): ref = self.reference.eval(context) value = js.get_value(self.expression.eval(context)) if self.op == '=': js.put_value(ref, value) return value else: new_value = perform_binary_op(self.op[:-1], js.get_value(ref), value) js.put_value(ref, new_value) return new_value
def eval(self, context): expr = self.expression.eval(context) value = js.get_value(expr) if self.op == 'delete': # TODO return True elif self.op == 'void': return js.UNDEFINED elif self.op == 'typeof': # TODO return 'object' elif self.op == '++': new_value = value + 1 js.put_value(expr, new_value) return new_value elif self.op == '--': new_value = value - 1 js.put_value(expr, new_value) return new_value elif self.op == 'postfix++': old_value = value js.put_value(expr, old_value + 1) return old_value elif self.op == 'postfix--': old_value = value js.put_value(expr, old_value - 1) return old_value elif self.op == '+': return +value elif self.op == '-': return -value elif self.op == '~': return ~value elif self.op == '!': return not value else: raise SyntaxError('Unknown unary operand: %s' % self.op)
def eval(self, context): ref = self.identifier.eval(context) value = js.get_value(self.initialiser.eval(context)) js.put_value(ref, value) return js.Completion(js.NORMAL, ref.name, js.EMPTY)