Skip to content

Commit 61b3246

Browse files
committed
fix: build failed in workdir=/root
1 parent d6e4dc7 commit 61b3246

File tree

2 files changed

+51
-31
lines changed

2 files changed

+51
-31
lines changed

README.md

+38-27
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,57 @@
22

33
A general-purpose open-source programming language and compiler designed to provide developers with an **elegant and concise** development experience, enabling them to build secure and reliable cross-platform software **simply and efficiently**.
44

5+
56
## Features
67

7-
### Implemented Features
8+
- ✓ Simple, natural, and consistent syntax design
9+
- ✓ Independent compilation system, no dependency on llvm, supports cross-platform compilation
10+
- ✓ Well-formed type system with support for generics, null-value safety, and error handling
11+
- ✓ Automated GC, with very short STW
12+
- ✓ Modularity and package management system, npkg
13+
- ✓ Built-in shared-stack concatenation, millions of concatenation switches per second
14+
- ✓ Built-in libuv cooperates with the concatenation to handle IO event loops
15+
- ✓ Built-in implementations of common data structures and standard libraries, and easy interaction with C
16+
- ✓ Editor lsp support
17+
- ○ Asymptotic GC, capable of manual memory management
18+
- ○ Tests DSLs, efficient and stable use of AI coding
19+
- ○ macho cross-platform connector, currently lacks the macho linker darwin can't be cross-platform compilation.
20+
- ○ Improvement of collaborative scheduling system
21+
- ○ Cross-platform compilation support for wasm and risc64 platforms
22+
- ○ Compilation to readable golang programming language
823

9-
- Clean, natural, and consistent syntax design
10-
- Independent compilation system without LLVM dependency, supporting cross-platform compilation for linux/darwin on amd64/arm64
11-
- Comprehensive type system with support for generics, null safety, and error handling
12-
- Automatic garbage collection with very brief STW (Stop-The-World) pauses
13-
- Modular design with npkg package management system
14-
- Built-in shared-stack coroutines capable of millions of context switches per second
15-
- Built-in libuv integration with coroutine-based IO event loop
16-
- Built-in common data structures and standard library implementation with convenient C language interoperability
17-
- LSP (Language Server Protocol) support for editors
24+
## Project Status
1825

19-
### Planned Features
26+
The nature programming language has reached a usable version, and the syntax APIs are basically stable, there will not be any drastic changes before version 1.0, but there are some minor syntax changes.
2027

21-
- Progressive garbage collection with manual memory management capabilities
22-
- Test module with dedicated testing DSL, aimed at efficient and stable AI-assisted coding
23-
- Enhanced GC and non-preemptive coroutine scheduling system
24-
- Cross-platform compilation support for WASM and RISC64 platforms
25-
- Compilation to readable Go code
28+
The current version of nature source code supports compilation on the following target platforms
29+
- linux/amd64
30+
- linux/arm64
31+
- darwin/amd64
32+
- darwin/arm64
2633

27-
## Project Status
34+
nature includes a set of test cases and a standard library to test the usability of the syntax, but it has not been tested on a medium to large scale project, and so there are still many bugs.
2835

29-
The project is currently under development. While the current syntax and API are relatively stable, minor syntax changes may occur before version 1.0.
36+
Major work in the next versions of The main work is
37+
- Standard library refinement
38+
- Gathering user feedback
39+
- Project validation and bug fixes
40+
- Refinement of language features
41+
- Compilation into a readable golang programming language to increase the usability of the nature programming language
3042

31-
The project includes a test suite and standard library to validate syntax functionality, though it hasn't been tested in medium to large-scale projects yet.
43+
Official website: [https://nature-lang.org](https://nature-lang.org)
3244

33-
Given Nature's current features, it is suitable for game engine and game development, scientific computing and AI, operating systems and IoT, as well as web development.
45+
## Design Philosophy
3446

35-
Future development priorities include:
36-
- Standard library enhancement
37-
- Project validation and bug fixes
38-
- Implementation of planned features listed above
47+
golang is the programming language I work with. It has a simple syntax, an excellent and high-performance cross-platform compiler and runtime implementations, an advanced concurrent design style, and a high-performance network. It has an excellent, high-performance cross-platform compiler and runtime implementation, an advanced concatenation design style, high-performance network I/O, and good support for standard libraries. However, there are some inconveniences.
3948

40-
nature is a project developed out of interest. golang is the programming language I use in my daily work, so nature is designed to be a continuation and optimization of the golang programming language, as described in the Features section.
49+
- Syntax is too simple, leading to lack of expressiveness.
50+
- Type system is not perfect, lack of nullable, enumerated parameter, generic (now available), etc.
51+
- Error handling mechanism is cumbersome.
52+
- GC and preemptive scheduling design is very good, but it also limits the scope of golang's application in areas such as GUI, OS, game development, and AI. nature is designed to be a continuation and optimization of the golang programming language, and to pursue certain differences, as described in the Features section.
4153

42-
golang has an excellent and high-performance cross-platform compiler and runtime implementation, and in future releases nature will be compiled into the readable golang language, further increasing the usability of the nature programming language.
54+
Based on the existing features of the nature programming language, it is suitable for game engines and game development, scientific computing and AI, OS and IoT, and web development.
4355

44-
Official website: [https://nature-lang.org](https://nature-lang.org/)
4556

4657
## Installation
4758

src/module.c

+13-4
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,31 @@ module_t *module_build(ast_import_t *import, char *source_path, module_type_t ty
3030
m->imports = slice_new();
3131
m->import_table = table_new();
3232
m->global_symbols = slice_new();
33-
m->global_vardef = slice_new();// ast_vardef_stmt_t
33+
m->global_vardef = slice_new(); // ast_vardef_stmt_t
3434
m->call_init_stmt = NULL;
3535
m->source_path = source_path;
3636
m->infer_type_args_stack = stack_new();
3737
m->ast_fndefs = slice_new();
3838
m->closures = slice_new();
39-
m->asm_global_symbols = slice_new();// 文件全局符号以及 operations 编译过程中产生的局部符号
39+
m->asm_global_symbols = slice_new(); // 文件全局符号以及 operations 编译过程中产生的局部符号
4040
m->asm_operations = slice_new();
4141
m->asm_temp_var_decl_count = 0;
4242
if (m->package_dir) {
43+
// source rel_path 需要保留目录名称,取上一级目录作为 base ns, 需要处理特殊情况 /root/main.n 这种情况的编译
44+
// package dir maybe eqs /root
4345
char *temp_dir = path_dir(m->package_dir);
44-
m->rel_path = str_replace(m->source_path, temp_dir, "");
46+
if (str_equal(temp_dir, "") || str_equal(temp_dir, "/")) {
47+
m->rel_path = m->source_path;
48+
} else {
49+
m->rel_path = str_replace(m->source_path, temp_dir, "");
50+
}
51+
assert(m->rel_path);
52+
4553
m->rel_path = ltrim(m->rel_path, "/");
4654
} else if (strstr(m->source_path, NATURE_ROOT) != NULL) {
4755
// builtin
4856
m->rel_path = str_replace(m->source_path, NATURE_ROOT, "");
57+
assert(m->rel_path);
4958
m->rel_path = ltrim(m->rel_path, "/");
5059
} else {
5160
m->rel_path = m->source_path;
@@ -123,7 +132,7 @@ module_t *module_build(ast_import_t *import, char *source_path, module_type_t ty
123132
ast_fndef_t *fndef = stmt->value;
124133

125134
if (fndef->impl_type.kind == 0) {
126-
fndef->symbol_name = ident_with_prefix(m->ident, fndef->symbol_name);// 全局函数改名
135+
fndef->symbol_name = ident_with_prefix(m->ident, fndef->symbol_name); // 全局函数改名
127136
symbol_t *s = symbol_table_set(fndef->symbol_name, SYMBOL_FN, fndef, false);
128137
ANALYZER_ASSERTF(s, "ident '%s' redeclared", fndef->symbol_name);
129138
} else {

0 commit comments

Comments
 (0)