2020-04-30 16:32:41 +00:00
|
|
|
#include "wren/vm_fun.hpp"
|
2020-04-25 18:45:59 +00:00
|
|
|
#include "wren/def_configuration.hpp"
|
2020-04-24 23:49:46 +00:00
|
|
|
#include <iostream>
|
|
|
|
#include <chrono>
|
|
|
|
#include <thread>
|
|
|
|
|
|
|
|
namespace {
|
2020-04-26 15:19:02 +00:00
|
|
|
const constexpr char g_script[] = ""
|
|
|
|
R"(class Math {
|
|
|
|
construct new() {}
|
|
|
|
foreign add(a, b)
|
|
|
|
}
|
|
|
|
System.print("I am running in a VM!")
|
|
|
|
var myvar = Math.new()
|
|
|
|
myvar.add(5, 6)
|
|
|
|
System.print("Script done")
|
|
|
|
)";
|
|
|
|
|
2020-04-24 23:49:46 +00:00
|
|
|
} //unnamed namespace
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
std::cout << "hello world\n";
|
2020-04-25 18:45:59 +00:00
|
|
|
wren::DefConfiguration config;
|
|
|
|
wren::VM vm(&config);
|
2020-04-26 15:19:02 +00:00
|
|
|
vm.interpret("my_module", g_script);
|
2020-04-24 23:49:46 +00:00
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(2000));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|