Exemple #1
0
    def _end_gen_constants(self, gen, numsteps):
        gen.begin_class(jPyPyConstantInit, 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()
Exemple #2
0
    def _end_gen_constants(self, gen, numsteps):
        gen.begin_class(jPyPyConstantInit, 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()
Exemple #3
0
 def _end_gen_constants(self, gen, numsteps):
     # The static init code just needs to call constant_init_1..N
     gen.begin_function('<clinit>', [], [], jVoid, True)
     for x in range(numsteps):
         m = Method.s(jPyPyConst, "constant_init_%d" % x, [], jVoid)
         gen.emit(m)
     gen.return_val(jVoid)
     gen.end_function()
     
     gen.end_class()
Exemple #4
0
from pypy.translator.jvm.generator import Field, Method, CUSTOMDICTMAKE
from pypy.translator.oosupport.constant import (
    BaseConstantGenerator,
    RecordConst,
    InstanceConst,
    ClassConst,
    StaticMethodConst,
    CustomDictConst,
    WeakRefConst,
    push_constant,
    MAX_CONST_PER_STEP,
)
from pypy.translator.jvm.typesystem import jObject, jVoid, jPyPyWeakRef, JvmClassType

jPyPyConstantInit = 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):
Exemple #5
0
from pypy.rpython.ootypesystem import ootype
from pypy.objspace.flow import model as flowmodel
from pypy.translator.jvm.generator import \
     Field, Method, CUSTOMDICTMAKE
from pypy.translator.oosupport.constant import \
     BaseConstantGenerator, RecordConst, InstanceConst, ClassConst, \
     StaticMethodConst, CustomDictConst, WeakRefConst, push_constant, \
     MAX_CONST_PER_STEP
from pypy.translator.jvm.typesystem import \
     jObject, jVoid, jPyPyWeakRef, JvmClassType

jPyPyConstantInit = 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