Lonami / pyndustric

A Python compiler for Mindustry's logic processors assembly language
MIT License
49 stars 9 forks source link

Support imports of additional modules #16

Open Lonami opened 3 years ago

Lonami commented 3 years ago

Split off https://github.com/Lonami/pyndustric/pull/12/files#diff-852dce7acd90bf3bfbde1cec63522f7204b9c209cc52b3e40d23bb6f3202ef7fR54-R55.

It would be necessary to inspect import statements and figure out what's used from them.

This issue won't be easy to tackle, because even if the user does from foo import bar, bar might be relying on the baz or even be compiled conditionally depending on qux. From an implementation-perspective:

  1. Assume the imported function is self-contained.
  2. Actually validate that the function is self-contained an error at compile time, to prevent running broken mlog.
  3. Smarter imports which will be able to handle some of the cases where 2. errors out (probably not possible to handle them all without extreme clutter).