[pypy-svn] r29913 - pypy/dist/pypy/translator/js
arigo at codespeak.net
arigo at codespeak.net
Sun Jul 9 19:51:05 CEST 2006
Author: arigo
Date: Sun Jul 9 19:51:04 2006
New Revision: 29913
Modified:
pypy/dist/pypy/translator/js/metavm.py
pypy/dist/pypy/translator/js/opcodes.py
Log:
(pedronis, arigo)
charCodeAt is not a method on 'String', but on strings.
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 9 19:51:04 2006
@@ -103,11 +103,20 @@
def render(self, generator, op):
raise NotImplementedError(self.reason)
-class _CastString(MicroInstruction):
+class _CastMethod(MicroInstruction):
+ def __init__(self, method_name, num=0):
+ self.method_name = method_name
+ self.num = num
+
def render(self, generator, op):
- this = op.args[0]
- generator.load(this)
- generator.call_external_method("toString", 0)
+ generator.call_external_method(self.method_name, self.num)
+
+class _LoadConst(MicroInstruction):
+ def __init__(self, value):
+ self.value = value
+
+ def render(self, generator, op):
+ generator.load(Constant(self.value, ootype.typeOf(self.value)))
class _GetBuiltinField(MicroInstruction):
def render(self, generator, op):
@@ -235,5 +244,5 @@
IsInstance = _IsInstance()
CallMethod = _CallMethod()
CopyName = [PushAllArgs, _SameAs ()]
-CastString = _CastString()
+CastString = _CastMethod("toString")
SameAs = CopyName
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 9 19:51:04 2006
@@ -9,7 +9,7 @@
from pypy.translator.js.metavm import SameAs, IsInstance, Call, CallMethod, CopyName, CastString,\
_Prefix, _CastFun, _NotImplemented, CallBuiltin, CallBuiltinObject, GetBuiltinField, SetBuiltinField,\
- IndirectCall, CallExternalObject, SetExternalField
+ IndirectCall, CallExternalObject, SetExternalField, _CastMethod, _LoadConst
from pypy.translator.js.jsbuiltin import Builtins
@@ -121,7 +121,7 @@
'ooupcast' : DoNothing,
'oodowncast' : DoNothing,
'oononnull' : [PushAllArgs,_Prefix('!!')],
- 'oostring' : [CastString],
+ 'oostring' : [PushArg(0),CastString],
'ooparse_int' : [PushAllArgs,_CastFun("parseInt",2)],
'oois' : '===',
# when casting from bool we want that every truth value is casted
@@ -131,8 +131,8 @@
'cast_bool_to_int': CopyName,
'cast_bool_to_uint': CopyName,
'cast_bool_to_float': CopyName,
- 'cast_char_to_int': [PushAllArgs,_CastFun("String.charCodeAt",1)],
- 'cast_unichar_to_int': [PushAllArgs,_CastFun("String.charCodeAt",1)],
+ 'cast_char_to_int': [PushAllArgs,_LoadConst(0),_CastMethod("charCodeAt",1)],
+ 'cast_unichar_to_int': [PushAllArgs,_LoadConst(0),_CastMethod("charCodeAt",1)],
'cast_int_to_char': [PushAllArgs,_CastFun("String.fromCharCode",1)],
'cast_int_to_unichar': [PushAllArgs,_CastFun("String.fromCharCode",1)],
'cast_int_to_uint': CopyName,
More information about the Pypy-commit
mailing list