-
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.
- Loading branch information
1 parent
e27163d
commit ae61e9a
Showing
6 changed files
with
71 additions
and
30 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
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 |
---|---|---|
@@ -1,7 +1,4 @@ | ||
//! Scripting engine for Surreal | ||
pub use lang::*; | ||
pub use runtime::*; | ||
|
||
mod lang; | ||
mod runtime; | ||
pub mod lang; | ||
pub mod runtime; |
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
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,18 @@ | ||
use common::Variant; | ||
|
||
#[test] | ||
pub fn it_should_compile_and_execute_wren_programs() { | ||
let program = "1 + 2 * 3"; | ||
|
||
let expression = surreal_scripting::lang::wren::parse(program).unwrap(); | ||
let mut opcodes = surreal_scripting::runtime::compiler::compile_expression(&expression).unwrap(); | ||
|
||
opcodes.push(surreal_scripting::runtime::Opcode::Return); | ||
|
||
println!("{:?}", opcodes); | ||
|
||
let mut machine = surreal_scripting::runtime::machine::VirtualMachine::default(); | ||
let result = machine.execute(&opcodes).unwrap(); | ||
|
||
assert_eq!(result, Some(Variant::I64(7))); | ||
} |