Beispiel #1
0
    def _add_methods(self):
        from pypy.translator.jvm.generator import Method

        for methname, methspec in self.OOTYPE._class_._methods.items():
            argtypes = [self.db.annotation_to_cts(arg._type) for arg in methspec.args]
            restype = self.db.annotation_to_cts(methspec.retval._type)
            self.methods[methname] = Method.v(self, methname, argtypes, restype)
Beispiel #2
0
 def _add_methods(self):
     from pypy.translator.jvm.generator import Method
     for methname, methspec in self.OOTYPE._class_._methods.items():
         argtypes = [
             self.db.annotation_to_cts(arg._type) for arg in methspec.args
         ]
         restype = self.db.annotation_to_cts(methspec.retval._type)
         self.methods[methname] = Method.v(self, methname, argtypes,
                                           restype)
Beispiel #3
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()
Beispiel #4
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()
Beispiel #5
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()
Beispiel #6
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):
Beispiel #7
0
 def putter_method_obj(node):
     return Method.v(node, methodnm + "_p", [fieldty], jVoid)
Beispiel #8
0
 def getter_method_obj(node):
     return Method.v(node, methodnm + "_g", [], fieldty)
Beispiel #9
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
Beispiel #10
0
 def putter_method_obj(node):
     return Method.v(node, methodnm+"_p", [fieldty], jVoid)
Beispiel #11
0
 def getter_method_obj(node):
     return Method.v(node, methodnm+"_g", [], fieldty)