Giter VIP home page Giter VIP logo

brozula's Introduction

This package is NOT supported.

You're welcome to use it, all code is MIT licensed by Tim Caswell

I intend for this to be a collection of high quality software that I use in my various personal projects.

I do not, however, feel any obligation to fix issues for others who use it.

Like the MIT license says, you can freely use this software, but it comes with zero warranty.

brozula's People

Contributors

creationix avatar daurnimator avatar shawwn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

brozula's Issues

Test fails on OSX Luajit 2.0.1

Hello. This is very interesting project. Maybe Luajit bytecode has changed because nothing seems to work?

test.lua:
local function fact (n)
if n == 0 then
return 1
else
return n * fact(n-1)
end
end
return fact

brozula test.lua

/usr/local/lib/node_modules/brozula/cli.js:114
if (err) throw err;
^
Error: TODO: Implement me
at Object.generators.UGET (/usr/local/lib/node_modules/brozula/brozula.js:652:11)
at generators.ISLT (/usr/local/lib/node_modules/brozula/brozula.js:477:51)
at Array.forEach (native)
at Object.compile (/usr/local/lib/node_modules/brozula/brozula.js:422:10)
at generate (/usr/local/lib/node_modules/brozula/cli.js:49:25)
at Socket.check (/usr/local/lib/node_modules/brozula/cli.js:43:7)
at Socket.EventEmitter.emit (events.js:93:17)
at Pipe.onread (net.js:418:51)

License?

Hey Tim, I'm not seeing a license on this. Would be nice to see an MIT license like Lua itself. (Or BSD, Apache, whatever you prefer)

Script Fails (A Coroutine example)

$ cat ~/luatute/tute-coro.lua

local read = function ( )
    return coroutine.yield ( )
end

local get_blah = function ( )
    print ( "PRE 1" )
    print ( read ( ) )
    print ( "PRE 2" )
    print ( read ( ) )
    print ( "PRE 3" )
    print ( read ( ) )
end

-- Create coroutine
local get_blah_co = coroutine.create ( get_blah )

-- Basic dispatcher
while coroutine.status ( get_blah_co ) == "suspended" do
    local ok , err_msg = coroutine.resume ( get_blah_co )
    if not ok then
        print("AN ERROR!",err_msg)
        break
    end
end

$ ./cli.js -pb ~/luatute/tute-coro.lua

[ { index: 0,
    flags: 0,
    numparams: 0,
    framesize: 1,
    bcins: 
     [ { op: 'GGET',
         args: [ 0, 'coroutine', 'index' ] },
       { op: 'TGETS',
         args: [ 0, 0, 'yield', 'index' ] },
       { op: 'CALLT',
         args: [ 0, 1, 'call' ] } ],
    uvdata: [] },
  { index: 1,
    flags: 0,
    numparams: 0,
    framesize: 2,
    bcins: 
     [ { op: 'GGET',
         args: [ 0, 'print', 'index' ] },
       { op: 'KSTR',
         args: [ 1, 'PRE 1' ] },
       { op: 'CALL',
         args: [ 0, 1, 2, 'call' ] },
       { op: 'GGET',
         args: [ 0, 'print', 'index' ] },
       { op: 'UGET', args: [ 1, 0 ] },
       { op: 'CALL',
         args: [ 1, 0, 1, 'call' ] },
       { op: 'CALLM',
         args: [ 0, 1, 0, 'call' ] },
       { op: 'GGET',
         args: [ 0, 'print', 'index' ] },
       { op: 'KSTR',
         args: [ 1, 'PRE 2' ] },
       { op: 'CALL',
         args: [ 0, 1, 2, 'call' ] },
       { op: 'GGET',
         args: [ 0, 'print', 'index' ] },
       { op: 'UGET', args: [ 1, 0 ] },
       { op: 'CALL',
         args: [ 1, 0, 1, 'call' ] },
       { op: 'CALLM',
         args: [ 0, 1, 0, 'call' ] },
       { op: 'GGET',
         args: [ 0, 'print', 'index' ] },
       { op: 'KSTR',
         args: [ 1, 'PRE 3' ] },
       { op: 'CALL',
         args: [ 0, 1, 2, 'call' ] },
       { op: 'GGET',
         args: [ 0, 'print', 'index' ] },
       { op: 'UGET', args: [ 1, 0 ] },
       { op: 'CALL',
         args: [ 1, 0, 1, 'call' ] },
       { op: 'CALLM',
         args: [ 0, 1, 0, 'call' ] },
       { op: 'RET0', args: [ 0, 1 ] } ],
    uvdata: 
     [ { local: true,
         immutable: true,
         uv: 0 } ] },
  { index: 2,
    flags: 3,
    numparams: 0,
    framesize: 8,
    bcins: 
     [ { op: 'FNEW',
         args: 
          [ 0,
            { index: 0,
              flags: 0,
              numparams: 0,
              framesize: 1,
              bcins: [Object],
              uvdata: [] },
            'gc' ] },
       { op: 'FNEW',
         args: 
          [ 1,
            { index: 1,
              flags: 0,
              numparams: 0,
              framesize: 2,
              bcins: [Object],
              uvdata: [Object] },
            'gc' ] },
       { op: 'GGET',
         args: [ 2, 'coroutine', 'index' ] },
       { op: 'TGETS',
         args: 
          [ 2,
            2,
            'create',
            'index' ] },
       { op: 'MOV', args: [ 3, 1 ] },
       { op: 'CALL',
         args: [ 2, 2, 2, 'call' ] },
       { op: 'GGET',
         args: [ 3, 'coroutine', 'index' ] },
       { op: 'TGETS',
         args: 
          [ 3,
            3,
            'status',
            'index' ] },
       { op: 'MOV', args: [ 4, 2 ] },
       { op: 'CALL',
         args: [ 3, 2, 2, 'call' ] },
       { op: 'ISNES',
         args: [ 3, 'suspended', 'eq' ] },
       { op: 'JMP', args: [ 3, 13 ] },
       { op: 'LOOP', args: [ 3, 12 ] },
       { op: 'GGET',
         args: [ 3, 'coroutine', 'index' ] },
       { op: 'TGETS',
         args: 
          [ 3,
            3,
            'resume',
            'index' ] },
       { op: 'MOV', args: [ 4, 2 ] },
       { op: 'CALL',
         args: [ 3, 3, 2, 'call' ] },
       { op: 'IST', args: [ 3 ] },
       { op: 'JMP', args: [ 5, -13 ] },
       { op: 'GGET',
         args: [ 5, 'print', 'index' ] },
       { op: 'KSTR',
         args: [ 6, 'AN ERROR!' ] },
       { op: 'MOV', args: [ 7, 4 ] },
       { op: 'CALL',
         args: [ 5, 1, 3, 'call' ] },
       { op: 'JMP', args: [ 3, 1 ] },
       { op: 'JMP', args: [ 3, -19 ] },
       { op: 'UCLO', args: [ 0, 0 ] },
       { op: 'RET0', args: [ 0, 1 ] } ],
    uvdata: [] } ]

$ ./cli.js ~/luatute/tute-coro.lua

/home/daurnimator/src/brozula/interpreter.js:37
    throw new Error("Lua error at " + this.protoIndex + "-" + (this.pc-1) + "\
          ^
Error: Lua error at 2-5
attempt to call a nil value
    at Closure.execute (/home/daurnimator/src/brozula/interpreter.js:37:11)
    at Closure.toFunction.fn (/home/daurnimator/src/brozula/interpreter.js:45:25)
    at /home/daurnimator/src/brozula/cli.js:191:67
    at generate (/home/daurnimator/src/brozula/cli.js:73:5)
    at /home/daurnimator/src/brozula/cli.js:62:7
    at fs.readFile (fs.js:176:14)
    at Object.oncomplete (fs.js:297:15)

`-p` option doesn't print the source code

Hi, I'm getting some weird results with the -p option:

$ cat foobar.lua 
print "foobar"
$ ./cli.js foobar.lua 
foobar
$ ./cli.js -p foobar.lua 
[ { index: 0,
    flags: 2,
    numparams: 0,
    framesize: 2,
    bcins: 
    [ { op: 'GGET', args: [Object] },
    { op: 'KSTR', args: [Object] },
    { op: 'CALL', args: [Object] },
    { op: 'RET0', args: [Object] } ],
    uvdata: [] } ]

This is with node 0.10.1. I'm digging around to try to figure out what's going on...

Script Fails (A Metatable example)

$ cat ~/luatute/tute-oo.lua

local mt = {
    __index = function ( ob , k )
        if ob.parent then
            return ob.parent [ k ]
        end
    end ;
}

local root = setmetatable ( {
        parent = nil
    } , mt )

function root:say(phrase)
    io.stdout:write ( tostring(self) , " says " , phrase , "\n" )
end

function root:derive ( newname )
    return setmetatable ( {
            parent = self ;
        } , mt )
end

root:say ( "I am root" )

local foo = root:derive ( )
foo:say ( "I am foo" )
function foo:say ( phrase )
    io.stdout:write ( tostring(self) , " annouces " , phrase , "\n" )
end
foo:say ( "I am foo" )
root:say ( "I am root" )

$ ./cli.js ~/luatute/tute-oo.lua

/home/daurnimator/src/brozula/interpreter.js:37
    throw new Error("Lua error at " + this.protoIndex + "-" + (this.pc-1) + "\
          ^
Error: Lua error at 4-14
Error: Lua error at 1-3
attempt to index a nil value
    at Closure.execute (/home/daurnimator/src/brozula/interpreter.js:37:11)
    at Closure.toFunction.fn (/home/daurnimator/src/brozula/interpreter.js:45:25)
    at /home/daurnimator/src/brozula/cli.js:191:67
    at generate (/home/daurnimator/src/brozula/cli.js:73:5)
    at /home/daurnimator/src/brozula/cli.js:62:7
    at fs.readFile (fs.js:176:14)
    at Object.oncomplete (fs.js:297:15)

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.