🎨 format

This commit is contained in:
ValKmjolnir
2025-06-02 13:27:04 +08:00
parent 240095ab37
commit 2cc5bb8625
97 changed files with 539 additions and 538 deletions

View File

@@ -329,7 +329,7 @@ source code:
if (x<2) return x;
return fib(x-1)+fib(x-2);
}
for(var i=0;i<31;i+=1)
for (var i=0;i<31;i+=1)
print(fib(i),'\n');
@@ -362,7 +362,7 @@ source code:
--> if (x<2) return x;
return fib(x-1)+fib(x-2);
}
for(var i=0;i<31;i+=1)
for (var i=0;i<31;i+=1)
print(fib(i),'\n');

View File

@@ -124,7 +124,7 @@ Hope you could help me! :)
There's an example of byte code below:
```javascript
for(var i=0;i<4000000;i+=1);
for (var i=0;i<4000000;i+=1);
```
```x86asm
@@ -175,7 +175,7 @@ In this update i changed global and local scope from `unordered_map` to `vector`
So the bytecode generator changed a lot.
```javascript
for(var i=0;i<4000000;i+=1);
for (var i=0;i<4000000;i+=1);
```
```x86asm

View File

@@ -112,7 +112,7 @@ __该项目于2019/7/25正式开始__。
下面是生成的字节码的样例:
```javascript
for(var i=0;i<4000000;i+=1);
for (var i=0;i<4000000;i+=1);
```
```x86asm
@@ -161,7 +161,7 @@ for(var i=0;i<4000000;i+=1);
在这次的更新中,我把全局变量和局部变量的存储结构从`unordered_map`变为了`vector`,从而提升执行效率。所以现在生成的字节码大变样了。
```javascript
for(var i=0;i<4000000;i+=1);
for (var i=0;i<4000000;i+=1);
```
```x86asm

View File

@@ -258,7 +258,7 @@ While loop and for loop is simalar to C/C++.
while(condition) {
continue;
}
for(var i = 0; i<10; i += 1) {
for (var i = 0; i<10; i += 1) {
break;
}
```
@@ -469,7 +469,7 @@ Then complete this function using C++:
var builtin_print(context* ctx, gc* ngc) {
// find value with index begin from 1
// because local[0] is reserved for value 'me'
for(auto& i : ctx->localr[1].vec().elems) {
for (auto& i : ctx->localr[1].vec().elems) {
std::cout << i;
}
std::cout << std::flush;
@@ -495,11 +495,11 @@ var builtin_keys(context* ctx, gc* ngc) {
auto res = ngc->temp = ngc->alloc(vm_vec);
auto& vec = res.vec().elems;
if (hash.type==vm_hash) {
for(const auto& iter : hash.hash().elems) {
for (const auto& iter : hash.hash().elems) {
vec.push_back(ngc->newstr(iter.first));
}
} else {
for(const auto& iter : hash.map().mapper) {
for (const auto& iter : hash.map().mapper) {
vec.push_back(ngc->newstr(iter.first));
}
}
@@ -645,7 +645,7 @@ Then we write a test nasal file to run this fib function:
use std.dylib;
var dlhandle = dylib.dlopen("libfib");
var fib = dlhandle.fib;
for(var i = 1; i<30; i += 1)
for (var i = 1; i<30; i += 1)
println(dylib.dlcall(fib, i));
dylib.dlclose(dlhandle.lib);
```
@@ -663,7 +663,7 @@ use std.dylib;
var dlhandle = dylib.dlopen("libfib");
var fib = dlhandle.fib;
var invoke = dylib.limitcall(1); # this means the called function has only one parameter
for(var i = 1; i<30; i += 1)
for (var i = 1; i<30; i += 1)
println(invoke(fib, i));
dylib.dlclose(dlhandle.lib);
```

View File

@@ -250,7 +250,7 @@ while循环和for循环大体上与C/C++是一致的。
while(condition) {
continue;
}
for(var i = 0; i<10; i += 1) {
for (var i = 0; i<10; i += 1) {
break;
}
```
@@ -457,7 +457,7 @@ var builtin_print(context*, gc*);
var builtin_print(context* ctx, gc* ngc) {
// 局部变量的下标其实是从 1 开始的
// 因为 local[0] 是保留给 'me' 的空间
for(auto& i : ctx->localr[1].vec().elems) {
for (auto& i : ctx->localr[1].vec().elems) {
std::cout << i;
}
std::cout << std::flush;
@@ -483,11 +483,11 @@ var builtin_keys(context* ctx, gc* ngc) {
auto res = ngc->temp = ngc->alloc(vm_vec);
auto& vec = res.vec().elems;
if (hash.type==vm_hash) {
for(const auto& iter : hash.hash().elems) {
for (const auto& iter : hash.hash().elems) {
vec.push_back(ngc->newstr(iter.first));
}
} else {
for(const auto& iter : hash.map().mapper) {
for (const auto& iter : hash.map().mapper) {
vec.push_back(ngc->newstr(iter.first));
}
}
@@ -624,7 +624,7 @@ Windows(`.dll`):
use std.dylib;
var dlhandle = dylib.dlopen("libfib");
var fib = dlhandle.fib;
for(var i = 1; i<30; i += 1)
for (var i = 1; i<30; i += 1)
println(dylib.dlcall(fib, i));
dylib.dlclose(dlhandle.lib);
```
@@ -642,7 +642,7 @@ use std.dylib;
var dlhandle = dylib.dlopen("libfib");
var fib = dlhandle.fib;
var invoke = dylib.limitcall(1); # this means the called function has only one parameter
for(var i = 1; i<30; i += 1)
for (var i = 1; i<30; i += 1)
println(invoke(fib, i));
dylib.dlclose(dlhandle.lib);
```