sparkslabs/pyxie

iiNode refactor / thunk removal breaks operator expressions

sparkslabs opened this issue · 1 comments

Summary: The iiNode refactor currently breaks operator expressions.

Reproduce:

To reproduce in a clean checkout (as of d4735b7 ):

cd examples/if/
clean.sh
compile.sh

Various usual output, and finishes with:

[...snip...]
self.lvalue pan
self.assigntype =
crvalue <type 'list'> ['op', 'minus', <pyxie.model.iinodes.iiIdentifier object at 0x7fe797e3ef90>, <pyxie.model.iinodes.iiInteger object at 0x7fe797e3ee50>]
[...snip usage...]
USAGE ERROR: cannot concatenate 'str' and 'list' objects
Original traceback follows
Traceback (most recent call last):
File "./bin/pyxie", line 80, in <module>
    main(argv = sys.argv[:])
File "./bin/pyxie", line 56, in main
    return StandardOptions.handle(command, *(argv[2:]))
File "/home/michael/WIP/Development/pyxie/pyxie/api.py", line 112, in handle
    f(*args)
File "/home/michael/WIP/Development/pyxie/pyxie/api.py", line 172, in compile
    compile_file(filename, profile, result_filename)
File "/home/michael/WIP/Development/pyxie/pyxie/core.py", line 289, in compile_file
    c_code  = codegen_phase(filename, result_filename, profile)
File "/home/michael/WIP/Development/pyxie/pyxie/core.py", line 181, in codegen_phase
    c_code = generate_code(cname, AST, profile, debug=True)  # Need the C NAME TO DO THIS
File "/home/michael/WIP/Development/pyxie/pyxie/core.py", line 167, in generate_code
    program.generate(profile)
File "/home/michael/WIP/Development/pyxie/pyxie/model/cppnodes.py", line 165, in generate
    frame_lines = self.main_cframe.concrete()
File "/home/michael/WIP/Development/pyxie/pyxie/model/cppnodes.py", line 206, in concrete
    code = statement.code()
File "/home/michael/WIP/Development/pyxie/pyxie/model/cppnodes.py", line 600, in code
    block_code = "\n".join( self.block_cframe.concrete() )
File "/home/michael/WIP/Development/pyxie/pyxie/model/cppnodes.py", line 206, in concrete
    code = statement.code()
File "/home/michael/WIP/Development/pyxie/pyxie/model/cppnodes.py", line 254, in code
    return self.lvalue + " "+self.assigntype+" " + crvalue
TypeError: cannot concatenate 'str' and 'list' objects

Likely cause: (if known)

The purpose of the refactor was to replace representing intermediate notes as lists (which are relatively inflexible, but OK when starting) with "proper" iiNode objects. During dev a thunk was in place to allow either to be used safely (allowing things to continue to function fine during transition). Since the thunk has now been deleted, just flushing out the few places which the use of a thunk masked places that had been missed.

Likely Steps to fix (if known):

Fix usage of iiOperator and probably create a CppOperator base class.

Fixed in 163ea27

Ensure operator expressions compile correctly again

Quite a few changes:

  • pyxie/model/pynodes/operators.py - extended to make it simpler to extract the arguments for the operators. This could be rationalised further.

  • pyxie/model/iinodes.py - remove the iiOpNode based operator nodes, and replace with a single simpler iiOperator class. iiComparison modified to allow the compator to be also called the operator, harmonising exceptions.

  • pyxie/model/transform.py - Remove usage of list based iiOperators and use iiOperators instead.

  • pyxie/model/cppnodes.py - Collection of fixes to make these changes work as expected.