(1, 0) (1, 22) COMMENT '#!/usr/bin/env python2' (1, 22) (1, 23) NL '\n' (2, 0) (4, 3) STRING '"""\nword_compile_test.py: Tests for word_compile.py\n"""' (4, 3) (4, 4) NEWLINE '\n' (5, 0) (5, 1) NL '\n' (6, 0) (6, 6) NAME 'import' (6, 7) (6, 15) NAME 'unittest' (6, 15) (6, 16) NEWLINE '\n' (7, 0) (7, 1) NL '\n' (8, 0) (8, 51) COMMENT '#from core import word_compile # module under test' (8, 51) (8, 52) NL '\n' (9, 0) (9, 1) NL '\n' (10, 0) (10, 1) NL '\n' (11, 0) (11, 5) NAME 'class' (11, 6) (11, 21) NAME 'WordCompileTest' (11, 21) (11, 22) OP '(' (11, 22) (11, 30) NAME 'unittest' (11, 30) (11, 31) OP '.' (11, 31) (11, 39) NAME 'TestCase' (11, 39) (11, 40) OP ')' (11, 40) (11, 41) OP ':' (11, 41) (11, 42) NEWLINE '\n' (12, 0) (12, 2) INDENT ' ' (12, 2) (12, 6) NAME 'pass' (12, 6) (12, 7) NEWLINE '\n' (13, 0) (13, 1) NL '\n' (14, 0) (14, 1) NL '\n' (15, 0) (15, 0) DEDENT '' (15, 0) (15, 2) NAME 'if' (15, 3) (15, 11) NAME '__name__' (15, 12) (15, 14) OP '==' (15, 15) (15, 25) STRING "'__main__'" (15, 25) (15, 26) OP ':' (15, 26) (15, 27) NEWLINE '\n' (16, 0) (16, 2) INDENT ' ' (16, 2) (16, 10) NAME 'unittest' (16, 10) (16, 11) OP '.' (16, 11) (16, 15) NAME 'main' (16, 15) (16, 16) OP '(' (16, 16) (16, 17) OP ')' (16, 17) (16, 18) NEWLINE '\n' (17, 0) (17, 0) DEDENT '' (17, 0) (17, 0) ENDMARKER '' OK lex Module( doc = '\nword_compile_test.py: Tests for word_compile.py\n' node = Stmt( nodes = [ Import( names = [ ( 'unittest' None ) ] ) # Import Class( name = 'WordCompileTest' bases = [ Getattr( expr = Name( name = 'unittest' ) # Name attrname = 'TestCase' ) # Getattr ] doc = None code = Stmt( nodes = [ Pass( ) # Pass ] ) # Stmt decorators = None ) # Class If( tests = [ ( Compare( expr = Name( name = '__name__' ) # Name ops = [ ( '==' Const( value = '__main__' ) # Const ) ] ) # Compare Stmt( nodes = [ Discard( expr = CallFunc( node = Getattr( expr = Name( name = 'unittest' ) # Name attrname = 'main' ) # Getattr args = [ ] star_args = None dstar_args = None ) # CallFunc ) # Discard ] ) # Stmt ) ] else_ = None ) # If ] ) # Stmt ) # Module OK ast globals: cells: defs: WordCompileTest unittest uses: __name__ unittest frees: globals: cells: defs: __module__ uses: frees: OK symbols OK cfg 55 OK run Compiled to 72 bytes of top-level bytecode co_argcount: 0 co_cellvars: () co_filename: 'osh/word_compile_test.py' co_firstlineno: 6 co_flags: 0x00000 co_freevars: () co_lnotab: '\x12\x05\x19\x04\x0c\x01' co_name: '' co_names: ('__doc__', 'unittest', 'TestCase', 'WordCompileTest', '__name__', 'main') co_nlocals: 0 co_stacksize: 4 co_varnames: ('__doc__', 'unittest', 'TestCase', 'WordCompileTest', '__name__', 'main') co_code 64 01 00 5a 00 00 64 02 00 64 00 00 6c 01 00 5a 01 00 64 03 00 65 01 00 6a 02 00 66 01 00 64 04 00 84 00 00 83 00 00 59 5a 03 00 65 04 00 64 05 00 6b 02 00 72 44 00 65 01 00 6a 05 00 83 00 00 01 6e 00 00 64 00 00 53 disassembled: 6 0 LOAD_CONST 1 ('\nword_compile_test.py: Tests for word_compile.py\n') 3 STORE_NAME 0 (__doc__) 6 LOAD_CONST 2 (-1) 9 LOAD_CONST 0 (None) 12 IMPORT_NAME 1 (unittest) 15 STORE_NAME 1 (unittest) 11 18 LOAD_CONST 3 ('WordCompileTest') 21 LOAD_NAME 1 (unittest) 24 LOAD_ATTR 2 (TestCase) 27 BUILD_TUPLE 1 30 LOAD_CONST 4 (code object WordCompileTest osh/word_compile_test.py 11) 33 MAKE_FUNCTION 0 36 CALL_FUNCTION 0 39 BUILD_CLASS 40 STORE_NAME 3 (WordCompileTest) 15 43 LOAD_NAME 4 (__name__) 46 LOAD_CONST 5 ('__main__') 49 COMPARE_OP 2 (==) 52 POP_JUMP_IF_FALSE 68 16 55 LOAD_NAME 1 (unittest) 58 LOAD_ATTR 5 (main) 61 CALL_FUNCTION 0 64 POP_TOP 65 JUMP_FORWARD 0 (to 68) >> 68 LOAD_CONST 0 (None) 71 RETURN_VALUE co_consts 0 None 1 '\nword_compile_test.py: Tests for word_compile.py\n' 2 -1 3 'WordCompileTest' 4 (code object) co_argcount: 0 co_cellvars: () co_filename: 'osh/word_compile_test.py' co_firstlineno: 11 co_flags: 0x00002 CO_NEWLOCALS co_freevars: () co_lnotab: '\x06\x01' co_name: 'WordCompileTest' co_names: ('__name__', '__module__') co_nlocals: 0 co_stacksize: 2 co_varnames: () co_code 74 00 00 5a 01 00 52 53 disassembled: 11 0 LOAD_GLOBAL 0 (__name__) 3 STORE_NAME 1 (__module__) 12 6 LOAD_LOCALS 7 RETURN_VALUE co_consts 0 None 5 '__main__' OK dis 0 file_input - 0 stmt """ word_compile_test.py: Tests for word_compile.py """ 0 simple_stmt """ word_compile_test.py: Tests for word_compile.py """ 0 small_stmt """ word_compile_test.py: Tests for word_compile.py """ 0 expr_stmt """ word_compile_test.py: Tests for word_compile.py """ 0 testlist """ word_compile_test.py: Tests for word_compile.py """ 0 test """ word_compile_test.py: Tests for word_compile.py """ 0 or_test """ word_compile_test.py: Tests for word_compile.py """ 0 and_test """ word_compile_test.py: Tests for word_compile.py """ 0 not_test """ word_compile_test.py: Tests for word_compile.py """ 0 comparison """ word_compile_test.py: Tests for word_compile.py """ 0 expr """ word_compile_test.py: Tests for word_compile.py """ 0 xor_expr """ word_compile_test.py: Tests for word_compile.py """ 0 and_expr """ word_compile_test.py: Tests for word_compile.py """ 0 shift_expr """ word_compile_test.py: Tests for word_compile.py """ 0 arith_expr """ word_compile_test.py: Tests for word_compile.py """ 0 term """ word_compile_test.py: Tests for word_compile.py """ 0 factor """ word_compile_test.py: Tests for word_compile.py """ 0 power """ word_compile_test.py: Tests for word_compile.py """ 0 atom """ word_compile_test.py: Tests for word_compile.py """ 0 STRING """ word_compile_test.py: Tests for word_compile.py """ 1 NEWLINE 1 stmt import 0 simple_stmt import 0 small_stmt import 0 import_stmt import 0 import_name import 0 NAME import 1 dotted_as_names unittest 0 dotted_as_name unittest 0 dotted_name unittest 0 NAME unittest 1 NEWLINE 2 stmt class 0 compound_stmt class 0 classdef class 0 NAME class 1 NAME WordCompileTest 2 LPAR ( 3 testlist unittest 0 test unittest 0 or_test unittest 0 and_test unittest 0 not_test unittest 0 comparison unittest 0 expr unittest 0 xor_expr unittest 0 and_expr unittest 0 shift_expr unittest 0 arith_expr unittest 0 term unittest 0 factor unittest 0 power unittest 0 atom unittest 0 NAME unittest 1 trailer . 0 DOT . 1 NAME TestCase 4 RPAR ) 5 COLON : 6 suite 0 NEWLINE 1 INDENT 2 stmt pass 0 simple_stmt pass 0 small_stmt pass 0 pass_stmt pass 0 NAME pass 1 NEWLINE 3 DEDENT 3 stmt if 0 compound_stmt if 0 if_stmt if 0 NAME if 1 test __name__ 0 or_test __name__ 0 and_test __name__ 0 not_test __name__ 0 comparison __name__ 0 expr __name__ 0 xor_expr __name__ 0 and_expr __name__ 0 shift_expr __name__ 0 arith_expr __name__ 0 term __name__ 0 factor __name__ 0 power __name__ 0 atom __name__ 0 NAME __name__ 1 comp_op == 0 EQEQUAL == 2 expr '__main__' 0 xor_expr '__main__' 0 and_expr '__main__' 0 shift_expr '__main__' 0 arith_expr '__main__' 0 term '__main__' 0 factor '__main__' 0 power '__main__' 0 atom '__main__' 0 STRING '__main__' 2 COLON : 3 suite 0 NEWLINE 1 INDENT 2 stmt unittest 0 simple_stmt unittest 0 small_stmt unittest 0 expr_stmt unittest 0 testlist unittest 0 test unittest 0 or_test unittest 0 and_test unittest 0 not_test unittest 0 comparison unittest 0 expr unittest 0 xor_expr unittest 0 and_expr unittest 0 shift_expr unittest 0 arith_expr unittest 0 term unittest 0 factor unittest 0 power unittest 0 atom unittest 0 NAME unittest 1 trailer . 0 DOT . 1 NAME main 2 trailer ( 0 LPAR ( 1 RPAR ) 1 NEWLINE 3 DEDENT 4 ENDMARKER OK parse a 0 atom - 0 assert_stmt a 0 single_input a 0 NAME a 1 ENDMARKER a = 3 0 atom - 0 assert_stmt a 0 single_input a 0 NAME a 1 EQUAL = 2 arglist 3 0 NUMBER 3 1 ENDMARKER unsigned int a 0 atom - 0 assert_stmt unsigned 0 NAME unsigned 1 NAME int 2 single_input a 0 NAME a 1 ENDMARKER unsigned unsigned int a 0 atom - 0 assert_stmt unsigned 0 NAME unsigned 1 NAME unsigned 2 NAME int 3 single_input a 0 NAME a 1 ENDMARKER unsigned unsigned b c 0 atom - 0 assert_stmt unsigned 0 NAME unsigned 1 NAME unsigned 2 single_input b 0 NAME b 3 single_input c 0 NAME c 1 ENDMARKER unsigned foo(arg); 0 arith_expr - 0 argument unsigned 0 augassign unsigned 0 NAME unsigned 1 single_input foo 0 NAME foo 2 LPAR ( 3 and_expr arg 0 NAME arg 4 RPAR ) 5 SEMI ; 1 ENDMARKER unsigned foo(arg) { body } 0 arith_expr - 0 argument unsigned 0 augassign unsigned 0 NAME unsigned 1 single_input foo 0 NAME foo 2 LPAR ( 3 and_expr arg 0 NAME arg 4 RPAR ) 5 LBRACE { 6 and_test body 0 NAME body 7 RBRACE } 1 ENDMARKER 1 + 2 0 single_input - 0 and_test 1 0 and_expr 1 0 NUMBER 1 1 PLUS + 2 and_expr 2 0 NUMBER 2 1 ENDMARKER a - 42 0 single_input - 0 and_test a 0 and_expr a 0 NAME a 1 MINUS - 2 and_expr 42 0 NUMBER 42 1 ENDMARKER if a - 42 0 single_input - 0 and_test if 0 NAME if 1 and_expr a 0 NAME a 2 MINUS - 3 and_expr 42 0 NUMBER 42 1 ENDMARKER DONE OK parse-with Compiled to 72 bytes of top-level bytecode Compiled to 66 bytes of top-level bytecode -rw-rw-r-- 1 andy andy 493 Mar 18 14:41 _tmp/opyc-compile-1 -rw-rw-r-- 1 andy andy 415 Mar 18 14:41 _tmp/opyc-compile-2 OK compile All test/opyc.sh tests passed.