Author: Stephan <step...@stzal.com>
Branch: 
Changeset: r341:301dfd045fd3
Date: 2013-01-09 11:09 +0100
http://bitbucket.org/pypy/lang-js/changeset/301dfd045fd3/

Log:    cleaned up commoncall and commonnew

diff --git a/js/opcodes.py b/js/opcodes.py
--- a/js/opcodes.py
+++ b/js/opcodes.py
@@ -638,16 +638,17 @@
         ctx.stack_pop()
 
 
-def common_call(ctx, r1, args, this, name):
-    from js.jsobj import W_BasicFunction, W_List
+def common_call(ctx, funcobj, args, this, identifyer):
+    if not funcobj.is_callable():
+        err = u"%s is not a callable (%s)" % (funcobj.to_string(), 
identifyer.to_string())
+        raise JsTypeError(err)
+
+    from js.jsobj import W_List, W_BasicFunction
     assert isinstance(args, W_List)
-    # TODO
-    if not (isinstance(r1, W_BasicFunction)):
-        #err = (u"%s is not a callable (%s)"%(r1.to_string(), 
name.to_string()))
-        err = u"is not a callable (%s)" % (r1.to_string())
-        raise JsTypeError(err)
+    assert isinstance(funcobj, W_BasicFunction)
+
     argv = args.to_list()
-    res = r1.Call(args=argv, this=this, calling_context=ctx)
+    res = funcobj.Call(args=argv, this=this, calling_context=ctx)
     return res
 
 
@@ -758,10 +759,12 @@
 
 
 def commonnew(ctx, obj, args):
+    if not obj.is_callable():
+        msg = u'%s is not a constructor' % (obj.to_string())
+        raise JsTypeError(msg)
+
     from js.jsobj import W_BasicFunction
-
-    if not isinstance(obj, W_BasicFunction):
-        raise JsTypeError(u'not a constructor')
+    assert isinstance(obj, W_BasicFunction)
     res = obj.Construct(args=args)
     return res
 
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to