Skip to content

feat(vm): integrate new Parser / Compiler / VM#112

Open
davydog187 wants to merge 4 commits intomainfrom
drop-luerl
Open

feat(vm): integrate new Parser / Compiler / VM#112
davydog187 wants to merge 4 commits intomainfrom
drop-luerl

Conversation

@davydog187
Copy link
Contributor

This PR integrates the new system into the user-facing library. Since we dont have full feature-parity yet, some of the tests are skipped.

  • Phase 0: Arithmetic operations and single return
  • Phase 1: Local variables with register assignment
  • Phase 2: Global variables (get_global, set_global)
  • Phase 3: Conditionals (if/elseif/else, and/or short-circuit)
  • Phase 4: Loops (while, repeat, numeric for)
  • Phase 5: Functions, closures, and upvalues
  • Phase 6: Tables and method calls
  • Phase 7: Native function calls (Lua→Elixir calling convention)
  • Phase 8: Generic for, varargs, and multiple returns
  • Phase 9: String concatenation and bitwise operations
  • Phase 10: Value encoding/decoding (Lua.VM.Value)
  • Phase 11: deflua integration (reimplement lib/lua.ex against VM.State)
  • Phase 12: Peephole optimizer
  • Phase 13: Remove Luerl dependency

This PR integrates the new system into the user-facing library. Since we
dont have full feature-parity yet, some of the tests are skipped.
Sets the path patterns that Luerl will look in when requiring Lua scripts. For example,
if you store Lua files in your application's priv directory:

iex> lua = Lua.new(exclude: [[:package], [:require]])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bring back and comment out


#{Enum.join(errors, "\n")}

#{Util.format_stacktrace(stacktrace, state)}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leave a note about stacktraces here

Comment on lines 130 to 132
> In order to use `Lua.set_lua_paths/2`, the following functions cannot be sandboxed:
> * `[:package]`
> * `[:require]`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bring back these comments

Comment on lines 136 to 142
def set_lua_paths(%__MODULE__{} = lua, paths) when is_list(paths) do
set_lua_paths(lua, Enum.join(paths, ";"))
end

def set_lua_paths(%__MODULE__{} = lua, paths) when is_binary(paths) do
set!(lua, ["package", "path"], paths)
def set_lua_paths(%__MODULE__{} = _lua, _paths) do
raise Lua.RuntimeException, "set_lua_paths is not yet supported in the new VM"
end
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bring this back

Comment on lines +554 to +555
iex> {[ref], lua} = Lua.eval!(Lua.new(), "return function(x) return x end", decode: false)
iex> {:ok, [ret], _lua} = Lua.call_function(lua, ref, [42])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change ghanges back to their previous examples. If we can't do it like this right now, comment out and leave a todo via #iex>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant