fglock / Perlito

"Perlito" Perl programming language compiler
http://fglock.github.io/Perlito/
Other
414 stars 47 forks source link

«TypeError: Cannot call method 'require' of undefined» after compiling expand-solitaire-multi-card-moves #23

Open shlomif opened 9 years ago

shlomif commented 9 years ago

After I compile perlito and run it on the code here - https://github.com/shlomif/fc-solve/tree/Games-Solitaire-Verify--for-Perlito--Get-Rid-of-Getopt-Long , I'm getting an error:

shlomif@telaviv1:~/Download/unpack/perl/Perlito/Perlito$ perl perlito5.pl -Cjs -I src5/lib/ -I/home/shlomif/progs/freecell/git/fc-solve/cpan/Games-Solitaire-Verify/Games-Solitaire-Verify/lib /home/shlomif/progs/freecell/git/fc-solve/cpan/Games-Solitaire-Verify/Games-Solitaire-Verify/script/expand-solitaire-multi-card-moves > ~/e.js
shlomif@telaviv1:~/Download/unpack/perl/Perlito/Perlito$ node ~/e.js
/home/shlomif/e.js:2330
                p5pkg["Perlito5::Grammar::Use"]["require"]([p5str('Games::Solitaire::Verify:
                                                          ^
TypeError: Cannot call method 'require' of undefined
    at p5pkg.Fcntl.List_ISA (/home/shlomif/e.js:2330:45)
    at /home/shlomif/e.js:2389:4
    at Object.<anonymous> (/home/shlomif/e.js:8435:3)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3

Please look into fixing it.

Regards, -- @shlomif

fglock commented 9 years ago

I believe this is because the pre-compiled script is already "detached" from the compiler - it can't do "require" anymore. It can't also "do FILE" or "eval STRING".

The compiler consists of the list of modules at the start of "src5/util/ perlito5.pl" - basically the Grammar and Emitter modules.

I'll look into a way to force linking the full compiler into the script if it is needed anywhere at runtime. Alternately, this could be a compiler command-line option, such as "-M".

2014-10-20 21:50 GMT+02:00 Shlomi Fish notifications@github.com:

After I compile perlito and run it on the code here - https://github.com/shlomif/fc-solve/tree/Games-Solitaire-Verify--for-Perlito--Get-Rid-of-Getopt-Long , I'm getting an error:

shlomif@telaviv1:~/Download/unpack/perl/Perlito/Perlito$ perl perlito5.pl -Cjs -I src5/lib/ -I/home/shlomif/progs/freecell/git/fc-solve/cpan/Games-Solitaire-Verify/Games-Solitaire-Verify/lib /home/shlomif/progs/freecell/git/fc-solve/cpan/Games-Solitaire-Verify/Games-Solitaire-Verify/script/expand-solitaire-multi-card-moves > ~/e.js shlomif@telaviv1:~/Download/unpack/perl/Perlito/Perlito$ node ~/e.js /home/shlomif/e.js:2330 p5pkg["Perlito5::Grammar::Use"]["require"]([p5str%28'Games::Solitaire::Verify: ^ TypeError: Cannot call method 'require' of undefined at p5pkg.Fcntl.List_ISA %28/home/shlomif/e.js:2330:45) at /home/shlomif/e.js:2389:4 at Object. (/home/shlomif/e.js:8435:3) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:906:3

Please look into fixing it.

Regards, -- @shlomif https://github.com/shlomif

— Reply to this email directly or view it on GitHub https://github.com/fglock/Perlito/issues/23.

fglock commented 6 years ago

update on this: module pre-compilation is in the TODO list;

this is a low priority task because replacing "require" with "use" will precompile.