Exemplo n.º 1
0
def exe_w_limits(c):
	vm = GridLangVM()
	vm.capture_exception = True
	vm.data_limit = 99
	vm.set_code(c)
	vm.run()
	return vm
Exemplo n.º 2
0
def exe(c):
	vm = GridLangVM()
	vm.capture_exception = True
	vm.set_code(c)
	vm.run()
	return vm
Exemplo n.º 3
0
sys.path.append("..")
from gridcontrol.engine.ffi import GridControlFFI

def fake_ffi(vm, args):
	return 0

if __name__ == "__main__":
	if len(sys.argv) > 1:
		fn = sys.argv[1]
	else:
		fn = "code.gridlang"

	with open(fn) as fh:
		code = fh.read()
	c = GridLangParser.parse(code, constants=GridControlFFI.CONSTANTS)

	vm = None
	data = None

	while 1:
		if vm is not None:
			data = vm.freeze()
		vm = GridLangVM()
		vm.ffi = fake_ffi
		vm.set_code(c)
		if data is not None:
			vm.thaw(data)
		if vm.run(10):
			break