@cella-lang/cpp 0.1.202611090959 → 0.1.202611101335
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 +62 -0
- package/cpp.arrays.cell +0 -0
- package/cpp.cell +0 -0
- package/cpp.classes.cell +0 -0
- package/cpp.classrules.cell +0 -0
- package/cpp.construction.cell +0 -0
- package/cpp.constructs.cell +0 -0
- package/cpp.copies.cell +0 -0
- package/cpp.exceptions.cell +0 -0
- package/cpp.inheritance.cell +0 -0
- package/cpp.lambdas.cell +0 -0
- package/cpp.layouts.cell +0 -0
- package/cpp.library.algorithms.cell +0 -0
- package/cpp.library.bitsets.cell +0 -0
- package/cpp.library.cell +0 -0
- package/cpp.library.comparisons.cell +0 -0
- package/cpp.library.deques.cell +0 -0
- package/cpp.library.iterators.cell +0 -0
- package/cpp.library.limits.cell +0 -0
- package/cpp.library.lists.cell +0 -0
- package/cpp.library.maps.cell +0 -0
- package/cpp.library.numerics.cell +0 -0
- package/cpp.library.pairs.cell +0 -0
- package/cpp.library.queues.cell +0 -0
- package/cpp.library.sets.cell +0 -0
- package/cpp.library.stacks.cell +0 -0
- package/cpp.library.streamiterators.cell +0 -0
- package/cpp.library.strings.cell +0 -0
- package/cpp.library.trees.cell +0 -0
- package/cpp.library.tuples.cell +0 -0
- package/cpp.library.unorderedmaps.cell +0 -0
- package/cpp.library.vectors.cell +0 -0
- package/cpp.memberpointers.cell +0 -0
- package/cpp.names.cell +0 -0
- package/cpp.objects.cell +0 -0
- package/cpp.operators.cell +0 -0
- package/cpp.overloading.cell +0 -0
- package/cpp.polymorphism.cell +0 -0
- package/cpp.primitives.cell +0 -0
- package/cpp.ranges.cell +0 -0
- package/cpp.references.cell +0 -0
- package/cpp.runtimetypes.cell +0 -0
- package/cpp.standardexceptions.cell +0 -0
- package/cpp.standardfunctions.cell +0 -0
- package/cpp.standardnames.cell +0 -0
- package/cpp.staticmembers.cell +0 -0
- package/cpp.streams.cell +0 -0
- package/cpp.templates.cell +0 -0
- package/cpp.userconversions.cell +0 -0
- package/index.json +1106 -922
- package/package.json +6 -6
package/CHANGES.md
CHANGED
|
@@ -5,6 +5,68 @@
|
|
|
5
5
|
|
|
6
6
|
## 未發佈
|
|
7
7
|
|
|
8
|
+
- **語意樹可以說成員定義在類別外的哪裡**(**和 semorphe 談定的新形狀**;只做加法,舊的樹照舊可讀):頂層項目
|
|
9
|
+
`{"k": "iMemberAt", "n": "n7", "cls": "A", "x": "a@A"}`,放在類外定義所在的位置(`n` 是類外定義的節點,`cls` 是類別名,`x` 是類內宣告的標籤);
|
|
10
|
+
`mbStatic` 的 `x` 本來就有,`mbMethod`、`mbCtor`、`mbDtor`、`mbStaticMethod` 多一個選用的 `x`(省略等於 null)。
|
|
11
|
+
有標記時:靜態資料成員照**定義**的順序初始化([basic.start.dynamic],`struct A { static int b; static int a; }; int A::a = next();
|
|
12
|
+
int A::b = next();` 印 `12`,之前 `21`),類外的本體與初始值看得到定義之前的全域名字([basic.lookup.unqual],之前判「use of undeclared
|
|
13
|
+
identifier」),之後才宣告的照舊看不到。格式錯的標記(沒有類別宣告這個標籤、標記在類別之前、`cls` 不是那個類別、同一個標籤兩次)判 unknown。
|
|
14
|
+
類別模板的成員的標記沒有作用,行為和沒標記相同。沒有標記的樹照舊把定義放在類別的位置。
|
|
15
|
+
- **暫時的 unknown(只有沒標記的樹)**:沒有任何 `iMemberAt` 的程式,同一個類別有兩個以上帶可觀察副作用(輸入輸出,或寫全域;類別型別的靜態成員看它的建構子)的靜態初始值時判 unknown
|
|
16
|
+
「the order of this class's static initializers depends on where they are defined outside the class, which this program's tree does not
|
|
17
|
+
say」:那個順序取決於樹沒說的事。常數初始值(`int A::alive = 0;`)、只有一個帶副作用的初始值都照舊。送標記的工具不受影響,
|
|
18
|
+
所有工具都送標記後這條會拿掉。抓不到(沒標記時照舊可能和 clang 不同):跨類別的順序、靜態與全域變數交錯、後面的初始值只讀前面的(`b = a + 1`)。
|
|
19
|
+
誤傷:`inline static` 的兩個帶副作用的初始值也是 unknown(定義就在類別裡,順序其實知道,但沒標記時分不出來)。
|
|
20
|
+
- 新的 API:`MemberAt.labels`、`MemberAt.prepared`、`MemberAt.settled`、`MemberAt.split`、`MemberAt.itemsOf`、`Member.label`、`Item.madeFrom`、
|
|
21
|
+
`Lambdas.beforeMarks`、`Lambdas.placed`、`Cpp.constructsObservably`、`Cpp.orderedStatics`、`Cpp.definitionOrderUnsaid`。
|
|
22
|
+
|
|
23
|
+
- **之前判 reject、現在判 accept**:靜態成員函式宣告在同類別的靜態資料成員之前時,函式本體讀寫那個資料成員(`class A { public: static
|
|
24
|
+
int f(); static int a; }; int A::a = 7; int A::f() { return a; }`;類內定義、寫 `A::a` 全名、賦值、取址、陣列、繼承來的、命名空間與巢狀
|
|
25
|
+
類別裡的、類別樣板的都是);之前判「use of undeclared identifier」。成員函式的本體是完整類別的語境([class.mem]p6),靜態資料成員現在
|
|
26
|
+
排在同類別的靜態函式之前。語意樹的形狀不變。
|
|
27
|
+
- **`std::string` 的建構子補齊**:`string(n, c)`、`string(s, n)`、`string(str, pos)`、`string(str, pos, n)`([string.cons]),之前都判 reject
|
|
28
|
+
「no matching constructor」(例如 `string s(3, 'a');`)。`pos` 超過 `size()` 丟 `out_of_range`(`what()` 照 libc++ 是 `basic_string`),`n` 超過
|
|
29
|
+
`max_size()` 丟 `length_error`。`string(65, 65)`(兩個 `int`)選 `(size_type, char)`,不是迭代器範圍的樣板。新增成員 `max_size()`(值照 libc++)。
|
|
30
|
+
`operator<<` 印出全部 `size()` 個字元,字串裡的 null 也算([string.io]p1;之前停在第一個 null,輸出和 clang 不同)。
|
|
31
|
+
- **之前判 reject、現在判 unknown**:標準庫類別(`std::` 開頭,或函式庫定義的)的建構子多載解析失敗或模糊時,判 unknown,說明「the model's '…' has no
|
|
32
|
+
constructor for these arguments」:模型的多載不齊,標準可能有(`map<int,int> m(v.begin(), v.end());` 是合法的)。和成員函式的處理相同。使用者自己的
|
|
33
|
+
class 照舊 reject。**真的錯的程式也跟著變成 unknown**(模型分不出來):`string s(1, 2, 3, 4, 5);`、`string s(5);`、`string s = 5;`、`string s(0, 65);`
|
|
34
|
+
(clang:`0` 當空指標時模糊)、`vector<string> v(3, 5);`、`deque<int> d("x");`、`map<int, int> m(1);`。
|
|
35
|
+
- **指標比較與 `?:` 走複合指標型別(之前判 reject,現在判 accept)**:`==`、`!=`、`<`、`<=`、`>`、`>=` 的兩個運算元是指向類別與它的基底的指標(兩個方向、
|
|
36
|
+
多層、const 差異)時,衍生的先轉成基底([expr.type]p4、[expr.eq]、[expr.rel];多重繼承比較的是基底子物件的位址),一支 `T t; S *p = &t; p == &t`
|
|
37
|
+
之前判 reject「invalid operands to a binary operator」。指標對 `void*` 的比較、兩個 `void*` 的先後(之前判 reject「arithmetic on a void pointer」)也
|
|
38
|
+
照 C++ 的規則接受。`c ? a : b` 用同一套規則(衍生對基底、`void*`、const 差異,之前判 reject「pointer type mismatch」或「discards the const
|
|
39
|
+
qualifier」)。
|
|
40
|
+
- **之前判 reject 的字換成 clang 的**:基底不能用時,比較與 `?:` 判 reject「cannot cast 'P' to its private base class 'A'」或「ambiguous conversion
|
|
41
|
+
from derived class 'D' to base class 'A'」(之前是「invalid operands to a binary operator」或「pointer type mismatch」)。無關類別的指標仍判 reject,字照舊。
|
|
42
|
+
- **之前判 accept、現在判 unknown**:`void*` 比較到同一物件和它的子物件(`C c; void *v = &c; A *a = &c; v == (void*)a`):位址相不相同是類別版面的事,
|
|
43
|
+
模型沒有,回 unknown(選擇 `itanium:layout.baseAddress`),之前 accept 並印 0,clang 印 1。
|
|
44
|
+
- 新的 API:`Inheritance.comparison`、`Inheritance.compositeOfConditional`、`Inheritance.compareAddresses`、`Inheritance.derivedSide`、`Inheritance.joinsVoid`、
|
|
45
|
+
`Inheritance.toObject`、`Inheritance.place`、`Inheritance.layoutDecides`;`CppExpr` 多一個建構子 `comparedAddresses`(**不相容**:窮舉它的工具要補)。
|
|
46
|
+
- **函式式轉型不再被丟掉(之前判 accept 但輸出是錯的)**:轉換工具(`tools/cfamily/cpp_to_tree.py`)把 `T(x)` 當透明節點,目標是純量時型別轉換
|
|
47
|
+
整個消失:`char c = 97; std::cout << int(c);` 印 `a`(clang 印 `97`),`double(1) / 2` 算成整數除法、多載也照轉型前的型別選。現在目標是純量
|
|
48
|
+
(內建型別、指標、列舉,含 `typedef`/`using` 別名與 `uint8_t`、`size_t`)時轉成和 C 式轉型相同的 `eCast`;參考型別的別名是左值轉型。類別的
|
|
49
|
+
`T(x)` 照舊由建構子或轉換函式表示。用這個工具轉 C++ 原文的消費者,樹會多出 `eCast`,判決或輸出可能改變。
|
|
50
|
+
- **之前轉換工具報「不認得」、現在轉得過**:`int()`、`double()` 等純量的值初始化(零,別名是指標時是空指標)與 `int{c}`、`char{98}`、`int{}`
|
|
51
|
+
(純量的大括號)。
|
|
52
|
+
|
|
53
|
+
- **判決變快,判決與輸出不變**:標準串流當二元運算元的檢查(`Operators.streamMismatch`)只有運算元真的是串流時才解析運算子。之前
|
|
54
|
+
每個二元運算式都先解析一次程式宣告的運算子函式,物件的運算子串接(`log << a << b`、`a + b + c`)每一層多檢查一份運算元,時間隨層數
|
|
55
|
+
指數成長(一支十幾個運算子、串接 `<<` 的程式從約 7 秒變成約 60 秒)。
|
|
56
|
+
- **大括號指定**:`x = {a, b}` 走 `operator=(initializer_list)`([over.ass]、[over.ics.rank]p3.1),`x = {}` 也是(容量留著)。
|
|
57
|
+
標準庫的 `vector`、`deque`、`set`、`multiset`、`map`、`unordered_map`、`string` 多了 `operator=(initializer_list)`;`map`、`unordered_map`、
|
|
58
|
+
`string` 多了 initializer_list 建構子;`initializer_list` 的標頭只要程式寫到大括號串列(指定、引數、回傳值,不只宣告)就載入。之前
|
|
59
|
+
`v = {1, 2}` 被當成 `vector(1, 2)`(一個元素,讀 `v[1]` 判 reject;`{3, 5}` 判 accept 但是三個 5),六個元素判 reject「no matching
|
|
60
|
+
constructor」。只有 initializer_list 建構子的類別改成移動指派(之前是複製指派);建構子是 explicit 時判 reject「no viable overloaded '='」。
|
|
61
|
+
- **之前判 reject、現在判 unknown 或 accept**:`f({1, 2})`(傳值參數)從「the expression is nested too deeply」改成 unknown;元素轉不過去時
|
|
62
|
+
initializer_list 建構子不可行、改走其他建構子([over.match.list]p1,`Construction.listAt`)。
|
|
63
|
+
- **`std::string::npos`**:程式有 string 類別時也是標頭的常數(之前判 reject「no member named 'npos' in 'std::string'」)。標準庫類別(`std::` 開頭)
|
|
64
|
+
模型沒有的成員判 unknown,不判 reject(`StaticMembers.unmodeled`)。`string::size_type`、`vector<T>::size_type` 等容器的 `size_type` 有了。
|
|
65
|
+
- **vector、deque 的 `explicit` 建構子真的是 explicit**(**不相容**:轉換工具之前沒讀到 `explicit`,`vector(n)` 被當成轉換建構子)。
|
|
66
|
+
- 新的 API:`Construction.listAt`、`Construction.listFits`、`Construction.itemFits`、`Construction.listTaken`、`Overloading.assignedList`、
|
|
67
|
+
`Overloading.listAssignment`、`Overloading.classAssignment`、`Overloading.choosesExplicit`、`Braced.target`、`Braced.textForCharacters`、
|
|
68
|
+
`Library.bracedExpression`、`Library.stringMember`、`StaticMembers.unmodeled`。
|
|
69
|
+
|
|
8
70
|
- **之前判 unknown、現在判 reject**:標準串流當二元運算子的運算元、而 std::ostream/std::istream 沒有那個運算子(學生把 `<<` 打成
|
|
9
71
|
`<`:`cout < "Hello!";`、`int x; cin < x;`;`cout + x`、`x == cin`、`cerr < 1`),判 reject operandTypes,字照 clang:
|
|
10
72
|
「invalid operands to binary expression ('ostream' (aka 'basic_ostream<char>') and 'const char[7]')」(另一邊的型別照寫的、陣列
|
package/cpp.arrays.cell
CHANGED
|
Binary file
|
package/cpp.cell
CHANGED
|
Binary file
|
package/cpp.classes.cell
CHANGED
|
Binary file
|
package/cpp.classrules.cell
CHANGED
|
Binary file
|
package/cpp.construction.cell
CHANGED
|
Binary file
|
package/cpp.constructs.cell
CHANGED
|
Binary file
|
package/cpp.copies.cell
CHANGED
|
Binary file
|
package/cpp.exceptions.cell
CHANGED
|
Binary file
|
package/cpp.inheritance.cell
CHANGED
|
Binary file
|
package/cpp.lambdas.cell
CHANGED
|
Binary file
|
package/cpp.layouts.cell
CHANGED
|
Binary file
|
|
Binary file
|
package/cpp.library.bitsets.cell
CHANGED
|
Binary file
|
package/cpp.library.cell
CHANGED
|
Binary file
|
|
Binary file
|
package/cpp.library.deques.cell
CHANGED
|
Binary file
|
|
Binary file
|
package/cpp.library.limits.cell
CHANGED
|
Binary file
|
package/cpp.library.lists.cell
CHANGED
|
Binary file
|
package/cpp.library.maps.cell
CHANGED
|
Binary file
|
|
Binary file
|
package/cpp.library.pairs.cell
CHANGED
|
Binary file
|
package/cpp.library.queues.cell
CHANGED
|
Binary file
|
package/cpp.library.sets.cell
CHANGED
|
Binary file
|
package/cpp.library.stacks.cell
CHANGED
|
Binary file
|
|
Binary file
|
package/cpp.library.strings.cell
CHANGED
|
Binary file
|
package/cpp.library.trees.cell
CHANGED
|
Binary file
|
package/cpp.library.tuples.cell
CHANGED
|
Binary file
|
|
Binary file
|
package/cpp.library.vectors.cell
CHANGED
|
Binary file
|
package/cpp.memberpointers.cell
CHANGED
|
Binary file
|
package/cpp.names.cell
CHANGED
|
Binary file
|
package/cpp.objects.cell
CHANGED
|
Binary file
|
package/cpp.operators.cell
CHANGED
|
Binary file
|
package/cpp.overloading.cell
CHANGED
|
Binary file
|
package/cpp.polymorphism.cell
CHANGED
|
Binary file
|
package/cpp.primitives.cell
CHANGED
|
Binary file
|
package/cpp.ranges.cell
CHANGED
|
Binary file
|
package/cpp.references.cell
CHANGED
|
Binary file
|
package/cpp.runtimetypes.cell
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/cpp.standardnames.cell
CHANGED
|
Binary file
|
package/cpp.staticmembers.cell
CHANGED
|
Binary file
|
package/cpp.streams.cell
CHANGED
|
Binary file
|
package/cpp.templates.cell
CHANGED
|
Binary file
|
package/cpp.userconversions.cell
CHANGED
|
Binary file
|