javaclass

Changeset

13:5f0832d56165
2004-11-09 Paul Boddie raw files shortlog changelog graph Added usage of name translation. Added notes on proper exception handling.
bytecode.py (file)
     1.1 --- a/bytecode.py	Tue Nov 09 01:20:19 2004 +0100
     1.2 +++ b/bytecode.py	Tue Nov 09 01:25:47 2004 +0100
     1.3 @@ -492,7 +492,12 @@
     1.4  
     1.5              # Insert exception handler end details.
     1.6              for exception in exception_block_end.get(self.java_position, []):
     1.7 +                # NOTE: Insert jump beyond handlers.
     1.8 +                # NOTE: program.jump_forward/absolute(...)
     1.9                  program.end_exception()
    1.10 +                # NOTE: Insert a check for the correct exception at the start of each handler.
    1.11 +                # NOTE: Insert end finally at end of handlers as well as where "ret" occurs.
    1.12 +                # NOTE: Ensure that pop_block is reachable by possibly inserting it at the start of finally handlers.
    1.13  
    1.14              # Where handlers are begun, do not produce equivalent bytecode since
    1.15              # the first handler instruction typically involves saving a local
    1.16 @@ -987,13 +992,13 @@
    1.17  
    1.18      def getfield(self, arguments, program):
    1.19          index = (arguments[0] << 8) + arguments[1]
    1.20 -        target_name = self.class_file.constants[index - 1].get_name()
    1.21 +        target_name = self.class_file.constants[index - 1].get_python_name()
    1.22          # NOTE: Using the string version of the name which may contain incompatible characters.
    1.23          program.load_attr(str(target_name))
    1.24  
    1.25      def getstatic(self, arguments, program):
    1.26          index = (arguments[0] << 8) + arguments[1]
    1.27 -        target_name = self.class_file.constants[index - 1].get_name()
    1.28 +        target_name = self.class_file.constants[index - 1].get_python_name()
    1.29          program.load_name("self")
    1.30          program.load_attr("__class__")
    1.31          # NOTE: Using the string version of the name which may contain incompatible characters.
    1.32 @@ -1183,7 +1188,7 @@
    1.33          # NOTE: Java rules not specifically obeyed.
    1.34          index = (arguments[0] << 8) + arguments[1]
    1.35          count = arguments[2]
    1.36 -        target_name = self.class_file.constants[index - 1].get_name()
    1.37 +        target_name = self.class_file.constants[index - 1].get_python_name()
    1.38          # Stack: objectref, arg1, arg2, ...
    1.39          program.build_tuple(count)          # Stack: objectref, tuple
    1.40          program.rot_two()                   # Stack: tuple, objectref
    1.41 @@ -1195,7 +1200,7 @@
    1.42          # NOTE: Java rules not specifically obeyed.
    1.43          index = (arguments[0] << 8) + arguments[1]
    1.44          target = self.class_file.constants[index - 1]
    1.45 -        target_name = target.get_name()
    1.46 +        target_name = target.get_python_name()
    1.47          # Get the number of parameters from the descriptor.
    1.48          count = len(target.get_descriptor()[0])
    1.49          # Stack: objectref, arg1, arg2, ...
    1.50 @@ -1228,7 +1233,7 @@
    1.51          # NOTE: Java rules not specifically obeyed.
    1.52          index = (arguments[0] << 8) + arguments[1]
    1.53          target = self.class_file.constants[index - 1]
    1.54 -        target_name = target.get_name()
    1.55 +        target_name = target.get_python_name()
    1.56          # Get the number of parameters from the descriptor.
    1.57          count = len(target.get_descriptor()[0])
    1.58          # Stack: arg1, arg2, ...
    1.59 @@ -1429,14 +1434,14 @@
    1.60  
    1.61      def putfield(self, arguments, program):
    1.62          index = (arguments[0] << 8) + arguments[1]
    1.63 -        target_name = self.class_file.constants[index - 1].get_name()
    1.64 +        target_name = self.class_file.constants[index - 1].get_python_name()
    1.65          program.rot_two()
    1.66          # NOTE: Using the string version of the name which may contain incompatible characters.
    1.67          program.store_attr(str(target_name))
    1.68  
    1.69      def putstatic(self, arguments, program):
    1.70          index = (arguments[0] << 8) + arguments[1]
    1.71 -        target_name = self.class_file.constants[index - 1].get_name()
    1.72 +        target_name = self.class_file.constants[index - 1].get_python_name()
    1.73          program.load_name("self")
    1.74          program.load_attr("__class__")
    1.75          # NOTE: Using the string version of the name which may contain incompatible characters.