diff --git a/Cargo.lock b/Cargo.lock index a606925..fcb412e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,4 +4,4 @@ version = 3 [[package]] name = "key-lang" -version = "0.1.3" +version = "0.1.4" diff --git a/Cargo.toml b/Cargo.toml index 6c5e346..4584a70 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "key-lang" -version = "0.1.3" +version = "0.1.4" edition = "2021" description = "To be the prettiest and simpliest script" license = "MPL-2.0" diff --git a/samples/helloworld.ks b/samples/helloworld.ks index 967c990..358a0c2 100644 --- a/samples/helloworld.ks +++ b/samples/helloworld.ks @@ -1,9 +1,10 @@ mod D:\code\rs\tst\target\debug\tstlib.dll> m; -let s = "芙 -卡 -洛 -斯"; -for c: s.lines() { - log(c) +let iter; +{ + let a = "启动启动启动!"; + iter = a.lines(); +} +for l:iter { + log(l); } diff --git a/src/main.rs b/src/main.rs index 96d8804..91335aa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,7 +28,7 @@ static mut LINE:usize = 1; static mut PLACE:String = String::new(); /// 标志解释器的版本 -static VERSION:usize = 100003; +static VERSION:usize = 100004; /// 解释器发行者(用于区分主版本和魔改版) /// diff --git a/src/native.rs b/src/native.rs index 9af9e25..7c36ce4 100644 --- a/src/native.rs +++ b/src/native.rs @@ -52,7 +52,8 @@ struct FuncTable { get_self: fn(Scope)-> *mut Litr, get_parent: fn(Scope)-> Option, outlive_inc: fn(Scope), - outlive_dec: fn(Scope) + outlive_dec: fn(Scope), + symcls: fn()-> *mut NativeClassDef } static FUNCTABLE:FuncTable = FuncTable { intern, @@ -72,6 +73,7 @@ static FUNCTABLE:FuncTable = FuncTable { get_parent: |cx|cx.parent, outlive_inc: outlive::increase_scope_count, outlive_dec: outlive::decrease_scope_count, + symcls: ||unsafe{crate::primitive::sym::SYMBOL_CLASS} }; /// 原生类型实例 diff --git a/src/primitive/sym.rs b/src/primitive/sym.rs index dc13a3b..e2cc81a 100644 --- a/src/primitive/sym.rs +++ b/src/primitive/sym.rs @@ -4,7 +4,7 @@ use crate::{ pub const ITER_END:usize = 1; -static mut SYMBOL_CLASS: *mut NativeClassDef = std::ptr::null_mut(); +pub static mut SYMBOL_CLASS: *mut NativeClassDef = std::ptr::null_mut(); pub fn init()-> (Interned, *mut NativeClassDef) { unsafe { @@ -14,6 +14,7 @@ pub fn init()-> (Interned, *mut NativeClassDef) { ] ); SYMBOL_CLASS = s.1; + (*SYMBOL_CLASS).to_str = to_str; s } }