<s> from llvm . core import * <EOL> m = None <EOL> test_module = """<STR_LIT>""" <EOL> class strstream ( object ) : <EOL> def __init__ ( self ) : pass <EOL> def read ( self ) : return test_module <EOL> m = Module . from_assembly ( strstream ( ) ) <EOL> print "<STR_LIT:->" * <NUM_LIT> <EOL> print m <EOL> print "<STR_LIT:->" * <NUM_LIT> <EOL> test_func = m . get_function_named ( "<STR_LIT>" ) <EOL> prod = m . get_function_named ( "<STR_LIT>" ) <EOL> print <EOL> i1 = test_func . basic_blocks [ <NUM_LIT:0> ] . instructions [ <NUM_LIT:0> ] <EOL> i2 = test_func . basic_blocks [ <NUM_LIT:0> ] . instructions [ <NUM_LIT:1> ] <EOL> print "<STR_LIT>" , <EOL> if i1 . operand_count == <NUM_LIT:3> and i2 . operand_count == <NUM_LIT:2> : <EOL> print "<STR_LIT:OK>" <EOL> else : <EOL> print "<STR_LIT>" <EOL> print "<STR_LIT>" , <EOL> c1 = i1 . operands [ <NUM_LIT:0> ] is prod <EOL> c2 = i1 . operands [ <NUM_LIT:1> ] is test_func . args [ <NUM_LIT:0> ] <EOL> c3 = i1 . operands [ <NUM_LIT:2> ] is test_func . args [ <NUM_LIT:1> ] <EOL> c4 = i2 . operands [ <NUM_LIT:0> ] is i1 <EOL> c5 = i2 . operands [ <NUM_LIT:1> ] is test_func . args [ <NUM_LIT:2> ] <EOL> c6 = len ( i1 . operands ) == <NUM_LIT:3> <EOL> c7 = len ( i2 . operands ) == <NUM_LIT:2> <EOL> if c1 and c2 and c3 and c5 and c6 and c7 : <EOL> print "<STR_LIT:OK>" <EOL> else : <EOL> print "<STR_LIT>" <EOL> print <EOL> print "<STR_LIT>" <EOL> idx = <NUM_LIT:1> <EOL> for inst in test_func . basic_blocks [ <NUM_LIT:0> ] . instructions : <EOL> print "<STR_LIT>" % ( idx , ) <EOL> print "<STR_LIT>" , inst . operand_count <EOL> print "<STR_LIT>" <EOL> oidx = <NUM_LIT:1> <EOL> for op in inst . operands : <EOL> print "<STR_LIT>" % ( oidx , repr ( op ) ) <EOL> oidx += <NUM_LIT:1> <EOL> idx += <NUM_LIT:1> </s>
