-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds chunk support, which allows users to precompile Lua statements and then execute them later, as opposed re-parsing and code generating at eval time. We achieve this with the following two features 1. The ability to return chunks from the Lua sigil with the 'c' modifier ```elixir ~LUA""" print("hello world") """c ``` 2. The ability to load and evaluate chunks ```elixir {[4], _} = Lua.eval!(~LUA[return 2 + 2]c) ```
- Loading branch information
1 parent
f58fe4e
commit e607f40
Showing
3 changed files
with
91 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
defmodule Lua.Chunk do | ||
@moduledoc """ | ||
A pre-compiled [chunk](https://www.lua.org/pil/1.1.html) of Lua code | ||
that can be executed at a future point in time | ||
""" | ||
|
||
@type t :: %__MODULE__{} | ||
|
||
defstruct [:instructions, :ref] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters