Author: Stephan <[email protected]>
Branch:
Changeset: r149:38486b303a41
Date: 2011-11-02 13:11 +0100
http://bitbucket.org/pypy/lang-js/changeset/38486b303a41/
Log: do not pass context do W_Root#Get
diff --git a/js/builtins.py b/js/builtins.py
--- a/js/builtins.py
+++ b/js/builtins.py
@@ -381,7 +381,7 @@
class W_ArrayPush(W_NewBuiltin):
def Call(self, ctx, args=[], this=None):
- n = this.Get(ctx, 'length').ToUInt32(ctx)
+ n = this.Get('length').ToUInt32(ctx)
for arg in args:
this.Put(ctx, str(n), arg)
n += 1
@@ -391,13 +391,13 @@
class W_ArrayPop(W_NewBuiltin):
def Call(self, ctx, args=[], this=None):
- len = this.Get(ctx, 'length').ToUInt32(ctx)
+ len = this.Get('length').ToUInt32(ctx)
if(len == 0):
return w_Undefined
else:
indx = len-1
indxstr = str(indx)
- element = this.Get(ctx, indxstr)
+ element = this.Get(indxstr)
this.Delete(indxstr)
this.Put(ctx, 'length', W_IntNumber(indx))
return element
@@ -405,7 +405,7 @@
class W_ArrayReverse(W_NewBuiltin):
length = 0
def Call(self, ctx, args=[], this=None):
- r2 = this.Get(ctx, 'length').ToUInt32(ctx)
+ r2 = this.Get('length').ToUInt32(ctx)
k = r_uint(0)
r3 = r_uint(math.floor( float(r2)/2.0 ))
if r3 == k:
@@ -416,8 +416,8 @@
r7 = str(k)
r8 = str(r6)
- r9 = this.Get(ctx, r7)
- r10 = this.Get(ctx, r8)
+ r9 = this.Get(r7)
+ r10 = this.Get(r8)
this.Put(ctx, r7, r10)
this.Put(ctx, r8, r9)
@@ -429,7 +429,7 @@
length = 1
#XXX: further optimize this function
def Call(self, ctx, args=[], this=None):
- length = this.Get(ctx, 'length').ToUInt32(ctx)
+ length = this.Get('length').ToUInt32(ctx)
# According to ECMA-262 15.4.4.11, non-existing properties always come
after
# existing values. Undefined is always greater than any other value.
@@ -442,7 +442,7 @@
if not this.HasProperty(P):
# non existing property
continue
- obj = this.Get(ctx, str(i))
+ obj = this.Get(str(i))
if obj is w_Undefined:
undefs += 1
continue
@@ -513,11 +513,11 @@
return W_ValueValueOf
def common_join(ctx, this, sep=','):
- length = this.Get(ctx, 'length').ToUInt32(ctx)
+ length = this.Get('length').ToUInt32(ctx)
l = []
i = 0
while i < length:
- item = this.Get(ctx, str(i))
+ item = this.Get(str(i))
if isnull_or_undefined(item):
item_string = ''
else:
@@ -701,7 +701,7 @@
return Value.ToObject(ctx)
def create_array(ctx, elements=[]):
- proto = ctx.get_global().Get(ctx, 'Array').Get(ctx, 'prototype')
+ proto = ctx.get_global().Get('Array').Get('prototype')
# TODO do not get array prototype from global context?
assert isinstance(proto, W_PrimitiveObject)
array = W_Array(ctx, Prototype=proto, Class = proto.Class)
diff --git a/js/jsexecution_context.py b/js/jsexecution_context.py
--- a/js/jsexecution_context.py
+++ b/js/jsexecution_context.py
@@ -11,7 +11,7 @@
def resolve_identifier(self, ctx, identifier):
if self.ctx_obj is not None and self.ctx_obj.HasProperty(identifier):
- return self.ctx_obj.Get(ctx, identifier);
+ return self.ctx_obj.Get(identifier);
try:
return self.get_property_value(identifier)
diff --git a/js/jsobj.py b/js/jsobj.py
--- a/js/jsobj.py
+++ b/js/jsobj.py
@@ -54,7 +54,7 @@
def ToUInt32(self, ctx):
return r_uint32(0)
- def Get(self, ctx, P):
+ def Get(self, P):
raise NotImplementedError(self.__class__)
def Put(self, ctx, P, V, flags = 0):
@@ -132,7 +132,7 @@
def __repr__(self):
return '<W_ContextObject (%s)>' % (repr(self.context),)
- def Get(self, ctx, name):
+ def Get(self, name):
try:
return self.context.get_property_value(name)
except KeyError:
@@ -222,25 +222,25 @@
def Construct(self, ctx, args=[]):
obj = W_Object(Class='Object')
- prot = self.Get(ctx, 'prototype')
+ 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(ctx, 'Object').Get(ctx,
'prototype')
+ obj.Prototype = ctx.get_global().Get('Object').Get('prototype')
try: #this is a hack to be compatible to spidermonkey
self.Call(ctx, args, this=obj)
return obj
except ReturnException, e:
return e.value
- def Get(self, ctx, P):
+ 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(ctx, P) # go down the prototype chain
+ return self.Prototype.Get(P) # go down the prototype chain
def CanPut(self, P):
if self._has_property(P):
@@ -273,12 +273,12 @@
return True
def internal_def_value(self, ctx, tryone, trytwo):
- t1 = self.Get(ctx, tryone)
+ t1 = self.Get(tryone)
if isinstance(t1, W_PrimitiveObject):
val = t1.Call(ctx, this=self)
if isinstance(val, W_Primitive):
return val
- t2 = self.Get(ctx, trytwo)
+ t2 = self.Get(trytwo)
if isinstance(t2, W_PrimitiveObject):
val = t2.Call(ctx, this=self)
if isinstance(val, W_Primitive):
@@ -317,7 +317,7 @@
W_PrimitiveObject.__init__(self, ctx, Prototype, Class, Value)
def ToNumber(self, ctx):
- return self.Get(ctx, 'valueOf').Call(ctx, args=[],
this=self).ToNumber(ctx)
+ return self.Get('valueOf').Call(ctx, args=[], this=self).ToNumber(ctx)
class W_CallableObject(W_Object):
_immutable_fields_ = ['callfunc', 'ctx']
@@ -365,7 +365,7 @@
length = -1
def __init__(self, ctx, Prototype=None, Class='function',
Value=w_Undefined):
if Prototype is None:
- proto = ctx.get_global().Get(ctx, 'Function').Get(ctx, 'prototype')
+ proto = ctx.get_global().Get('Function').Get('prototype')
Prototype = proto
W_PrimitiveObject.__init__(self, ctx, Prototype, Class, Value)
@@ -548,7 +548,7 @@
def ToObject(self, ctx):
return create_object(ctx, 'Number', Value=self)
- def Get(self, ctx, P):
+ def Get(self, P):
return w_Undefined
def type(self):
@@ -681,7 +681,7 @@
return len(self.elements_w) == 0
def create_object(ctx, prototypename, Value=w_Undefined):
- proto = ctx.get_global().Get(ctx, prototypename).Get(ctx, 'prototype')
+ proto = ctx.get_global().Get(prototypename).Get('prototype')
# TODO get Object prototype from interp.w_Object
assert isinstance(proto, W_PrimitiveObject)
obj = W_Object(ctx, Prototype=proto, Class = proto.Class, Value = Value)
diff --git a/js/opcodes.py b/js/opcodes.py
--- a/js/opcodes.py
+++ b/js/opcodes.py
@@ -125,8 +125,9 @@
self.counter = counter
def eval(self, ctx):
- proto = ctx.get_global().Get(ctx, 'Array').Get(ctx, 'prototype')
+ proto = ctx.get_global().Get('Array').Get('prototype')
# TODO get array prototype?
+ # builtins make_array??
assert isinstance(proto, W_PrimitiveObject)
array = W_Array(ctx, Prototype=proto, Class = proto.Class)
for i in range(self.counter):
@@ -159,7 +160,7 @@
self.funcobj = funcobj
def eval(self, ctx):
- proto = ctx.get_global().Get(ctx, 'Function').Get(ctx, 'prototype')
+ proto = ctx.get_global().Get('Function').Get('prototype')
w_func = W_CallableObject(ctx, proto, self.funcobj)
w_func.Put(ctx, 'length', W_IntNumber(len(self.funcobj.params)))
w_obj = create_object(ctx, 'Object')
@@ -204,7 +205,7 @@
def eval(self, ctx):
w_obj = ctx.pop().ToObject(ctx)
name = ctx.pop().ToString(ctx)
- ctx.append(w_obj.Get(ctx, name))
+ ctx.append(w_obj.Get(name))
class COMMA(BaseUnaryOperation):
def eval(self, ctx):
@@ -453,7 +454,7 @@
def eval(self, ctx):
# function declaration actyally don't run anything
- proto = ctx.get_global().Get(ctx, 'Function').Get(ctx, 'prototype')
+ proto = ctx.get_global().Get('Function').Get('prototype')
w_func = W_CallableObject(ctx, proto, self.funcobj)
w_func.Put(ctx, 'length', W_IntNumber(len(self.funcobj.params)))
w_obj = create_object(ctx, 'Object')
@@ -519,7 +520,7 @@
what = ctx.pop().ToObject(ctx)
args = ctx.pop()
name = method.ToString(ctx)
- r1 = what.Get(ctx, name)
+ r1 = what.Get(name)
ctx.append(common_call(ctx, r1, args, what, name))
class DUP(Opcode):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit