|
@@ -262,15 +262,14 @@ class Literal(Value):
|
|
|
def __str__(self):
|
|
|
return 'literal %r' % self.literal
|
|
|
|
|
|
-class FunctionCall(Value):
|
|
|
- """A value that is the result of a function call."""
|
|
|
- def __init__(self, target, argument_list, calling_convention='jit'):
|
|
|
+class IndirectFunctionCall(Value):
|
|
|
+ """A value that is the result of an indirect function call."""
|
|
|
+ def __init__(self, target, argument_list):
|
|
|
Value.__init__(self)
|
|
|
assert isinstance(target, Definition)
|
|
|
self.target = target
|
|
|
assert all([isinstance(val, Definition) for _, val in argument_list])
|
|
|
self.argument_list = argument_list
|
|
|
- self.calling_convention = calling_convention
|
|
|
|
|
|
def has_side_effects(self):
|
|
|
"""Tells if this instruction has side-effects."""
|
|
@@ -281,11 +280,40 @@ class FunctionCall(Value):
|
|
|
return [self.target] + [val for _, val in self.argument_list]
|
|
|
|
|
|
def __str__(self):
|
|
|
- return 'call %r %s(%s)' % (
|
|
|
- self.calling_convention,
|
|
|
+ return 'indirect-call %s(%s)' % (
|
|
|
self.target.ref_str(),
|
|
|
', '.join(['%s=%s' % (key, val.ref_str()) for key, val in self.argument_list]))
|
|
|
|
|
|
+SIMPLE_POSITIONAL_CALLING_CONVENTION = 'simple-positional'
|
|
|
+"""The calling convention for functions that use 'return' statements to return.
|
|
|
+ Arguments are matched to parameters based on position."""
|
|
|
+
|
|
|
+JIT_CALLING_CONVENTION = 'jit'
|
|
|
+"""The calling convention for jitted functions."""
|
|
|
+
|
|
|
+class DirectFunctionCall(Value):
|
|
|
+ """A value that is the result of a direct function call."""
|
|
|
+ def __init__(self, target_name, argument_list, calling_convention=JIT_CALLING_CONVENTION):
|
|
|
+ Value.__init__(self)
|
|
|
+ self.target_name = target_name
|
|
|
+ assert all([isinstance(val, Definition) for _, val in argument_list])
|
|
|
+ self.argument_list = argument_list
|
|
|
+ self.calling_convention = calling_convention
|
|
|
+
|
|
|
+ def has_side_effects(self):
|
|
|
+ """Tells if this instruction has side-effects."""
|
|
|
+ return True
|
|
|
+
|
|
|
+ def get_dependencies(self):
|
|
|
+ """Gets all definitions and instructions on which this instruction depends."""
|
|
|
+ return [val for _, val in self.argument_list]
|
|
|
+
|
|
|
+ def __str__(self):
|
|
|
+ return 'direct-call %r %s(%s)' % (
|
|
|
+ self.calling_convention,
|
|
|
+ self.target_name,
|
|
|
+ ', '.join(['%s=%s' % (key, val.ref_str()) for key, val in self.argument_list]))
|
|
|
+
|
|
|
class AllocateRootNode(Value):
|
|
|
"""A value that produces a new root node. Typically used in function prologs."""
|
|
|
def __init__(self):
|