aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorGustav Sörnäs <gustav@sornas.net>2021-01-28 22:05:44 +0100
committerGustav Sörnäs <gustav@sornas.net>2021-01-28 22:05:44 +0100
commit8eea80192eb1d913e1d4840af3a4a2b2c5a82b9d (patch)
tree1858c7601dc56f9047427a1d333a9d4734871755 /src/lib.rs
parente255b79af57d1e202816ccbb59e73115b27e9c38 (diff)
parent3a987d3dfe0014bed43151874882c5b4f20eb7af (diff)
downloadsylt-8eea80192eb1d913e1d4840af3a4a2b2c5a82b9d.tar.gz
Merge branch 'structs'
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/lib.rs b/src/lib.rs
index e83d11f..c190918 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,5 +1,4 @@
use std::path::Path;
-use std::rc::Rc;
pub mod compiler;
pub mod tokenizer;
@@ -23,7 +22,7 @@ pub fn run(tokens: TokenStream, path: &Path, print: bool) -> Result<(), Vec<Erro
Ok(blocks) => {
let mut vm = vm::VM::new().print_blocks(print).print_ops(print);
vm.typecheck(&blocks)?;
- if let Err(e) = vm.run(Rc::clone(&blocks[0])) {
+ if let Err(e) = vm.run(&blocks) {
Err(vec![e])
} else {
Ok(())
@@ -273,6 +272,31 @@ a() <=> 4
*/
);
+ test_multiple!(
+ blob,
+ simple: "blob A {}",
+ instantiate: "blob A {}
+ a := A()",
+ field: "blob A { a: int }",
+ field_assign: "blob A { a: int }
+ a := A()
+ a.a = 2",
+ field_get: "blob A { a: int }
+ a := A()
+ a.a = 2
+ //TODO a.a <=> 2
+ 2 <=> a.a",
+ multiple_fields: "blob A {
+ a: int
+ b: int
+ }
+ a := A()
+ a.a = 2
+ a.b = 3
+ //TODO a.a + a.b <=> 5
+ 5 <=> a.a + a.b"
+ );
+
test_file!(scoping, "tests/scoping.tdy");
test_file!(for_, "tests/for.tdy");
}