1.1 --- a/micropython/rsvp.py Wed Aug 27 00:45:14 2008 +0200
1.2 +++ b/micropython/rsvp.py Mon Sep 01 01:32:32 2008 +0200
1.3 @@ -20,13 +20,39 @@
1.4 """
1.5
1.6 from micropython.common import Label
1.7 -from micropython.data import Attr, Const, Instance
1.8 +from micropython.data import Attr, Class, Const, Function
1.9
1.10 -def raw(code):
1.11 +def raw(code, objtable, paramtable):
1.12 new_code = []
1.13 for item in code:
1.14 if isinstance(item, Attr):
1.15 - new_code.append((item.context and item.context.location, item.value and item.value.location)) # no useful context is provided
1.16 + new_code.append((
1.17 + item.context and item.context.location,
1.18 + item.value and item.value.location # no useful context is provided
1.19 + ))
1.20 + elif isinstance(item, Class):
1.21 + # NOTE: Need initialiser details!
1.22 + new_code.append((
1.23 + objtable.as_list().get_code(item.full_name()),
1.24 + objtable.get_index(item.full_name()),
1.25 + item.get_instantiator().code_location,
1.26 + len(item.get_instantiator().positional_names)
1.27 + ))
1.28 + elif isinstance(item, Const):
1.29 + # NOTE: Need class details!
1.30 + new_code.append((
1.31 + None, #objtable.as_list().get_code(item.full_name()),
1.32 + None, #objtable.get_index(item.full_name()),
1.33 + None, None
1.34 + ))
1.35 + elif isinstance(item, Function):
1.36 + # NOTE: Need class and parameter details! Should arguably be types.FunctionType.
1.37 + new_code.append((
1.38 + objtable.as_list().get_code("__builtins__.function"),
1.39 + objtable.get_index("__builtins__.function"),
1.40 + item.code_location,
1.41 + len(item.positional_names)
1.42 + ))
1.43 else:
1.44 new_code.append(item)
1.45 return new_code
1.46 @@ -66,6 +92,9 @@
1.47 else:
1.48 return ""
1.49
1.50 + def get_operand(self):
1.51 + return None
1.52 +
1.53 class FrameRelativeInstruction(Instruction):
1.54
1.55 "An instruction operating on the current frame."
1.56 @@ -175,6 +204,7 @@
1.57
1.58 class MakeFrame(Immediate): "Make a new invocation frame."
1.59 class DropFrame(Instruction): "Drop an invocation frame."
1.60 +class RecoverFrame(Instruction): "Recover the current frame as an invocation frame."
1.61 class StoreFrame(Immediate): "Store the current value as an argument for the parameter with the given position."
1.62 class StoreFrameIndex(Immediate): "Store the current value as an argument for the parameter with the given index."
1.63 class LoadCallable(Instruction): "Load the target of an invocation."
1.64 @@ -185,8 +215,9 @@
1.65
1.66 # Invocation-related instructions, using a special result "register".
1.67
1.68 -class JumpWithFrame(Instruction): "Jump, adopting the invocation frame, to the callable found as the current value."
1.69 +class JumpWithFrame(Instruction): "Jump, adopting the invocation frame, to the current callable."
1.70 class ExtendFrame(Immediate): "Extend the current frame for temporary storage use."
1.71 +class AdjustFrame(Immediate): "Adjust the current frame for corrected invocations."
1.72 class Return(Instruction): "Return from a subprogram."
1.73 class LoadResult(Instruction): "Load into the current value a returned value."
1.74 class StoreResult(Instruction): "Store the current value as a value to be returned."