Skip to content

Commit c647619

Browse files
authored
Merge pull request #234 from nature-lang/release/0.7.4
reacotr: reduction type add visited
2 parents 4dc5243 + 786cede commit c647619

File tree

17 files changed

+422
-304
lines changed

17 files changed

+422
-304
lines changed

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,23 @@ A general-purpose system programming language and compiler, designed to build hi
77
- Lightweight, concise, and consistent syntax design, easy to master and get started quickly
88
- Strong type system, static analysis and compilation, memory safety, exception handling, making it easy to write secure and reliable software
99
- Built-in concurrency primitives: go/future/channel/select
10+
- Comprehensive type system supporting generics, enum, tagged union, interface, nullable(?), errable(!)
1011
- Compiles directly to machine code for the target platform, does not rely on LLVM, and supports cross-compilation.
1112
- Simple deployment, efficient compilation, static linking based on musl libc with good cross-platform characteristics
12-
- Comprehensive type system supporting generics, union types, interfaces, nullable(?), errable(!)
13+
- High-performance C FFI implementation with zero-overhead calls to C standard library functions
1314
- High-performance GC implementation with very short STW (Stop The World)
1415
- High-performance memory allocator implementation, referencing tcmalloc
1516
- High-performance shared-stack coroutine implementation, capable of millions of coroutine switches per second
1617
- High-performance IO based on libuv implementation
1718
- High-performance runtime and compiler based on pure C implementation
18-
- Built-in data structures vec/map/set/tup and common standard library implementations
19-
- Function calls follow system ABI, built-in libc, c std functions are called without performance loss.
19+
- Built-in data structures vec/string/map/set/tup and common standard library implementations
20+
- Test as a first-class citizen, write test blocks directly in source files
2021
- Centralized package management system npkg
2122
- Editor LSP support
2223

2324
## Overview
2425

25-
The nature programming language has reached an early usable version, with a basically stable syntax API that will not change significantly before version 1.0. Future versions will add some necessary and commonly used syntax features such as enum, ternary operators, struct labels, etc.
26-
27-
Key features to be completed include controllable memory allocator, LLM coding adaptation, DSL test framework, GUI adaptation, and WASM3.0 adaptation.
26+
The nature programming language has reached an early usable version, and its core syntax features are now in place. Key features still to be completed include unsafe runtime mode, LLM coding adaptation, C target adaptation, and WASM3.0 target adaptation.
2827

2928
The current version supports compilation for the following target architectures: linux_amd64, linux_arm64, linux_riscv64, darwin_amd64, darwin_arm64.
3029

README_CN.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,30 @@
88
- 轻量、简洁、一致性的语法设计,轻松掌握并快速上手使用
99
- 强类型、静态分析与编译、内存安全、异常处理,轻松编写安全可靠的软件
1010
- 内置并发原语 go/future/channel/select
11+
- 完善的类型系统,支持 generics、enum、tagged union、interface、nullable(?)、errable(!)
1112
- 直接编译为目标平台的机器码,不依赖 LLVM,并支持交叉编译
1213
- 部署简单,高效编译,基于 musl libc 进行静态链接,具备良好的跨平台特性
13-
- 完善的类型系统,支持泛型、联合类型、interface、nullable(?)、errable(!)
14+
- 高性能 C FFI 实现,无性能损耗调用 C 标准库函数
1415
- 高性能 GC 实现,具有非常短暂的 STW (Stop The World)
1516
- 高性能内存分配器实现,参考 tcmalloc
1617
- 高性能共享栈协程实现,每秒能够进行数百万次的协程切换
1718
- 基于 libuv 实现的高性能 IO
1819
- 纯 C 实现的高性能 runtime 和编译器
19-
- 内置数据结构 vec/map/set/tup 和常用标准库实现
20-
- 函数调用遵守 system ABI,内置 libc,无性能损耗调用 c 标准库函数
20+
- 内置数据结构 vec/string/map/set/tup 和常用标准库实现
21+
- test 作为一等公民,直接在源码文件中编写测试块
2122
- 集中式包管理系统 npkg
2223
- 编辑器 lsp 支持
2324

2425
## 概况
2526

26-
nature 编程语言已经达到早期可用版本,语法 API 基本稳定,在 1.0 版本之前不会有大幅的变化,后续版本会添加一些必要的语法,如 enum,三元运算符,struct label 等。
27-
28-
待完成的关键特性有可控内存分配器,LLM 编码适配,DSL 测试框架,GUI 适配,WASM3.0 适配。
27+
nature 编程语言已经达到早期可用版本,核心语法功能以添加完成。待完成的关键特性有 unsafe 运行模式,LLM 编码适配,C target 适配,WASM3.0 target 适配。
2928

3029
当前版本编译目标架构包含 linux_amd64、linux_arm64、linux_riscv64、darwin_amd64、darwin_arm64。
3130

3231
nature 包含一组测试用例和标准库用来测试基本功能和语法的可用性,包含一组中小型项目测试整体可用性,还未经过大型的项目测试。
3332

3433
官网 https://nature-lang.cn
3534

36-
3735
## 安装
3836

3937
[releases](https://github.com/nature-lang/nature/releases) 中下载并解压 nature 安装包(注意权限是否正确)。将解压后的 nature 文件夹移动到 `/usr/local/` 下,并将 `/usr/local/nature/bin` 目录加入到系统环境变量。

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.7.3
1+
v0.7.4

nls/src/analyzer/common.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,10 @@ impl Type {
129129
err: false,
130130
};
131131

132-
if Self::is_impl_builtin_type(&kind) {
132+
if Self::is_origin_type(&kind) {
133133
t.ident = kind.to_string();
134134
t.ident_kind = TypeIdentKind::Builtin;
135+
t.args = Vec::new();
135136
}
136137

137138
return t;
@@ -635,17 +636,13 @@ pub struct TypeFn {
635636
#[repr(u8)]
636637
pub enum ReductionStatus {
637638
Undo = 1,
638-
Doing = 2,
639-
Doing2 = 3,
640-
Done = 4,
639+
Done = 2,
641640
}
642641

643642
impl Display for ReductionStatus {
644643
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
645644
match self {
646645
ReductionStatus::Undo => write!(f, "undo"),
647-
ReductionStatus::Doing => write!(f, "doing"),
648-
ReductionStatus::Doing2 => write!(f, "doing2"),
649646
ReductionStatus::Done => write!(f, "done"),
650647
}
651648
}

nls/src/analyzer/semantic.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,12 +669,19 @@ impl<'a> Semantic<'a> {
669669
let symbol_name = fndef.symbol_name.clone();
670670

671671
if fndef.impl_type.kind.is_exist() {
672+
let mut impl_type_ident = fndef.impl_type.ident.clone();
673+
674+
if Type::is_impl_builtin_type(&fndef.impl_type.kind) {
675+
impl_type_ident = fndef.impl_type.kind.to_string();
676+
}
677+
672678
// 非 builtin type 则进行 resolve type 查找
673679
if !Type::is_impl_builtin_type(&fndef.impl_type.kind) {
674680
// resolve global ident
675681
if let Some(symbol_id) = self.resolve_typedef(&mut fndef.impl_type.ident) {
676682
// ident maybe change
677683
fndef.impl_type.symbol_id = symbol_id;
684+
impl_type_ident = fndef.impl_type.ident.clone();
678685

679686
// 自定义泛型 impl type 必须显式给出类型参数(仅检查 impl_type.args)
680687
if let Some(symbol) = self.symbol_table.get_symbol(symbol_id) {
@@ -704,7 +711,7 @@ impl<'a> Semantic<'a> {
704711
}
705712
}
706713

707-
fndef.symbol_name = format_impl_ident(fndef.impl_type.ident.clone(), symbol_name);
714+
fndef.symbol_name = format_impl_ident(impl_type_ident, symbol_name);
708715

709716
// register to global symbol table
710717
match self.symbol_table.define_symbol_in_scope(

nls/src/analyzer/syntax.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3222,10 +3222,7 @@ impl<'a> Syntax {
32223222
t
32233223
} else if (first_token.token_type == TokenType::Ident) && self.ident_is_builtin_type(first_token.clone()) {
32243224
if self.next_is(1, TokenType::LeftAngle) {
3225-
let mut t = self.parser_single_type()?;
3226-
t.ident = first_token.literal.clone();
3227-
t.ident_kind = TypeIdentKind::Builtin;
3228-
t
3225+
self.parser_single_type()?
32293226
} else {
32303227
self.must(TokenType::Ident)?;
32313228
let mut t = Type::unknown();
@@ -3236,9 +3233,6 @@ impl<'a> Syntax {
32363233
"tup" => TypeKind::Tuple(Vec::new(), 0),
32373234
_ => TypeKind::Ident,
32383235
};
3239-
t.ident = first_token.literal.clone();
3240-
t.ident_kind = TypeIdentKind::Builtin;
3241-
t.args = Vec::new();
32423236
t.start = first_token.start;
32433237
t.end = first_token.end;
32443238
t
@@ -3247,9 +3241,6 @@ impl<'a> Syntax {
32473241
self.must(TokenType::Chan)?;
32483242
let mut t = Type::unknown();
32493243
t.kind = TypeKind::Chan(Box::new(Type::unknown()));
3250-
t.ident = "chan".to_string();
3251-
t.ident_kind = TypeIdentKind::Builtin;
3252-
t.args = Vec::new();
32533244
t.start = first_token.start;
32543245
t.end = first_token.end;
32553246
t

0 commit comments

Comments
 (0)