🐛 fix(tsl_syntax): repair lookup engine and reconcile reference facts
lookup.py: exempt code-anchored ASCII identifiers from the mixed zh/en gate so exact hits are no longer dropped; dedup parent/child sections in results; validate write-prelude anchors in --check. references: correct interpreter-verified facts (case-as-expression, control-flow semicolons, __line__/__stack_frame, tslObjects order, destroy timing, ErrDefine, truncated outputs), fix headings, scope qualifiers and reversed quotes; strip dead preamble metadata from all 24 pages. packaging: exclude __pycache__/*.pyc from playbook and bundle copies; update build test file-count assertion to match. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,5 @@
|
||||
# TSL 对象运行时与反射
|
||||
|
||||
文档类型:语法深水专题
|
||||
是否可直接用于生成代码:仅部分
|
||||
是否含可直接照写示例:是
|
||||
是否含不可照写反例:是
|
||||
|
||||
这一篇收拢对象模型里不适合继续堆在基础类主线里的运行时内容:类信息、函数句柄、对象状态、引用计数、运行时对象枚举、弱引用与自动弱引用。普通类声明、继承、构造和普通对象创建仍以 [08_objects_and_classes.md](08_objects_and_classes.md) 为主线;本页只在用户明确需要运行时反射、内省、对象生命周期或弱引用能力时进入。
|
||||
|
||||
## 本篇职责
|
||||
@@ -40,7 +35,7 @@
|
||||
- `functionInfo` 至少可以读出 `functionname`、`returntype`、`classname` 这几个字段。
|
||||
- `tslObjects(1)` 会按类名分组返回对象信息,并且分组项里的 `"obj"` 字段可以重新拿到可调用对象。
|
||||
- 对象赋值会延长对象存活;只有最后一个引用清空后才会触发 `destroy()`。
|
||||
- `self` 在本页只用于需要本实例对象引用的运行时函数,例如 `objectstate(self)`;普通成员访问仍按 [08_objects_and_classes.md](08_objects_and_classes.md) 的规则,不加 `self` 前缀。
|
||||
- `self` 表示本实例对象引用;本页在需要该引用的场景使用它,如传给运行时函数(`objectstate(self)`)或保存自身引用(`sca := self;`)。普通成员访问仍按 [08_objects_and_classes.md](08_objects_and_classes.md) 的规则,不加 `self` 前缀。
|
||||
- 弱引用能力的条件编译宏是 `weakptr`;自动弱引用相关宏是 `autoWeak`。
|
||||
- `weakRef(obj)` 可以创建弱引用;对象仍存活时,`weakref_get(w)` 可以拿回强引用。
|
||||
- `checkWeakRef(w)` 在对象仍存活时返回 `1`,对象已释放后返回 `-1`。
|
||||
@@ -355,15 +350,15 @@ end;
|
||||
代码块身份:可直接照写示例
|
||||
|
||||
```tsl
|
||||
objA := new TestClass01(100);
|
||||
objB := new TestClass01(101);
|
||||
|
||||
objsInfo := tslObjects(1);
|
||||
writeLn(length(objsInfo["TestClass01"]));
|
||||
newObjA := objsInfo["TestClass01"][0, "obj"];
|
||||
writeLn(newObjA is class(TestClass01));
|
||||
writeLn(newObjA.add(1, 2));
|
||||
|
||||
objA := new TestClass01(100);
|
||||
objB := new TestClass01(101);
|
||||
|
||||
type TestClass01 = class
|
||||
public
|
||||
value;
|
||||
@@ -575,6 +570,8 @@ end;
|
||||
|
||||
上面这种给段落切换关键字**加分号**(`weakRef;` / `autoRef;`)的写法会编译失败,错误信息包含 `invalid class definition`。关键在分号:段落切换关键字要像 `public` / `private` 那样**不带分号**独占一行,带分号后被当成独立语句才报错。正确的段落式写法见下一段。
|
||||
|
||||
### 段落式 `weakRef` / `autoRef` 的正确写法
|
||||
|
||||
段落式 `weakRef` / `autoRef`(不带分号)像 `public` / `private` 一样切换后续成员的弱引用属性:
|
||||
|
||||
代码块身份:可直接照写示例
|
||||
|
||||
Reference in New Issue
Block a user