def _end_gen_constants(self, gen, numsteps): gen.begin_class(jPyPyConstantInit, jvm.jObject) gen.begin_j_function(jPyPyConstantInit, jPyPyConstantInitMethod) for cls in self.step_classes: m = Method.s(cls, "constant_init", [], jVoid) gen.emit(m) gen.return_val(jVoid) gen.end_function() gen.end_class()
from rpython.rtyper.ootypesystem import ootype from rpython.flowspace import model as flowmodel import rpython.translator.jvm.typesystem as jvm from rpython.translator.jvm.typesystem import \ jVoid, Method, Field from rpython.translator.oosupport.constant import \ BaseConstantGenerator, RecordConst, InstanceConst, ClassConst, \ StaticMethodConst, CustomDictConst, WeakRefConst, push_constant, \ MAX_CONST_PER_STEP jPyPyConstantInit = jvm.JvmClassType('pypy.ConstantInit') jPyPyConstantInitMethod = Method.s(jPyPyConstantInit, 'init', [], jVoid) # ___________________________________________________________________________ # Constant Generator class JVMConstantGenerator(BaseConstantGenerator): MAX_INSTRUCTION_COUNT = 20000 def __init__(self, db): BaseConstantGenerator.__init__(self, db) self.num_constants = 0 self.ccs = [] def runtime_init(self, gen): """ Called from node.EntryPoint to generate code that initializes all of the constants. Right now, this invokes a known static method, but this should probably be changed eventually. """
from rpython.rtyper.ootypesystem import ootype from rpython.flowspace import model as flowmodel import rpython.translator.jvm.typesystem as jvm from rpython.translator.jvm.typesystem import \ jVoid, Method, Field from rpython.translator.oosupport.constant import \ BaseConstantGenerator, RecordConst, InstanceConst, ClassConst, \ StaticMethodConst, CustomDictConst, WeakRefConst, push_constant, \ MAX_CONST_PER_STEP jPyPyConstantInit = jvm.JvmClassType('pypy.ConstantInit') jPyPyConstantInitMethod = Method.s(jPyPyConstantInit, 'init', [], jVoid) # ___________________________________________________________________________ # Constant Generator class JVMConstantGenerator(BaseConstantGenerator): MAX_INSTRUCTION_COUNT = 20000 def __init__(self, db): BaseConstantGenerator.__init__(self, db) self.num_constants = 0 self.ccs = [] def runtime_init(self, gen): """ Called from node.EntryPoint to generate code that initializes all of the constants. Right now, this invokes a known static method, but this should probably be changed eventually.