Exemplo n.º 1
0
 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
Exemplo n.º 2
0
 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
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
 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)
Exemplo n.º 5
0
 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)
Exemplo n.º 6
0
 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)