Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fix mrb_generate_code

  • Loading branch information...
commit 3899dfbf9273eae6c2ffee2398bd7cdc6a2c3bc0 1 parent 3459fcf
Ryan Scott Lewis authored

Showing 2 changed files with 12 additions and 9 deletions. Show diff stats Hide diff stats

  1. +8 5 examples/sample.lua
  2. +4 4 lib/lua-mruby.c
13 examples/sample.lua
@@ -3,6 +3,9 @@ package.cpath = package.cpath .. ";../pkg/?.so"
3 3
4 4 require "mruby"
5 5
  6 +mruby.run(" puts 'Hello, World!'" )
  7 +
  8 +
6 9 -- mruby.run([[
7 10 --
8 11 -- def tak(x, y, z)
@@ -18,8 +21,8 @@ require "mruby"
18 21 --
19 22 -- ]])
20 23
21   -mrbState = mrbOpen()
22   -print( mrbState ) -- Print out the MRuby state
23   -print( mrbState:stack() ) -- Print out the MRuby state's stack
24   -mrbClose()
25   -
  24 +-- mrbState = mrbOpen()
  25 +-- print( mrbState ) -- Print out the MRuby state
  26 +-- print( mrbState:stack() ) -- Print out the MRuby state's stack
  27 +-- mrbClose()
  28 +--
8 lib/lua-mruby.c
@@ -12,12 +12,12 @@
12 12 static int lua_mruby_run(lua_State *L) {
13 13 mrb_state *mrb = mrb_open();
14 14 const char *mrb_code = lua_tostring(L, 1);
15   - struct mrb_parser_state *p = mrb_parse_string(mrb, mrb_code, NULL);
16   - int mrb_generated_code = mrb_generate_code(mrb, p-> tree);
  15 + struct mrb_parser_state* p = mrb_parse_string(mrb, mrb_code, NULL);
  16 + int n = mrb_generate_code(mrb, p);
17 17
18   - mrb_run( mrb, mrb_proc_new(mrb, mrb->irep[mrb_generated_code]), mrb_nil_value() );
  18 + mrb_run( mrb, mrb_proc_new(mrb, mrb->irep[n]), mrb_nil_value() );
19 19
20   - int lua_return = mrb_generated_code > 0 ? 0 : 1;
  20 + int lua_return = n > 0 ? 0 : 1;
21 21 lua_pushnumber(L, lua_return);
22 22
23 23 mrb_close(mrb);

0 comments on commit 3899dfb

Please sign in to comment.
Something went wrong with that request. Please try again.