Skip to content

Commit

Permalink
feat: native symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
Bylx666 committed Apr 8, 2024
1 parent bb10056 commit 0ac1a11
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
13 changes: 7 additions & 6 deletions samples/helloworld.ks
Original file line number Diff line number Diff line change
@@ -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);
}
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ static mut LINE:usize = 1;
static mut PLACE:String = String::new();

/// 标志解释器的版本
static VERSION:usize = 100003;
static VERSION:usize = 100004;

/// 解释器发行者(用于区分主版本和魔改版)
///
Expand Down
4 changes: 3 additions & 1 deletion src/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ struct FuncTable {
get_self: fn(Scope)-> *mut Litr,
get_parent: fn(Scope)-> Option<Scope>,
outlive_inc: fn(Scope),
outlive_dec: fn(Scope)
outlive_dec: fn(Scope),
symcls: fn()-> *mut NativeClassDef
}
static FUNCTABLE:FuncTable = FuncTable {
intern,
Expand All @@ -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}
};

/// 原生类型实例
Expand Down
3 changes: 2 additions & 1 deletion src/primitive/sym.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -14,6 +14,7 @@ pub fn init()-> (Interned, *mut NativeClassDef) {
]
);
SYMBOL_CLASS = s.1;
(*SYMBOL_CLASS).to_str = to_str;
s
}
}
Expand Down

0 comments on commit 0ac1a11

Please sign in to comment.