コード例 #1
0
ファイル: types.py プロジェクト: ctz/lighthouse
 def from_xml(t):
     assert t.tag == 'array'
     a = Array(t.get('id'), t.get('name'))
     a.type = type_from_xml(descend_one(t.find('type')))
     if t.find('domain'):
         a.domain = type_from_xml(descend_one(t.find('domain')))
     return a
コード例 #2
0
ファイル: statements.py プロジェクト: ctz/lighthouse
 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
コード例 #3
0
ファイル: statements.py プロジェクト: ctz/lighthouse
 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
コード例 #4
0
ファイル: statements.py プロジェクト: ctz/lighthouse
 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
コード例 #5
0
ファイル: statements.py プロジェクト: ctz/lighthouse
 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
コード例 #6
0
ファイル: expression.py プロジェクト: ctz/lighthouse
def expression_from_xml(t):
    if t.tag in valid_lvalues:
        return result_from_xml(t)
    if t.tag in ('constant',):
        return constant.convert(t)
    if t.tag in binary_operators.keys():
        return BinaryOp(binary_operators[t.tag])
    if t.tag in unary_operators.keys():
        return UnaryOp(unary_operators[t.tag])
    if t.tag == 'addr-of':
        return AddrOf(t)
    if t.tag == 'void':
        return Void()
    if t.tag == 'function':
        return expression_from_xml(descend_one(t))

    print 'warn: tag %s unhandled, returning dummy bound' % (t.tag)
    dump(t)
    return Bound()
コード例 #7
0
ファイル: expression.py プロジェクト: ctz/lighthouse
 def __init__(self, t):
     self.thing = result_from_xml(descend_one(t))
コード例 #8
0
ファイル: expression.py プロジェクト: ctz/lighthouse
 def __init__(self, t):
     self.array = expression_from_xml(descend_one(t.find('array')))
     self.index = expression_from_xml(descend_one(t.find('index')))
コード例 #9
0
ファイル: expression.py プロジェクト: ctz/lighthouse
 def __init__(self, t):
     self.struct = expression_from_xml(descend_one(t.find('structure')))
     self.member = expression_from_xml(descend_one(t.find('member')))
コード例 #10
0
ファイル: expression.py プロジェクト: ctz/lighthouse
 def __init__(self, t):
     self.of = expression_from_xml(descend_one(t))
コード例 #11
0
ファイル: types.py プロジェクト: ctz/lighthouse
 def from_xml(t):
     a = AddrOf(0, t.get('name'))
     a.of = type_from_xml(descend_one(t))
     return a
コード例 #12
0
ファイル: types.py プロジェクト: ctz/lighthouse
 def from_xml(t):
     f = Function(t.get('id') or 0, t.get('name'))
     f.returns = type_from_xml(descend_one(t.find('return')))
     for a in t.find('arguments').getchildren():
         f.arguments += [ type_from_xml(a) ]
     return f