micropython

Changeset

402:c87bdb84d9d3
2011-02-27 Paul Boddie raw files shortlog changelog graph Introduced placeholder functions for print in order to let all tests pass. Added TestIdentity and status-related optimisation suggestions.
TO_DO.txt (file) rsvplib.py (file)
     1.1 --- a/TO_DO.txt	Sun Feb 27 02:45:38 2011 +0100
     1.2 +++ b/TO_DO.txt	Sun Feb 27 17:38:50 2011 +0100
     1.3 @@ -1,22 +1,3 @@
     1.4 -Permit __class__ as being differently defined for classes and instances. Since __class__
     1.5 -is always defined, no shadowing may occur for the attribute exposing it at different
     1.6 -levels.
     1.7 -
     1.8 -  The instance definition of __class__ should be stored in the object table.
     1.9 -
    1.10 -  Each common definition for instances of a class shall be stored as the first
    1.11 -  attribute of each class.
    1.12 -
    1.13 -  Access to __class__ has to be detected and a special instruction (sequence)
    1.14 -  generated to handle the class/instance logic.
    1.15 -
    1.16 -  The type class should be exposed as each class's __class__ attribute.
    1.17 -
    1.18 -  Note that object table information will not be able to reflect the class-type
    1.19 -  relationship, but isinstance will need to check for instances and classes, anyway.
    1.20 -
    1.21 -Tuple references to stack locations in a merged stack/heap memory model.
    1.22 -
    1.23  Attribute Usage
    1.24  ===============
    1.25  
    1.26 @@ -111,3 +92,12 @@
    1.27  __getitem__ could be written in Python, using a native method only to access fragments.
    1.28  
    1.29  Consider better "macro" support where new expressions need to be generated and processed.
    1.30 +
    1.31 +Detect TestIdentity results involving constants, potentially optimising status-affected
    1.32 +instructions:
    1.33 +
    1.34 +  TestIdentity(x, y) # where x is always y
    1.35 +  JumpIfFalse(...)   # would be removed (never false)
    1.36 +  JumpIfTrue(...)    # changed to Jump(...)
    1.37 +
    1.38 +Status-affected blocks could be optimised away for such constant-related results.
     2.1 --- a/rsvplib.py	Sun Feb 27 02:45:38 2011 +0100
     2.2 +++ b/rsvplib.py	Sun Feb 27 17:38:50 2011 +0100
     2.3 @@ -445,6 +445,14 @@
     2.4          else:
     2.5              self.machine.result = DataValue(self.constants[False], self.constants[False])
     2.6  
     2.7 +    def builtins_print(self):
     2.8 +        # NOTE: Do nothing for now.
     2.9 +        pass
    2.10 +
    2.11 +    def builtins_printnl(self):
    2.12 +        # NOTE: Do nothing for now.
    2.13 +        pass
    2.14 +
    2.15      native_functions = {
    2.16  
    2.17          # Native method implementations:
    2.18 @@ -491,6 +499,8 @@
    2.19          # Native helper functions:
    2.20  
    2.21          "__builtins__._isinstance" : builtins_isinstance,
    2.22 +        "__builtins__._print" : builtins_print,
    2.23 +        "__builtins__._printnl" : builtins_printnl,
    2.24          }
    2.25  
    2.26  # vim: tabstop=4 expandtab shiftwidth=4