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()
import pypy.translator.jvm.typesystem as jvm from pypy.translator.jvm.typesystem import jVoid, Method, Field from pypy.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):
from pypy.rpython.ootypesystem import ootype from pypy.objspace.flow import model as flowmodel import pypy.translator.jvm.typesystem as jvm from pypy.translator.jvm.typesystem import \ jVoid, Method, Field from pypy.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.