chore(lua): rename env() to get_env()
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
ba0889265e
commit
8c52d47692
4 changed files with 12 additions and 9 deletions
|
@ -250,6 +250,6 @@ void open_environment(lua_State * L) {
|
|||
SET_GLOBAL_FUN(mk_environment, "environment");
|
||||
SET_GLOBAL_FUN(environment_pred, "is_environment");
|
||||
SET_GLOBAL_FUN(get_environment, "get_environment");
|
||||
SET_GLOBAL_FUN(get_environment, "env");
|
||||
SET_GLOBAL_FUN(get_environment, "get_env");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,10 @@ Variable x : Int
|
|||
-- Add a variable to the environment using Lua
|
||||
-- The type of the new variable is equal to the type
|
||||
-- of x
|
||||
typeofx = env():check_type(Const("x"))
|
||||
local env = get_environment()
|
||||
typeofx = env:check_type(Const("x"))
|
||||
print("type of x is " .. tostring(typeofx))
|
||||
env():add_var("y", typeofx)
|
||||
env:add_var("y", typeofx)
|
||||
**)
|
||||
|
||||
Check x + y
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
Variable x : Int
|
||||
|
||||
(**
|
||||
local N = 100
|
||||
local N = 100
|
||||
local env = get_environment()
|
||||
-- Create N variables with the same type of x
|
||||
typeofx = env():check_type(Const("x"))
|
||||
typeofx = env:check_type(Const("x"))
|
||||
for i = 1, N do
|
||||
env():add_var("y_" .. i, typeofx)
|
||||
env:add_var("y_" .. i, typeofx)
|
||||
end
|
||||
**)
|
||||
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
Variable x : Int
|
||||
|
||||
(**
|
||||
ty_x = env():check_type(Const("x"))
|
||||
local env = get_environment()
|
||||
ty_x = env:check_type(Const("x"))
|
||||
c = context()
|
||||
c = context(c, "x", ty_x)
|
||||
c = context(c, "y", ty_x)
|
||||
print(c)
|
||||
o = env():find_object("x")
|
||||
o = env:find_object("x")
|
||||
print(o)
|
||||
o = env():find_object("y")
|
||||
o = env:find_object("y")
|
||||
print(o)
|
||||
**)
|
Loading…
Reference in a new issue