Skip to content

Commit 1cd4b9c

Browse files
committed
fix(*): fix a bug in type-calculator
1. sort the documents 2. update stamon-standard-library 3. fix a fatal bug in type-calculator please refer to the work log for details BREAKING CHANGE: the old version of the stamon-standard-library is incompatible
1 parent 1283b17 commit 1cd4b9c

File tree

9 files changed

+30
-35
lines changed

9 files changed

+30
-35
lines changed

demos/demo.stvc

259 Bytes
Binary file not shown.

demos/demo1.stvc

259 Bytes
Binary file not shown.

demos/demo2.stvc

259 Bytes
Binary file not shown.

doc/工作日志/20250328.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# 2025/03/28 工作日志
2+
3+
本次更新的内部版本为``2.4.42``
4+
本次更新并不会发行``2.4.42``
5+
6+
### 整合了文档
7+
8+
我修正了一些文档的用词,让文档变得更加规范。
9+
10+
### 微调了Stamon语言库
11+
12+
经过再三思考,我认为System.version和System.typeof的命名是不够恰当的,因此我把这两个函数封装到了``Stamon``对象当中。
13+
14+
### 修复了一个致命漏洞
15+
16+
``TypeCalculator.cpp``中,有一个表达式由于未妥善使用括号,导致优先级不符合预期,现已修复。
17+
除此之外我也删去了一些调试时遗留的注释代码。

src/bin-include/stddef.st

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def println;
1717
def input;
1818

1919
//平台库定义
20+
def Stamon;
2021
def System;
2122

2223
//字符串库定义

src/bin-include/system.st

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,21 @@
33
import stddef;
44
import math;
55

6-
System = class {
6+
Stamon = class {
7+
8+
func typeof(self, v) {
9+
//给定对象,返回其类型
10+
return native("typeof", v);
11+
}
712

813
func version(self) {
14+
//返回版本号
915
return native("version", null);
1016
}
17+
18+
}.new;
1119

12-
func typeof(self, v) {
13-
//返回类型
14-
return native("typeof", v);
15-
}
20+
System = class {
1621

1722
func throw(self, s) {
1823
//抛出异常,同时让虚拟机退出

src/config/StamonConfig.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace stamon {
1313
constexpr int STAMON_VER_X = 2;
1414
constexpr int STAMON_VER_Y = 4;
15-
constexpr int STAMON_VER_Z = 40;
15+
constexpr int STAMON_VER_Z = 42;
1616
} // namespace stamon
1717

1818
namespace stamon::config {

src/sfn/SFN.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ void sfn_int(SFN_PARA_LIST);
3232
void sfn_str(SFN_PARA_LIST);
3333
void sfn_len(SFN_PARA_LIST);
3434

35-
void sfn_input(SFN_PARA_LIST);
36-
3735
void sfn_typeof(SFN_PARA_LIST);
3836
void sfn_throw(SFN_PARA_LIST);
3937
void sfn_system(SFN_PARA_LIST);

src/vm/TypeCalculator.cpp

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -97,32 +97,6 @@ namespace stamon::vm {
9797
BIND_BIN(ast::BinaryDiviType , BinaryDivi);
9898
BIND_BIN(ast::BinaryModType , BinaryMod);
9999

100-
// //初始化单目运算函数
101-
// UnCalcFunc[ast::UnaryPositiveType] = &TypeCalculator::UnaryPositive;
102-
// UnCalcFunc[ast::UnaryNegativeType] = UnaryNegative;
103-
// UnCalcFunc[ast::UnaryNotType] = UnaryNot;
104-
// UnCalcFunc[ast::UnaryInverseType] = UnaryInverse;
105-
106-
// //初始化双目运算函数
107-
// BinCalcFunc[ast::BinaryLogicORType] = BinaryLogicOR;
108-
// BinCalcFunc[ast::BinaryLogicANDType] = BinaryLogicAND;
109-
// BinCalcFunc[ast::BinaryBitORType] = BinaryBitOR;
110-
// BinCalcFunc[ast::BinaryBitXORType] = BinaryBitXOR;
111-
// BinCalcFunc[ast::BinaryBitANDType] = BinaryBitAND;
112-
// BinCalcFunc[ast::BinaryEqualityType] = BinaryEquality;
113-
// BinCalcFunc[ast::BinaryInequalityType] = BinaryInequality;
114-
// BinCalcFunc[ast::BinaryBigThanType] = BinaryBigThan;
115-
// BinCalcFunc[ast::BinaryLessThanType] = BinaryLessThan;
116-
// BinCalcFunc[ast::BinaryBigThanOrEqualType] = BinaryBigThanOrEqual;
117-
// BinCalcFunc[ast::BinaryLessThanOrEqualType] = BinaryLessThanOrEqual;
118-
// BinCalcFunc[ast::BinaryLeftShiftType] = BinaryLeftShift;
119-
// BinCalcFunc[ast::BinaryRightShiftType] = BinaryRightShift;
120-
// BinCalcFunc[ast::BinaryAddType] = BinaryAdd;
121-
// BinCalcFunc[ast::BinarySubType] = BinarySub;
122-
// BinCalcFunc[ast::BinaryMultType] = BinaryMult;
123-
// BinCalcFunc[ast::BinaryDiviType] = BinaryDivi;
124-
// BinCalcFunc[ast::BinaryModType] = BinaryMod;
125-
126100
}
127101

128102
inline int AssignOperatorToBinaryOperator(int op) {
@@ -246,7 +220,7 @@ namespace stamon::vm {
246220
| (1<<datatype::NullTypeID)
247221
| (1<<datatype::ClassTypeID)
248222
| (1<<datatype::MethodTypeID);
249-
return (1<<a->getType()) & range != 0;
223+
return ((1<<a->getType()) & range) != 0;
250224
}
251225

252226
case ast::BinaryBigThanType:

0 commit comments

Comments
 (0)