@cella-lang/cfamily 0.1.202611052225 → 0.1.202611060800
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGES.md +57 -0
- package/cfamily.arithmetic.cell +0 -0
- package/cfamily.behavior.cell +0 -0
- package/cfamily.cell +0 -0
- package/cfamily.clibrary.cell +0 -0
- package/cfamily.conversion.cell +0 -0
- package/cfamily.debugging.cell +0 -0
- package/cfamily.evaluation.cell +0 -0
- package/cfamily.execution.cell +0 -0
- package/cfamily.expressions.cell +0 -0
- package/cfamily.files.cell +0 -0
- package/cfamily.generate.cell +0 -0
- package/cfamily.layout.cell +0 -0
- package/cfamily.lengths.cell +0 -0
- package/cfamily.librarycode.cell +0 -0
- package/cfamily.lifting.cell +0 -0
- package/cfamily.memory.cell +0 -0
- package/cfamily.orders.cell +0 -0
- package/cfamily.program.cell +0 -0
- package/cfamily.querying.cell +0 -0
- package/cfamily.representation.cell +0 -0
- package/cfamily.resolution.cell +0 -0
- package/cfamily.rules.cell +0 -0
- package/cfamily.running.cell +0 -0
- package/cfamily.scopes.cell +0 -0
- package/cfamily.sequencing.cell +0 -0
- package/cfamily.sessions.cell +0 -0
- package/cfamily.standardlibrary.cell +0 -0
- package/cfamily.state.cell +0 -0
- package/cfamily.statements.cell +0 -0
- package/cfamily.statics.cell +0 -0
- package/cfamily.summaries.cell +0 -0
- package/cfamily.syntax.cell +0 -0
- package/cfamily.syntaxcollect.cell +0 -0
- package/cfamily.syntaxnodes.cell +0 -0
- package/cfamily.syntaxtypes.cell +0 -0
- package/cfamily.syntaxwalk.cell +0 -0
- package/cfamily.tables.cell +0 -0
- package/cfamily.typed.cell +0 -0
- package/cfamily.typetext.cell +0 -0
- package/cfamily.variables.cell +0 -0
- package/index.json +2841 -2550
- package/package.json +5 -4
- package/verdict-kinds.json +3 -0
package/CHANGES.md
CHANGED
|
@@ -2,6 +2,63 @@
|
|
|
2
2
|
|
|
3
3
|
## 未發佈
|
|
4
4
|
|
|
5
|
+
- **不完整型別:解參照只是左值,讀值才要完整**(C 與 C++ 共用的核心;kind 都是 `reject`,params 是 `{}`,只有 reason 變)。
|
|
6
|
+
指向只宣告的 struct/class(C++ 的 `iClassDecl`、C 沒有定義的 `struct S`)的 `*p` 不再在解參照時拒絕,而是得到左值,要用到值的地方才拒絕:
|
|
7
|
+
- 指派(`*p = *q`):reason `incomplete type where a complete type is required`,at 是指派的節點(之前 `dereferencing a pointer to
|
|
8
|
+
an incomplete type`,at 是 `*`)。
|
|
9
|
+
- 取成員(`p->v`、`(*p).v`):reason `member access into incomplete type`,at 是 `->` 或 `.` 的節點(之前同上)。
|
|
10
|
+
- sizeof(`sizeof *p`):reason 改成 `sizeof an incomplete type`,at 是 sizeof 的節點;以值宣告(`variable has an incomplete type`)、
|
|
11
|
+
下標(`subscript of a pointer to an incomplete type`)照舊。C++ 的輸出、運算子本來就找不到可用的(`cannot print this type with
|
|
12
|
+
std::cout`、`operandTypes`)。
|
|
13
|
+
- 丟棄的 `*p`(運算式敘述、`(void)*p`、逗號的左邊)依新的規則 `Rules.discardedLvalueIsRead`:C 是 true(C11 6.3.2.1p2,讀值是
|
|
14
|
+
未定義行為:reject,reason `incomplete type where a complete type is required`,at 是 `*`),C++ 是 false(C++17 [expr]p12,只求值
|
|
15
|
+
指標:accept)。
|
|
16
|
+
- 只要左值的寫法(`&*p`、C++ 的 `Helper &r = *p`、回傳 `Helper &` 的 `return *p`):之前 reject,現在 accept。
|
|
17
|
+
- void 與長度不明的陣列的解參照照舊拒絕(`dereferencing a pointer to an incomplete type`)。
|
|
18
|
+
- **函式定義的參數與回傳型別要完整**(C11 6.9.1p3、p7;C++17 [dcl.fct.def.general]p2):寫成 struct/union/class、程式只宣告沒定義的,
|
|
19
|
+
判 reject,at 是函式定義的節點,reason 是參數 `variable has incomplete type`、回傳型別 `incomplete result type in function definition`。
|
|
20
|
+
之前都判 accept(C 的參數由 `@cella-lang/c` 先擋,訊息不變)。參考(`Helper &`)、指標不受影響。
|
|
21
|
+
|
|
22
|
+
### ⚠️ 不相容(不完整型別)
|
|
23
|
+
|
|
24
|
+
- `Rules` 多一欄 `discardedLvalueIsRead`(C 是 true、C++ 是 false)。`Ty.knownOnlyByName`、`CheckDialect.discardedIndirection`、
|
|
25
|
+
`ProgramDialect.undefinedTag`、`ProgramDialect.undefinedParameter`、`ProgramDialect.incompleteInDefinition` 是新的。
|
|
26
|
+
|
|
27
|
+
- **新的問題種類 `ubFlowOffEnd`**(C++ 才有):回傳值的函式(main 除外)執行到結尾、沒有 return,是未定義行為(C++17
|
|
28
|
+
[stmt.return]p2,C++20 是 [stmt.return]/4),不看呼叫端有沒有用那個值。判決 reject,`category` 是 `error`,`clause` 是
|
|
29
|
+
`C++17 [stmt.return]p2`,reason 是 `flowing off the end of a function that returns a value`,`at` 是那個函式定義的節點(成員函式是
|
|
30
|
+
它的定義;lambda 的 operator() 是展開出來的,報在呼叫 lambda 的地方),還沒結構化(`params` 是 `{}`、`structured` 是 false)。之前:只呼叫不用值判 accept;用到值判
|
|
31
|
+
`ubUninit`(`C++17 [dcl.init]p12`,at 是呼叫)。`verdict-kinds.json` 已加上。
|
|
32
|
+
C 照舊:C11 6.9.1p12 只有用到值才是未定義行為,不用值是 accept、用到值是 `ubUninit`(`C11 6.3.2.1p2`)。
|
|
33
|
+
|
|
34
|
+
### ⚠️ 不相容(執行到結尾)
|
|
35
|
+
|
|
36
|
+
- `Rules` 多一欄 `flowingOffEndUndefined`(C++ 是 true、C 是 false);`Behavior` 多一個建構子 `flowedOffEnd`(依建構子分派的地方要多一支)。
|
|
37
|
+
`Ty.returnsValue`、`TypedStmt.endingWith` 是新的:`ProgramDialect.function` 在規則這樣說、函式回傳值且不是入口時,把停在函式節點的
|
|
38
|
+
`failWith` 接在本體最後一個敘述之後(本體區塊裡;return 在那之前就離開)。
|
|
39
|
+
- **陣列的長度可以送運算式,由 Cella 判斷**:`TypeSyntax` 新的建構子 `tArrE (t : TypeSyntax) (len : Expr)`,JSON 是
|
|
40
|
+
`{"k": "tArrE", "t": {"k": "tInt"}, "len": {"k": "eBin", "n": "node_7", "op": {"k": "opMul"}, "a": {"k": "eName", "n": "node_5", "name": "N"}, "b": {"k": "eNum", "n": "node_6", "v": 2}}}`。
|
|
41
|
+
可以出現在任何寫型別的地方(宣告、多維陣列的內層 `tArrE (tArrE tInt m) n`、欄位、參數、typedef、cast、sizeof);長度裡的名字可以是
|
|
42
|
+
`eName`(宣告的型別裡的名字看得到外層、看不到這個宣告自己;參數的型別看得到前面的參數)。`Program.checkWith` 在名字解析之後、方言的
|
|
43
|
+
前處理之前(新模組 `cfamily.lengths`,`ArrayLengths.lowered`)照方言的常數運算式規則判斷每個長度:
|
|
44
|
+
- 正的常數:和 `tArr t k` 相同(列舉常數、`sizeof(基本型別)`、cast 成整數型別、算術與位元運算、`?:`;C++ 另有 const 整數變數、逗號);
|
|
45
|
+
- 0 或負的常數:reject(`zero size array`、`array has a negative size`,指在長度的節點);
|
|
46
|
+
- 判斷不了:unknown(`sizeof 運算式`、`sizeof(struct)`、C++ 的函式呼叫(可能是 constexpr)、標頭與板子的常數、值是未定義的運算);
|
|
47
|
+
- 不是常數:區塊裡沒有初始化子的最外層是 VLA(和 `sDeclV` 相同:C 照標準,C++ 帶假設 `gcc:vla`);有初始化子 C reject
|
|
48
|
+
(`variable-sized object may not be initialized`)、C++ unknown;檔案範圍或 static reject(`variable length array declaration cannot have
|
|
49
|
+
static storage duration`);struct 的成員 reject(`fields must have a constant size`);C 的參數調整成指標;其他位置 unknown。
|
|
50
|
+
C 的 const 變數不是常數運算式(C11 6.6p6):`const int N = 10; int a[N];` 在檔案範圍 reject(clang 只警告,GNU 的擴充),在區塊裡是 VLA。
|
|
51
|
+
舊的 `tArr`、`tArrU`、`sDeclV` 照收。新的 API:`ConstantValue`、`ConstantScope`、`ConstantSource`、`ArrayLengths.lowered`、
|
|
52
|
+
`ArrayLengths.constants`、`TypeSyntax.hasVariableLength`、`Item.variableLengthMisplaced`、`Scopes.type`、`Scopes.fields`、
|
|
53
|
+
`Scopes.structDefinition`、`Stmt.variableLength`、`StatementDialect.declarationOf`、`Item.allNames`、`TypeSyntax.lengthPrinted`。
|
|
54
|
+
|
|
55
|
+
### ⚠️ 不相容(陣列的長度)
|
|
56
|
+
|
|
57
|
+
- `TypeSyntax` 多一個建構子 `tArrE`,並移進 `Expr`、`Designator`、`Init` 的 `mutual` 區塊(窮舉 `TypeSyntax` 的 match 要多一個分支)。
|
|
58
|
+
- `Rules` 多兩欄:`commaInConstantExpressions`(C++ true:常數運算式可以有逗號;C false,6.6p3)、`constexprCalls`(C++ true:呼叫可能是
|
|
59
|
+
constexpr 函式的常數運算式;C false)。
|
|
60
|
+
- `Scopes.parametersIn` 也解析參數型別裡的名字(之前只解析預設引數)。
|
|
61
|
+
|
|
5
62
|
- **名字可以只送寫出來的樣子,由 Cella 解析**:新的運算式 `eName (n : NodeId) (name : String)`,JSON 是
|
|
6
63
|
`{"k": "eName", "n": "node_12", "name": "count"}`。前端不必再自己做作用域走訪填 `eVar` 的宣告標籤 `x`;`Program.checkWith` 在檢查
|
|
7
64
|
重複宣告之後、方言的前處理之前,依作用域把每個 `eName` 換成:
|
package/cfamily.arithmetic.cell
CHANGED
|
Binary file
|
package/cfamily.behavior.cell
CHANGED
|
Binary file
|
package/cfamily.cell
CHANGED
|
Binary file
|
package/cfamily.clibrary.cell
CHANGED
|
Binary file
|
package/cfamily.conversion.cell
CHANGED
|
Binary file
|
package/cfamily.debugging.cell
CHANGED
|
Binary file
|
package/cfamily.evaluation.cell
CHANGED
|
Binary file
|
package/cfamily.execution.cell
CHANGED
|
Binary file
|
package/cfamily.expressions.cell
CHANGED
|
Binary file
|
package/cfamily.files.cell
CHANGED
|
Binary file
|
package/cfamily.generate.cell
CHANGED
|
Binary file
|
package/cfamily.layout.cell
CHANGED
|
Binary file
|
|
Binary file
|
package/cfamily.librarycode.cell
CHANGED
|
Binary file
|
package/cfamily.lifting.cell
CHANGED
|
Binary file
|
package/cfamily.memory.cell
CHANGED
|
Binary file
|
package/cfamily.orders.cell
CHANGED
|
Binary file
|
package/cfamily.program.cell
CHANGED
|
Binary file
|
package/cfamily.querying.cell
CHANGED
|
Binary file
|
|
Binary file
|
package/cfamily.resolution.cell
CHANGED
|
Binary file
|
package/cfamily.rules.cell
CHANGED
|
Binary file
|
package/cfamily.running.cell
CHANGED
|
Binary file
|
package/cfamily.scopes.cell
CHANGED
|
Binary file
|
package/cfamily.sequencing.cell
CHANGED
|
Binary file
|
package/cfamily.sessions.cell
CHANGED
|
Binary file
|
|
Binary file
|
package/cfamily.state.cell
CHANGED
|
Binary file
|
package/cfamily.statements.cell
CHANGED
|
Binary file
|
package/cfamily.statics.cell
CHANGED
|
Binary file
|
package/cfamily.summaries.cell
CHANGED
|
Binary file
|
package/cfamily.syntax.cell
CHANGED
|
Binary file
|
|
Binary file
|
package/cfamily.syntaxnodes.cell
CHANGED
|
Binary file
|
package/cfamily.syntaxtypes.cell
CHANGED
|
Binary file
|
package/cfamily.syntaxwalk.cell
CHANGED
|
Binary file
|
package/cfamily.tables.cell
CHANGED
|
Binary file
|
package/cfamily.typed.cell
CHANGED
|
Binary file
|
package/cfamily.typetext.cell
CHANGED
|
Binary file
|
package/cfamily.variables.cell
CHANGED
|
Binary file
|