Code Monkey home page Code Monkey logo

bytepatches's People

Contributors

martmists-gh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

bytepatches's Issues

Generators arent tokenized properly

Code:

def make_bytecode(ops: List[Opcode]):
    return b"".join(
        op.pack() for op in ops
    )

Generated tree (tree=True)

STORE_NAME[10](
     'make_bytecode',
     MAKE_FUNCTION[4](
         BUILD_CONST_KEY_MAP[1](
             LOAD_CONST[7](('ops',)),
             [BINARY_SUBSCR[0](LOAD_NAME[5](List), LOAD_NAME[7](Opcode))]
         ),
         RETURN_VALUE[0](
             CALL_METHOD[1](
                 LOAD_METHOD[0](LOAD_CONST[1](b''), join),
                 (CALL_FUNCTION[1](  # It's not being called with a function call but with a generator
                      MAKE_FUNCTION[0](
                          [LOAD_FAST[0](.0),
                           FOR_ITER[14](None, LOAD_CONST[0](None)),
                           STORE_FAST[1](op),
                           YIELD_VALUE[0](CALL_METHOD[0](LOAD_METHOD[0](LOAD_FAST[1](op), pack), ())),
                           POP_TOP[0](None),
                           JUMP_ABSOLUTE[2](None, FOR_ITER[14](None, LOAD_CONST[0](None))),
                           RETURN_VALUE[0](LOAD_CONST[0](None))]
                      ),
                      GET_ITER[0](LOAD_FAST[0](ops))
                  ),)
             )
         )
     )
 ),

Bytecode as ops:

68 LOAD_NAME 5
70 LOAD_NAME 7
72 BINARY_SUBSCR 0
74 LOAD_CONST 7
76 BUILD_CONST_KEY_MAP 1
78 LOAD_CONST 8
0 LOAD_CONST 1
2 LOAD_METHOD 0
4 LOAD_CONST 2
0 LOAD_FAST 0
2 FOR_ITER 14
4 STORE_FAST 1
6 LOAD_FAST 1
8 LOAD_METHOD 0
10 CALL_METHOD 0
12 YIELD_VALUE 0
14 POP_TOP 0
16 JUMP_ABSOLUTE 2
18 LOAD_CONST 0
20 RETURN_VALUE 0
6 LOAD_CONST 3
8 MAKE_FUNCTION 0
10 LOAD_FAST 0
12 GET_ITER 0
14 CALL_FUNCTION 1
16 CALL_METHOD 1
18 RETURN_VALUE 0
80 LOAD_CONST 9
82 MAKE_FUNCTION 4
84 STORE_NAME 10

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.