[pypy-svn] r56333 - pypy/dist/pypy/translator/js

fijal at codespeak.net fijal at codespeak.net
Sun Jul 6 05:22:00 CEST 2008


Author: fijal
Date: Sun Jul  6 05:21:59 2008
New Revision: 56333

Modified:
   pypy/dist/pypy/translator/js/metavm.py
   pypy/dist/pypy/translator/js/opcodes.py
Log:
Implement classof


Modified: pypy/dist/pypy/translator/js/metavm.py
==============================================================================
--- pypy/dist/pypy/translator/js/metavm.py	(original)
+++ pypy/dist/pypy/translator/js/metavm.py	Sun Jul  6 05:21:59 2008
@@ -146,11 +146,14 @@
         generator.get_field(None, field)
 
 class _GetPredefinedField(MicroInstruction):
-    def __init__(self, field):
+    def __init__(self, field, num=1):
         self.field = field
+        self.num = num
 
     def render(self, generator, op):
-        this = op.args[1]
+        if op.result.concretetype is ootype.Void:
+            return
+        this = op.args[self.num]
         generator.load(this)
         generator.get_field(None, self.field)
 

Modified: pypy/dist/pypy/translator/js/opcodes.py
==============================================================================
--- pypy/dist/pypy/translator/js/opcodes.py	(original)
+++ pypy/dist/pypy/translator/js/opcodes.py	Sun Jul  6 05:21:59 2008
@@ -12,7 +12,7 @@
      CopyName, CastString, _Prefix, _CastFun, _NotImplemented, CallBuiltin,\
      CallBuiltinObject, GetBuiltinField, SetBuiltinField, IndirectCall,\
      CallExternalObject, SetExternalField, _CastMethod, _LoadConst,\
-     DiscardStack, CheckLength, fix_opcodes
+     DiscardStack, CheckLength, fix_opcodes, _GetPredefinedField
 
 from pypy.translator.js.jsbuiltin import Builtins
 from pypy.rpython.ootypesystem import ootype
@@ -153,6 +153,8 @@
     'cast_float_to_uint':       [PushAllArgs,_CastFun("Math.floor",1)],
     'cast_float_to_longlong':   [PushAllArgs,_CastFun("Math.floor",1)],
     'truncate_longlong_to_int': CopyName,
+
+    'classof' : [_GetPredefinedField('_class', 0)],
     
     'debug_assert' : DoNothing,
     'resume_point' : DoNothing,



More information about the Pypy-commit mailing list