def from_xml(t): c = Call() if t.get('location'): c.location = Location(t.get('location')) if t.find('function') == None: c.fnexpr = expression.expression_from_xml(t.getchildren()[0]) else: c.fnexpr = expression.Bound(t.find('function')) c.lhs = expression.expression_from_xml(descend_one(t.find('lhs'))) for a in t.find('args').getchildren(): c.args += [ expression.expression_from_xml(a) ] return c
def from_xml(t): r = Ret() if t.get('location'): r.location = Location(t.get('location')) if t.getchildren(): r.expr = expression.expression_from_xml(descend_one(t)) return r
def from_xml(t): a = Assignment() if t.get('location'): a.location = Location(t.get('location')) a.lhs = expression.result_from_xml(descend_one(t.find('lhs'))) for x in t.find('rhs').getchildren(): a.rhs += [expression.expression_from_xml(x)] return a
def from_xml(t): c = Cond() if t.get('location'): c.location = Location(t.get('location')) for x in t.getchildren(): if x.tag == 'then': c.then = int(x.get('id')) elif x.tag == 'else': c.else_ = int(x.get('id')) else: c.cond += [ expression.expression_from_xml(x) ] return c
def from_xml(t): s = Switch() if t.get('location'): s.location = Location(t.get('location')) s.expr = expression.expression_from_xml(descend_one(t.find('index'))) if t.find('default') is not None: s.default = int(t.find('default').get('id')) for c in t.findall('case'): if len(c.getchildren()) == 1: k = descend_one(c) assert k.tag == 'exact', 'strange case label' s.mapping[constant.convert(descend_one(k))] = int(c.get('id')) else: assert len(c.getchildren()) == 2, 'strange case label' low, high = c.getchildren() assert low.tag == 'low-bound' assert high.tag == 'high-bound' low_const, high_const = constant.convert(descend_one(low)).get_value(), constant.convert(descend_one(high)).get_value() for x in range(low_const, high_const + 1): s.mapping[x] = int(c.get('id')) return s