Permalink
Browse files

here comes the refactoring

  • Loading branch information...
1 parent b523ce6 commit ddb5aadf93488dbd5d660bf689fb0d42bb7c497a @humbletim committed Dec 6, 2011
Showing with 16 additions and 984 deletions.
  1. +2 −102 Makefile
  2. +8 −70 README.md
  3. +0 −33 TODO.md
  4. +0 −336 demo.html
  5. +0 −50 demo.lua
  6. +0 −72 ffi.js
  7. +0 −79 misc/frexp.js
  8. +0 −37 misc/frexp.lua
  9. +0 −12 misc/mluac.lua
  10. +0 −25 misc/yluac.lua
  11. +0 −28 misc/yueliang_patch.lua
  12. +2 −2 lvm.js → src/ljs.lvm.js
  13. +0 −21 testmodule.lua
  14. +0 −14 testmodule2.lua
  15. 0 tests/{pass → fail}/frexp.lua
  16. +4 −2 tests/run.sh
  17. +0 −78 util/lua2html.pl
  18. +0 −23 util/luac2js.lua
View
104 Makefile
@@ -1,57 +1,6 @@
-# TODO: makefile is too specific, need a good way to organize > 1 demos...
-all: demo.html
-
-demo.html: demo.lua.output.html \
- demo.luac.js demo.lua.src.html \
- testmodule.luac.js \
- testmodule.lua.src.html
-# yueliang.luac.js
-
-%.luac: %.lua
- luac -o $@ $<
-
-%.luac.js: %.luac
- lua util/luac2js.lua $< > $@
-
-%.lua.src.html: %.lua
- perl util/lua2html.pl $< > $@
-
-demo.lua.output.html: demo.lua
- ( echo "<pre style='font-size:.9em'>" ; make -s lua-run ; \
- echo "</pre>" ) > demo.lua.output.html 2>&1 || true
-
-#demo.lua.numbered.html: demo.lua
-# nl -ba -nrz -w 3 -s "]] " $< |sed -e 's/^/--[[/' | \
-# perl util/lua2html.pl > $@
-
-
-# this approximates web browser test, using ndoe
-node-run: testmodule.luac
- luac -o luac.out demo.lua
- node lvm.js '(arg 1)' '(arg 2)'
-
-node-run-quiet:
- @make -s node-run 2>/dev/null
-
-run: node-run-quiet
-
-# this approximates web browser test, using lua
-lua-run:
- env LUA_PATH=./?.lua lua demo.lua \
- '(arg 1)' '(arg 2)'
-
-lua-run-quiet:
- @make -s lua-run 2>/dev/null
-
-# useful when dealing with subtleties
-nodeeqlua:
- @bash -c 'A=$$(make node-run-quiet);B=$$(make lua-run-quiet);\
- [ "$$A" == "$$B" ] && echo "node-run-quiet == lua-run-quiet" || ( \
- (echo "----- node -----" ; make -s node-run-quiet ) > A.out.txt ; \
- (echo "----- lua -----" ; make -s lua-run-quiet ) > B.out.txt ; \
- sdiff -l -w 80 B.out.txt A.out.txt ; \
- rm A.out.txt B.out.txt ) '
+all:
+ @echo make test
# sanity check to make sure these run in stock lua
pretest:
@@ -63,52 +12,3 @@ pretest:
# run node-based test framework
test: pretest
bash tests/run.sh
-
-clean:
- rm -vf *.luac *.luac.js
- rm -vf demo.lua.output.html
- rm -vf demo.lua.src.html testmodule.lua.src.html
- rm -vf luac.out _yueliang.lua _modluac.lua
-
-##### experimenting with yueliang...
-#testdump:
-# ( cd ../yueliang-0.4.1/orig-5.1.3 && \
-# cat lopcodes.lua ldump.lua \
-# test/test_ldump.lua ) | sed -e 's/^dofile/--dofile/g' > testdump.lua
-
-yueliang.luac: _yueliang.lua
- @echo "making stripped $@"
- luac -s -o $@ $<
-
-yueliang.luac.js: yueliang.luac
- lua util/luac2js.lua $< > $@
-
-_yueliang.lua: misc/mluac.lua misc/frexp.lua
- ( echo '-- composited yueliang.lua @ ' `date -u` ; \
- echo 'module(..., package.seeall)' ; \
- ( cd ../yueliang-0.4.1/orig-5.1.3 && \
- cat lzio.lua llex.lua lopcodes.lua ldump.lua lcode.lua lparser.lua \
- ) ; \
- cat misc/frexp.lua misc/yueliang_patch.lua misc/mluac.lua \
- ) | sed -e 's/^dofile/--dofile/g' > _yueliang.lua
-
-_modluac.lua: misc/yluac.lua misc/yueliang_patch.lua
- ( \
- ( cd ../yueliang-0.4.1/orig-5.1.3 && \
- cat lzio.lua llex.lua lopcodes.lua ldump.lua lcode.lua lparser.lua \
- ) ; \
- cat misc/yueliang_patch.lua misc/yluac.lua \
- ) | sed -e 's/^dofile/--dofile/g' > _modluac.lua
-
-modluac: _modluac.lua
- luac _modluac.lua
- @echo "luac.out is now yueliang-compiler"
-
-# TODO: yueliang needs separate test script, but for now...
-ytest: modluac
- bash -c 'set -e ; for x in tests/pass/*.lua tests/fail/*.lua ; do \
- node lvm.js $$x 2>/dev/null > $$x.yluac && echo "[ compiled (ljs) ] $$x!" || ( echo "FAIL(compile): $$x" && cat $$x.yluac && rm $$x.yluac ) ; \
- [ -e $$x.yluac ] && ( ( lua $$x.yluac 2>/dev/null >/dev/null \
- && echo "[ ran (`which lua`) ] $$x.yluac" ) || echo "FAIL(`which lua`): $$x" && rm $$x.yluac ) ; \
- done'
-
View
@@ -1,89 +1,27 @@
# ljs - Lua VM implemented in Javascript
-* [DEMO #1](http://humbletim.github.com/ljs/demo/demo.html)
- (ljs w/precompiled sample)
-* [DEMO #2](http://humbletim.github.com/ljs/demo/inbrowser.html)
- (ljs + precompiled [yeuliang](http://yueliang.luaforge.net/))
-* [DEMO #3](http://humbletim.github.com/ljs/demo/codemirror.html)
+* This is the Lua VM / core only. See [TBD] for example integrations.
+
+* [OLD DEMO](http://humbletim.github.com/ljs/demo/codemirror.html)
(ljs + precompiled [yeuliang](http://yueliang.luaforge.net/) + [codemirror](http://codemirror.net) editor)
-note: ljs is bytecode interpreter only
+note: ljs itself is bytecode loader / interpreter only
(.lua scripts must be compiled to .luac in advance)
-(yeuliang is lua compiler in lua)
-
-### roadmap:
-
-1. put together an example of how to go from lua source code to js-encoded
- bytecode
- * [done -- see Makefile]
-2. neutralize node-specific code in lvm.js, so project can run in any web
- browser again
- * [done -- tested in IE6, FF, Chrome, WebKit, Opera]
-3. experiment with some [BrowserLua](https://github.com/agladysh/browser-lua)
- concepts
- * [attempted]
-4. make a sandbox'd cgi-bin that takes lua code as input and emits js-encoded
- bytecode (text/javascript)
-5. ... that's it for now!
-
-### to run the legacy node-based tests (which should still work)
-
- bash tests/run.sh
- # -> 32/32 TESTS PASSED
-
-### to build and view the web browser test
-
- make all
- firefox demo.html
-
-*make all:*
-* demo.lua ->
- * demo.lua.output.txt *(build host's lua output, for comparison)*
- * .luac *(compiled bytecode)*
- * .luac.js *(encoded bytecode as html script include)*
- * .lua.src.html *(pretty source for browser)*
+### to run the node-based tests
-### to build precompiled yeuliang bootstrapping
- # download & extract yeuliang-0.4.1.tar.gz into sibling dir
- make yeuliang.luac.js
+ make test
+ # -> M/N TESTS PASSED
#### dependencies
-make all: lua / luac (tested with 5.1.4),
- make, bash,
- perl (lua2html.pl for output in browser test),
- node (for running tests)
+node (for running tests)
#### history
originally *ljs-16b833862ae2* from mecurial
http://code.matthewwild.co.uk/ljs/ ::
[16b833862ae2](http://code.matthewwild.co.uk/ljs/rev/16b833862ae2)
-
-On Tue, Jul 20, 2010 at 13:16, Matthew Wild [wrote](http://lua-users.org/lists/lua-l/2010-07/msg00569.html):
-
->... So I started on my own venture to write a VM in Javascript by hand:
-http://code.matthewwild.co.uk/ljs/
-
->Although I haven't had a chance to work on it the past month or so,
-it's still under quite heavy development. Much is implemented, except
-some of the trivial opcodes, and my current focus is metatables, and
-then implementing some of the standard library.
-
->It's only a VM, which means that scripts either need to be compiled
-offline, or someone needs to write a compiler in Lua or Javascript. In
-fact (although I haven't looked at it yet) the former has already been
-done as far as I know: http://yueliang.luaforge.net/ - so if one
-wanted to compile scripts live in the browser, Yueliang could be
-compiled offline and run in the VM in the browser to compile them.
-
->I find all of this much fun :)
-
->Matthew
-
------
#### License (MIT/X11)
-see: <http://matthewwild.co.uk/free> ->
- <http://en.wikipedia.org/wiki/MIT_licence>
View
33 TODO.md
@@ -1,33 +0,0 @@
-### FUTURE ROADMAP -- a possibility
-TODO: Create support for and tutorials showing:
-
-#### 1. How to bootstrap LJS into an existing *JavaScript* environment
-
-```javascript
- // packaging LJS w/compiler as a CommonJS module
- var ret = require('ljs.lua').eval('return [[demo]]');
-
- // packaging Lua modules as self-contained CommonJS modules
- var myapi = require('myluamodule');
- alert(myapi.method('arg'));
-```
-#### 2. How to map JavaScript APIs into *Lua* environment
-
-```lua
- -- DOM - document, window, etc.
- local div = require'domglue'.document.getElemenById('output')
- div.innerHTML = [[<i> hi from lua </i>]]
-
- -- HTML5 Canvas
- local canvas = require'domglue.canvas'.byId('mycanvas')
- local ctx = canvas.getContext('2d')
- function circle(x,y,r)
- ctx.beginPath()
- ctx.arc(x,y,r,0,math.pi*2,true)
- ctx.stroke()
- end
- circle(50,50,10)
-```
-
-* show how to use Firebug and profiling to identify performance issues
-* integrate http://www.timdown.co.uk/jshashtable/ to support full objects as table keys
Oops, something went wrong.

0 comments on commit ddb5aad

Please sign in to comment.