[pypy-commit] lang-js default: removed old code
stepahn
noreply at buildbot.pypy.org
Fri Dec 28 11:33:03 CET 2012
Author: Stephan <stephan at stzal.com>
Branch:
Changeset: r165:20c904e5be39
Date: 2011-12-21 13:55 +0100
http://bitbucket.org/pypy/lang-js/changeset/20c904e5be39/
Log: removed old code
diff --git a/js/jsobj.py b/js/jsobj.py
--- a/js/jsobj.py
+++ b/js/jsobj.py
@@ -507,222 +507,6 @@
def ToString(self):
return self._function_.ToString()
-#class W_PrimitiveObject(W_Root):
- #_immutable_fields_ = ['Class', 'Prototype', 'Scope', 'Value']
- #def __init__(self, Prototype=None, Class='Object', Value=w_Undefined):
- #self.Prototype = Prototype
- #self.property_map = root_map()
- #self.property_values = []
- #if Prototype is None:
- #Prototype = w_Undefined
- #self._set_property('prototype', Prototype, DONT_ENUM | DONT_DELETE)
- #self.Class = Class
- #self.Scope = None
- #self.Value = Value
-
- #def _set_property(self, name, value, flags):
- #if self.property_map.lookup(name) == self.property_map.NOT_FOUND:
- #self.property_map = self.property_map.add(name, flags)
- #self._set_property_value(name, value)
- #self._set_property_flags(name, flags)
-
- #def _set_property_value(self, name, value):
- #idx = self.property_map.lookup(name)
- #l = len(self.property_values)
-
- #if l <= idx:
- #self.property_values = self.property_values + ([None] * (idx - l + 1))
-
- #self.property_values[idx] = value
-
- #def _set_property_flags(self, name, flags):
- #self.property_map = self.property_map.set_flags(name, flags)
-
- #def _get_property_value(self, name):
- #idx = self.property_map.lookup(name)
- #if idx == self.property_map.NOT_FOUND:
- #raise KeyError
- #return self.property_values[idx]
-
- #def _get_property_flags(self, name):
- #flag = self.property_map.lookup_flag(name)
- #if flag == self.property_map.NOT_FOUND:
- #raise KeyError
- #return flag
-
- #def _has_property(self, name):
- #return self.property_map.lookup(name) != self.property_map.NOT_FOUND
-
- #@jit.unroll_safe
- #def _delete_property(self, name):
- #idx = self.property_map.lookup(name)
- #old_map = self.property_map
- #new_map = self.property_map.delete(name)
- #new_keys = new_map.keys()
- #new_values = [None] * len(new_keys)
- #old_values = self.property_values
-
- #for key in new_keys:
- #old_index = old_map.lookup(key)
- #new_index = new_map.lookup(key)
- #new_values[new_index] = old_values[old_index]
-
- #self.property_values = new_values
- #self.property_map = new_map
-
- #def _get_property_keys(self):
- #return self.property_map.keys()
-
- #def Call(self, args=[], this=None):
- #raise JsTypeError('not a function')
-
- #def Construct(self, args=[]):
- #obj = W_Object(Class='Object')
- #prot = self.Get('prototype')
- #if isinstance(prot, W_PrimitiveObject):
- #obj.Prototype = prot
- #else: # would love to test this
- ##but I fail to find a case that falls into this
- ##obj.Prototype = ctx.get_global().Get('Object').Get('prototype')
- #from js.builtins import get_builtin_prototype
- #obj.Prototype = get_builtin_prototype('Object')
- #try: #this is a hack to be compatible to spidermonkey
- #self.Call(args, this=obj)
- #return obj
- #except ReturnException, e:
- #return e.value
-
- #def Get(self, P):
- #try:
- #return self._get_property_value(P)
- #except KeyError:
- #if self.Prototype is None:
- #return w_Undefined
- #return self.Prototype.Get(P) # go down the prototype chain
-
- #def CanPut(self, P):
- #if self._has_property(P):
- #if self._get_property_flags(P) & READ_ONLY: return False
- #return True
- #if self.Prototype is None: return True
- #return self.Prototype.CanPut(P)
-
- #def Put(self, P, V, flags = 0):
- #if self._has_property(P):
- #self._set_property_value(P, V)
- #f = self._get_property_flags(P) | flags
- #self._set_property_flags(P, f)
- #return
-
- #if not self.CanPut(P): return
- #self._set_property(P, V, flags)
-
- #def HasProperty(self, P):
- #if self._has_property(P): return True
- #if self.Prototype is None: return False
- #return self.Prototype.HasProperty(P)
-
- #def Delete(self, P):
- #if self._has_property(P):
- #if self._get_property_flags(P) & DONT_DELETE:
- #return False
- #self._delete_property(P)
- #return True
- #return True
-
- #def internal_def_value(self, tryone, trytwo):
- ## XXX: redo this!
- #t1 = self.Get(tryone)
- #if isinstance(t1, W_PrimitiveObject):
- #val = t1.Call(this=self)
- #if isinstance(val, W__Primitive):
- #return val
- #t2 = self.Get(trytwo)
- #if isinstance(t2, W_PrimitiveObject):
- #val = t2.Call(this=self)
- #if isinstance(val, W__Primitive):
- #return val
- #raise JsTypeError
-
- #def DefaultValue(self, hint=""):
- #if hint == "String":
- #return self.internal_def_value("toString", "valueOf")
- #else: # hint can only be empty, String or Number
- #return self.internal_def_value("valueOf", "toString")
-
- #ToPrimitive = DefaultValue
-
- #def ToBoolean(self):
- #return True
-
- #def ToString(self):
- #try:
- #res = self.ToPrimitive('String')
- #except JsTypeError:
- #return "[object %s]"%(self.Class,)
- #return res.ToString()
-
- #def __str__(self):
- #return "<Object class: %s>" % self.Class
-
- #def type(self):
- #return 'object'
-
-#class W_Object(W_PrimitiveObject):
- #def __init__(self, Prototype=None, Class='Object', Value=w_Undefined):
- #W_PrimitiveObject.__init__(self, Prototype, Class, Value)
-
- #def ToNumber(self):
- #return self.Get('valueOf').Call(args=[], this=self).ToNumber()
-
-#class W_CallableObject(W_Object):
- #_immutable_fields_ = ['callfunc', 'ctx']
- #def __init__(self, ctx, Prototype, callfunc):
- #W_Object.__init__(self, Prototype, 'Function')
- #self.ctx = ctx
- #self.callfunc = callfunc
-
- #@jit.unroll_safe
- #def Call(self, args=[], this=None):
- #from js.jsexecution_context import make_activation_context, make_function_context
-
- #w_Arguments = W_Arguments(self, args)
- #act = make_activation_context(self.ctx, this, w_Arguments)
- #newctx = make_function_context(act, self.callfunc)
-
- #paramn = len(self.callfunc.params)
- #for i in range(paramn):
- #paramname = self.callfunc.params[i]
- #try:
- #value = args[i]
- #except IndexError:
- #value = w_Undefined
- #newctx.declare_variable(paramname)
- #newctx.assign(paramname, value)
-
- #val = self.callfunc.run(ctx=newctx, save_stack = False)
- #return val
-
- #def type(self):
- #return 'function'
-
-#class W_Builtin(W_PrimitiveObject):
- #def __init__(self, builtin=None, Prototype=None, Class='function', Value=w_Undefined):
- #W_PrimitiveObject.__init__(self, Prototype, Class, Value)
- #self.set_builtin_call(builtin)
-
- #def set_builtin_call(self, callfuncbi):
- #self.callfuncbi = callfuncbi
-
- #def Call(self, args=[], this = None):
- #return self.callfuncbi(args, this)
-
- #def Construct(self, args=[]):
- #return self.callfuncbi(args, None)
-
- #def type(self):
- #return self.Class
-
class W_Arguments(W_BasicObject):
def tolist(self):
l = []
@@ -740,15 +524,6 @@
self.Put(str(i), args[i])
self.length = len(args)
-#class ActivationObject(W_PrimitiveObject):
- #"""The object used on function calls to hold arguments and this"""
- #def __init__(self):
- #W_PrimitiveObject.__init__(self, Class='Activation')
- #self._delete_property('prototype')
-
- #def __repr__(self):
- #return str(self.property_map)
-
class W_ArrayConstructor(W_BasicObject):
def IsCallable(self):
return True
More information about the pypy-commit
mailing list