|
@@ -245,7 +245,7 @@ def __cmp__(self, other):
|
|
|
|
|
|
|
|
|
|
class FunctionField:
|
|
class FunctionField:
|
|
- """Class representing a field passed through an expander"""
|
|
|
|
|
|
+ """Class representing a field passed through a function"""
|
|
def __init__(self, func, base):
|
|
def __init__(self, func, base):
|
|
self.mask = base.mask
|
|
self.mask = base.mask
|
|
self.sign = base.sign
|
|
self.sign = base.sign
|
|
@@ -266,6 +266,27 @@ def __ne__(self, other):
|
|
# end FunctionField
|
|
# end FunctionField
|
|
|
|
|
|
|
|
|
|
|
|
+class ParameterField:
|
|
|
|
+ """Class representing a pseudo-field read from a function"""
|
|
|
|
+ def __init__(self, func):
|
|
|
|
+ self.mask = 0
|
|
|
|
+ self.sign = 0
|
|
|
|
+ self.func = func
|
|
|
|
+
|
|
|
|
+ def __str__(self):
|
|
|
|
+ return self.func
|
|
|
|
+
|
|
|
|
+ def str_extract(self):
|
|
|
|
+ return self.func + '(ctx)'
|
|
|
|
+
|
|
|
|
+ def __eq__(self, other):
|
|
|
|
+ return self.func == other.func
|
|
|
|
+
|
|
|
|
+ def __ne__(self, other):
|
|
|
|
+ return not self.__eq__(other)
|
|
|
|
+# end ParameterField
|
|
|
|
+
|
|
|
|
+
|
|
class Arguments:
|
|
class Arguments:
|
|
"""Class representing the extracted fields of a format"""
|
|
"""Class representing the extracted fields of a format"""
|
|
def __init__(self, nm, flds, extern):
|
|
def __init__(self, nm, flds, extern):
|
|
@@ -433,17 +454,23 @@ def parse_field(lineno, name, toks):
|
|
|
|
|
|
if width > insnwidth:
|
|
if width > insnwidth:
|
|
error(lineno, 'field too large')
|
|
error(lineno, 'field too large')
|
|
- if len(subs) == 1:
|
|
|
|
- f = subs[0]
|
|
|
|
|
|
+ if len(subs) == 0:
|
|
|
|
+ if func:
|
|
|
|
+ f = ParameterField(func)
|
|
|
|
+ else:
|
|
|
|
+ error(lineno, 'field with no value')
|
|
else:
|
|
else:
|
|
- mask = 0
|
|
|
|
- for s in subs:
|
|
|
|
- if mask & s.mask:
|
|
|
|
- error(lineno, 'field components overlap')
|
|
|
|
- mask |= s.mask
|
|
|
|
- f = MultiField(subs, mask)
|
|
|
|
- if func:
|
|
|
|
- f = FunctionField(func, f)
|
|
|
|
|
|
+ if len(subs) == 1:
|
|
|
|
+ f = subs[0]
|
|
|
|
+ else:
|
|
|
|
+ mask = 0
|
|
|
|
+ for s in subs:
|
|
|
|
+ if mask & s.mask:
|
|
|
|
+ error(lineno, 'field components overlap')
|
|
|
|
+ mask |= s.mask
|
|
|
|
+ f = MultiField(subs, mask)
|
|
|
|
+ if func:
|
|
|
|
+ f = FunctionField(func, f)
|
|
|
|
|
|
if name in fields:
|
|
if name in fields:
|
|
error(lineno, 'duplicate field', name)
|
|
error(lineno, 'duplicate field', name)
|