daily pastebin goal
17%
SHARE
TWEET

Untitled

a guest Apr 16th, 2018 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. from pypy.translator.avm2.util import serialize_u32 as u32, Avm2Label
  3. from pypy.translator.avm2.constants import METHODFLAG_Activation, METHODFLAG_SetsDxns
  4. from decorator import decorator
  5.  
  6. INSTRUCTIONS = {}
  7.  
  8. @decorator
  9. def needs_specialized(fn, self, *args, **kwargs):
  10.       if not self.specialized:
  11.             raise ValueError, "Instruction needs to be specialized"
  12.       return fn(self, *args, **kwargs)
  13.  
  14. class _Avm2SpecializedInstruction(object):
  15.       pass
  16.  
  17. class _Avm2ShortInstruction(object):
  18.       specialized=False
  19.       def __init__(self, opcode, name, stack=0, scope=0, flags=0):
  20.             self.opcode = opcode
  21.             self.name   = name
  22.             self.stack  = stack
  23.             self.scope  = scope
  24.             self.flags  = flags
  25.  
  26.             INSTRUCTIONS[opcode] = self
  27.  
  28.       def _repr(self):
  29.             return "%s (0x%H)" % (self.name, self.opcode)
  30.      
  31.       def _set_assembler_props(self, asm):
  32.             asm.flags |= self.flags
  33.             asm.stack_depth += self.stack
  34.             asm.scope_depth += self.scope
  35.  
  36.       def _serialize(self):
  37.             return chr(self.opcode)
  38.  
  39.       serialize = _serialize
  40.       set_assembler_props = _set_assembler_props
  41.       __repr__ = _repr
  42.      
  43.       def specialize(self, **kwargs):
  44.             return type("_Avm2_Instruction_%s" % self.name,
  45.                          (_Avm2SpecializedInstruction, self.__class__),
  46.                          dict(kwargs.items(),
  47.                                specialized=True,
  48.                                set_assembler_props=self._set_assembler_props,
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top