Open main menu
Posts
Gists
Guilds
Users
Decipher
Docs
Open user menu
Log in
Sign up
Create a new gist
Posts
Gists
Guilds
Users
Decipher
Docs
Files
igs.src
prepend.src
append.src
build.src
meta.src
boilerplates/append.src
boilerplates/prepend.src
static/meta.src
igs.src
get_scope = function()
scope = {}
import_code("/home/me/projects/igs/meta.src")
scope.map = map
scope.l
i
st = list
scope.number = number
scope.string = string
scope.globals = globals
return scope
end function
shallow_copy
= function(
obj1, obj2)
for i in obj2.indexes
obj1[@i] = @obj2[@i]
end for
end function
transfer_scop
e =
function(scope)
shallow_copy(map, scope.map)
shallow_copy(list, scope.list)
shallow_copy(number, scope.number)
shallow_copy(string, scope.string)
shallow_copy(globals, scope.globals)
end function
a = "hello"
eval = function(code)
comp = get_shell.host_computer
PREPEND_CODE = comp.File("/home/me/projects/igs/prepend.src").get_content
APPEND_CODE = comp.File("/home/me/projects/igs/append.src").get_content
EVAL_BUILD_PATH = "/home/me/evals"
EVAL_SCRIPT_NAME = "evalScript.src"
eval_script_code = PREPEND_CODE + char(10) +
code + char(10) +
APPEND_CODE
eval_script = comp.File(EVAL_BUILD_PATH + "/" + EVAL_SCRIPT_NAME)
if eval_script != null then
eval_script.delete
i
nput_code
= function(
line = 0)
cod
e =
user_input("igs("+line+")> ")
if code.len > 0 and code.values[-1] == char(92) then
return
code
[0:-1]
+ char(10) +
input_code(line + 1)
end if
comp.touch(EVAL_BUILD_PATH, EVAL_SCRIPT_NAME)
eval_script = comp.File(EVAL_BUILD_PATH + "/" + EVAL_SCRIPT_NAME)
eval_script.set_content(eval_script_code)
get_shell.build(EVAL_BUILD_PATH + "/" + EVAL_SCRIPT_NAME, EVAL_BUILD_PATH)
get_custom_object.parent_scope = get_scope
get_shell.launch(EVAL_BUILD_PATH + "/" + EVAL_SCRIPT_NAME.split(".")[0])
transfer_scope(get_custom_object.child_scope)
return code
end function
while true
arbitrary_code =
user_
input
("igs> ")
eval(arbitrary
_code
)
end while
arbitrary_code = input_code
Meta.init()
Meta.eval(arbitrary_code)
end while
prepend.src
get_scope = function()
scope = {}
scope.map = map
scope.list = list
scope.number = number
scope.string = string
scope.globals = globals
return scope
end function
shallow_copy = function(obj1, obj2)
for i in obj2.indexes
obj1[@i] = @obj2[@i]
end for
end function
transfer_scope = function(scope)
shallow_copy(map, scope.map)
shallow_copy(list, scope.list)
shallow_copy(number, scope.number)
shallow_copy(string, scope.string)
shallow_copy(globals, scope.globals)
end function
parent_scope = get_custom_object.parent_scope
transfer_scope(parent_scope)
append.src
get_custom_object.child_scope = get_scope
build.src
LIB_FILE_PATH = "/home/me/projects/igs/meta.src"
STATIC_LIB_PATH = "/home/me/projects/igs/static/meta.src"
comp = get_shell.host_computer
file = comp.File(LIB_FILE_PATH)
lines = file.get_content.split(char(10))
prepend_index = lines.indexOf("// PREPEND_MARK") + 1
append_index = lines.indexOf("// APPEND_MARK") + 1
prepend_path = lines[prepend_index].split("""")[1]
append_path = lines[append_index].split("""")[1]
static_prepend = comp.File(prepend_path).get_content
append_prepend = comp.File(append_path).get_content
static_prepend = static_prepend.replace("""", """""")
append_prepend = append_prepend.replace("""", """""")
new_prepend_line = lines[prepend_index].split("=")[0] + " = " + """" + static_prepend + """"
new_append_line = lines[append_index].split("=")[0] + " = " + """" + append_prepend + """"
lines[prepend_index] = new_prepend_line
lines[append_index] = new_append_line
// ---------
comp.touch(STATIC_LIB_PATH.split("/")[0:-1].join("/"), STATIC_LIB_PATH.split("/")[-1])
comp.File(STATIC_LIB_PATH).set_content(lines.join(char(10)))
meta.src
Scoper = {}
Scoper.get_scope = function()
scope = {}
scope.map = map
scope.list = list
scope.number = number
scope.string = string
scope.globals = globals
return scope
end function
Scoper.shallow_copy = function(obj1, obj2)
for i in obj2.indexes
obj1[@i] = @obj2[@i]
end for
end function
Scoper.transfer_scope = function(scope)
self.shallow_copy(map, scope.map)
self.shallow_copy(list, scope.list)
self.shallow_copy(number, scope.number)
self.shallow_copy(string, scope.string)
self.shallow_copy(globals, scope.globals)
end function
Meta = {}
Meta.shell = get_shell
Meta.computer = Meta.shell.host_computer
// PREPEND_MARK
Meta.prepend_code = Meta.computer.File("/home/me/projects/igs/boilerplates/prepend.src").get_content
// APPEND_MARK
Meta.append_code = Meta.computer.File("/home/me/projects/igs/boilerplates/append.src").get_content
// required options:
// build_full_path, example /home/me/evals/evalscript.src
Meta.init = function(build_full_path = "/home/guest/evalscript.src")
self.build_full_path = build_full_path
self.build_path = self.build_full_path.split("/")[0:-1].join("/")
self.build_name = self.build_full_path.split("/")[-1]
self.build_bin_name = self.build_name.split(".")[0]
self.build_bin_full_path = self.build_path + "/" + self.build_bin_name
end function
Meta.eval = function(code)
eval_script_code = self.prepend_code + char(10) + code + char(10) + self.append_code
self.computer.touch(self.build_path, self.build_name)
eval_script = self.computer.File(self.build_full_path)
eval_script.set_content(eval_script_code)
get_shell.build(self.build_full_path, self.build_path)
get_custom_object.parent_scope = Scoper.get_scope
get_shell.launch(self.build_bin_full_path)
Scoper.transfer_scope(get_custom_object.child_scope)
end function
boilerplates/append.src
get_custom_object.child_scope = get_scope
boilerplates/prepend.src
get_scope = function()
scope = {}
scope.map = map
scope.list = list
scope.number = number
scope.string = string
scope.globals = globals
return scope
end function
shallow_copy = function(obj1, obj2)
for i in obj2.indexes
obj1[@i] = @obj2[@i]
end for
end function
transfer_scope = function(scope)
shallow_copy(map, scope.map)
shallow_copy(list, scope.list)
shallow_copy(number, scope.number)
shallow_copy(string, scope.string)
shallow_copy(globals, scope.globals)
end function
parent_scope = get_custom_object.parent_scope
transfer_scope(parent_scope)
static/meta.src
Scoper = {}
Scoper.get_scope = function()
scope = {}
scope.map = map
scope.list = list
scope.number = number
scope.string = string
scope.globals = globals
return scope
end function
Scoper.shallow_copy = function(obj1, obj2)
for i in obj2.indexes
obj1[@i] = @obj2[@i]
end for
end function
Scoper.transfer_scope = function(scope)
self.shallow_copy(map, scope.map)
self.shallow_copy(list, scope.list)
self.shallow_copy(number, scope.number)
self.shallow_copy(string, scope.string)
self.shallow_copy(globals, scope.globals)
end function
Meta = {}
Meta.shell = get_shell
Meta.computer = Meta.shell.host_computer
// PREPEND_MARK
Meta.prepend_code = "get_scope = function()
scope = {}
scope.map = map
scope.list = list
scope.number = number
scope.string = string
scope.globals = globals
return scope
end function
shallow_copy = function(obj1, obj2)
for i in obj2.indexes
obj1[@i] = @obj2[@i]
end for
end function
transfer_scope = function(scope)
shallow_copy(map, scope.map)
shallow_copy(list, scope.list)
shallow_copy(number, scope.number)
shallow_copy(string, scope.string)
shallow_copy(globals, scope.globals)
end function
parent_scope = get_custom_object.parent_scope
transfer_scope(parent_scope)
"
// APPEND_MARK
Meta.append_code = "get_custom_object.child_scope = get_scope"
// required options:
// build_full_path, example /home/me/evals/evalscript.src
Meta.init = function(build_full_path = "/home/guest/evalscript.src")
self.build_full_path = build_full_path
self.build_path = self.build_full_path.split("/")[0:-1].join("/")
self.build_name = self.build_full_path.split("/")[-1]
self.build_bin_name = self.build_name.split(".")[0]
self.build_bin_full_path = self.build_path + "/" + self.build_bin_name
end function
Meta.eval = function(code)
eval_script_code = self.prepend_code + char(10) + code + char(10) + self.append_code
self.computer.touch(self.build_path, self.build_name)
eval_script = self.computer.File(self.build_full_path)
eval_script.set_content(eval_script_code)
get_shell.build(self.build_full_path, self.build_path)
get_custom_object.parent_scope = Scoper.get_scope
get_shell.launch(self.build_bin_full_path)
Scoper.transfer_scope(get_custom_object.child_scope)
end function