@cella-lang/cpp 0.1.202611150249 → 0.1.202611152335
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 +97 -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.friends.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.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 +1279 -1203
- package/package.json +6 -6
package/CHANGES.md
CHANGED
|
@@ -5,6 +5,103 @@
|
|
|
5
5
|
|
|
6
6
|
## 未發佈
|
|
7
7
|
|
|
8
|
+
- **有引數的 constexpr 建構子:用常數建構的全域物件是常數初始化**([basic.start.static]p2、[expr.const]p2、[dcl.constexpr]p3):
|
|
9
|
+
之前 `struct P { int v; constexpr P(int a) : v(a) {} }; P p(3);` 的 `p` 在原來的位置建構,寫在前面的動態初始化讀它判 reject,clang
|
|
10
|
+
讀到 3。現在全域物件用 `P p(3)`、`P p = P(3)`、`P p{3}` 建構、引數只由字面常數與寫在前面可以用在常數運算式裡的 const 整數組成,
|
|
11
|
+
而且這個引數個數可能選到的建構子都是常數的(constexpr、本體是空的、參數是純量、每個成員用參數與字面常數的運算式初始化一次,
|
|
12
|
+
或用字面常數的預設成員初始值;類別沒有基底、虛擬函式,成員都是純量)時,在任何動態初始化之前建構;有解構子的照建構完成的順序解構。
|
|
13
|
+
其餘的照舊在原來的位置建構(建構子不是 constexpr、引數讀到不是常數的變數:寫在前面的動態初始化讀它照舊判 reject)。轉換工具從
|
|
14
|
+
clang 的 AST 填 `mbCtor` 的 `constexpr`。新欄位 `ClassMembers.constantArities`、`DeclaredConstructor.constexpr`(**不相容**:自己列
|
|
15
|
+
全部欄位的記錄要補);`Classes.constantObject` 多一個參數 `usable`(**不相容**,內部名字);新的內部名字:
|
|
16
|
+
`Classes.constantAritiesOf`、`Classes.constantConstructor`、`Classes.constantItem`、`Classes.fromParameters`。所有函式庫模組與案例模組重新產生
|
|
17
|
+
(`mbCtor` 多一個欄位,雜湊改變)。測試:`tests/cases/static_initialization/`(多 3 支,共 13 支;`constexpr_constructor_early.cpp`
|
|
18
|
+
印 `3 8 6 7 3 ~R8`,對過 clang++ -std=c++17)。
|
|
19
|
+
|
|
20
|
+
- **`std::deque` 的 `clear`、`std::remove`、`std::binary_search`**:之前模型的 `std::deque<int>` 沒有成員 `clear`,`<algorithm>`
|
|
21
|
+
沒有 `remove` 與 `binary_search`,用到的程式判 unknown(不支援)。現在 `d.clear()` 從前面依序解構每個元素、清空(保留區塊,同 libc++);
|
|
22
|
+
`std::deque` 也改成照 libc++ 分塊(元素放在固定大小的區塊,兩端放入時只加區塊、元素不再搬動):之前做成環狀緩衝,滿了把全部
|
|
23
|
+
元素移到兩倍大的緩衝,多出移動建構與解構(元素的解構子有輸出時多印,clang 不會),兩端放入之後之前拿到的元素參考也失效
|
|
24
|
+
([deque.modifiers]p1:兩端放入不讓參考失效)。
|
|
25
|
+
`remove(first, last, value)` 照 libc++:找到第一個相等的,之後不相等的依序移到前面,回傳新的結尾(erase-remove 的寫法
|
|
26
|
+
`v.erase(remove(v.begin(), v.end(), x), v.end())` 可以用);`binary_search(first, last, value[, comp])` 是 `lower_bound` 之後看找到的
|
|
27
|
+
是不是相等。沒給比較子的 `binary_search` 和 `lower_bound` 一樣先檢查範圍對 `e < value` 與 `!(value < e)` 分好([alg.binary.search]p1),
|
|
28
|
+
沒分好是前置條件違反,判 reject(libc++ 不檢查,編譯後的結果看運氣)。函式庫模組 `cpp.library.deques`、`cpp.library.algorithms`
|
|
29
|
+
重新產生(雜湊改變)。測試:`tests/cases/library_sequence_operations/`(7 支,在 VM 上跑;改前 6 支 unknown、`deque_reference_kept.cpp`
|
|
30
|
+
判 reject(參考失效),改後照 clang)。
|
|
31
|
+
|
|
32
|
+
- **例外離開 noexcept 的建構子會結束程式**([except.spec]p5、[except.terminate]p1):之前程式宣告的建構子降成函式時一律不是
|
|
33
|
+
noexcept,`T(int x) noexcept : v(x) { if (x < 0) throw 1; }` 丟出的例外被外面的 handler 接住,判 accept、印出 handler 的輸出(誤判;
|
|
34
|
+
clang 中止,結束碼 134)。現在宣告成 noexcept 的建構子與建構子樣板,例外離開它(本體或成員初始化)就和一般的 noexcept 函式一樣呼叫
|
|
35
|
+
`std::terminate`(問題種類 `uncaught`)。隱含的建構子不加:它只在呼叫的全都是 noexcept 時才是 noexcept,那些自己就會結束程式。
|
|
36
|
+
成員函式、靜態成員函式、使用者宣告的指定運算子與解構子(沒寫例外規格就是 noexcept)原本就照做,新測試一併固定。沒做:lambda 的
|
|
37
|
+
noexcept(語意樹的 `sLambda` 沒有這個欄位,`operator()` 一律不是 noexcept)。`Classes.constructor`、`Classes.constructorNamed`
|
|
38
|
+
多一個參數 `noexc: Bool`(**不相容**,內部名字)。測試:`tests/cases/noexcept_members/`(8 支,在 VM 上跑;建構子的 3 支改前 accept
|
|
39
|
+
並印 caught,改後照 clang)。
|
|
40
|
+
|
|
41
|
+
- **函式樣板的偏序只在可行的之間比**([over.match.viable]p3、[over.match.best]p2.5):推導不看沒有樣板參數的參數,`P` 與
|
|
42
|
+
`const char *` 的樣板對一個 string 也推導得出來;之前偏序在「推導得出來」的樣板之間挑最特化的,`const char *` 比 `const string &`
|
|
43
|
+
「更特化」,只留它當候選,結果沒有一個可行,判 reject "no matching function"(`u.replace(u.begin(), u.begin() + 1, string("zz"))`,
|
|
44
|
+
clang 選 `const string &` 那個)。現在推導得出來的樣板實例全部先做出來,只在引數轉得過去的實例之間比偏序;一般函式與樣板同名
|
|
45
|
+
(`Overloading.withTemplate`)與只有樣板(`Templates.chosen`)的兩條路都一樣。新的內部名字 `Viability`、`Cpp.viability`、
|
|
46
|
+
`Templates.viableInstance`、`Templates.amongViable`;`Templates.chosen`、`Templates.expression`、`Templates.statement` 多一個參數
|
|
47
|
+
(**不相容**)。測試:`tests/cases/template_instances/ordering_among_viable.cpp`、`ordering_among_viable_templates.cpp`(改前 reject、
|
|
48
|
+
改後 accept),輸出對過 clang++ -std=c++17。
|
|
49
|
+
|
|
50
|
+
- **程式的隱含特殊成員用到才檢查**([class.default.ctor]p4、[class.copy.ctor]p12、[class.copy.assign]p10:隱含的預設建構子、
|
|
51
|
+
複製/移動建構子、複製/移動指定只在 odr-used 時才定義):之前程式的類別隱含的這些成員一律先檢查,沒用到也一樣;成員的複製建構子、
|
|
52
|
+
複製指定或預設建構子是 private 時(隱含的那一個是刪除的),沒用到它的程式判 reject,clang 接受。現在和函式庫的函式一樣,用到
|
|
53
|
+
(呼叫、取位址)才檢查,用到時照舊拒絕。解構子照舊一律檢查(物件離開範圍時呼叫,不經可見的使用)。新欄位 `CppTables.implicit`
|
|
54
|
+
(**不相容**:自己列全部欄位的記錄要補);新的內部名字 `Classes.isImplicitNode`。判決的時間也變短:有虛擬基底的
|
|
55
|
+
`qualified_calls/virtual_base_named.cpp`、`virtual_base_through_intermediate.cpp` 約 2089 萬、2085 萬心跳變約 1009 萬、1005 萬。
|
|
56
|
+
測試:`tests/cases/implicit_members_used/`(沒用到的 3 支,改前 reject、改後 accept)、`tests/cpp_implicit_members_used_test.cella`
|
|
57
|
+
(用到的 3 支照舊 reject;clang 的樹是 RecoveryExpr,轉換工具不轉,手寫),輸出對過 clang++ -std=c++17。
|
|
58
|
+
|
|
59
|
+
- **有解構子的類別物件也可以常數初始化;const 的整數全域變數可以用在常數初始值裡**([basic.start.static]p2、[expr.const]p3、
|
|
60
|
+
[basic.start.term]p3):之前全域的類別物件有解構子時一律在原來的位置建構,寫在前面的動態初始化讀它判 reject;`const int y = 7;
|
|
61
|
+
int x = y;` 的 `x` 被當成動態初始化(先是零),寫在前面的動態初始化讀到 0,clang 讀到 7。現在有解構子的類別物件(其餘條件同上一條)
|
|
62
|
+
也在任何動態初始化之前建構,解構的順序照它在動態初始化之間的位置(標準:照建構完成的順序的反序);初始值只讀到寫在前面、本身是
|
|
63
|
+
常數初始化的 const 整數或列舉的全域變數,也是常數初始化。clang 的輸出對過(`destructor_constant_early.cpp` 印 `5 ~E2~D5~E1`、
|
|
64
|
+
`const_read_early.cpp` 印 `70660`)。有引數的 constexpr 建構子見上面一條。
|
|
65
|
+
測試:`tests/cases/static_initialization/`(多 2 支,共 10 支)。
|
|
66
|
+
|
|
67
|
+
- **全域的類別物件:隱含的預設建構子是常數運算式時是常數初始化**([basic.start.static]p2、[class.default.ctor]p4):`struct Q { int v = 5; };
|
|
68
|
+
Q q[10];` 這種物件(或陣列)沒有初始值或用 `{}` 初始化、類別沒有宣告建構子、預設建構讓每個物件都一樣(`ClassMembers.constructsAlike`:
|
|
69
|
+
成員用字面常數初始化)、沒有解構子要執行時,在任何動態初始化之前就建構好;之前寫在它前面的動態初始化讀它判 reject,clang 讀到
|
|
70
|
+
建構好的值。有解構子的類別也一樣(見上面一條)。
|
|
71
|
+
新的內部名字:`Classes.constantObject`(C++ 的 `ProgramExtension.constantObject`)。測試:`tests/cases/static_initialization/`
|
|
72
|
+
(8 支,輸出對過 clang++ -std=c++17)。
|
|
73
|
+
|
|
74
|
+
- **`std::sort` 只在看得到時才附假設 `sort.order`;新增 `std::stable_sort`、`std::partial_sort`、`std::nth_element`**([alg.sort]):
|
|
75
|
+
- `sort(first, last)`(預設的 `<`)之前一律附 `sort.order`;現在只在相等而不同的元素排出來的先後看得到時才附:元素是整數、字元、
|
|
76
|
+
`bool`、列舉、指標、`std::string`,或成員都是這些的 `std::pair`,相等就是同一個值,不附;`double`/`float` 只有 `+0` 與 `-0`
|
|
77
|
+
都在範圍裡時附;其他的類別(自己寫 `operator<` 的 struct)照舊附。範圍只有一個元素時不附。自己給的比較子(函式、lambda、
|
|
78
|
+
`greater<int>()`)照舊一律附(它當成相等的是不是同一個值不知道;也不為了看而多呼叫它)。
|
|
79
|
+
- `std::stable_sort`(兩種形式)照 libc++ 18 移植:相等的元素保持原來的順序,不附假設;比較與移動的次數照 libc++(可逐位元複製指定的
|
|
80
|
+
元素 128 個以內就地插入排序,其他的經過暫存區合併)。`std::partial_sort`、`std::nth_element`(兩種形式)照 libc++ 18 移植:前段/
|
|
81
|
+
第 n 個的值是標準定的;後段(`partial_sort.rest`)與兩側(`nth_element.rest`)的順序標準沒規定,兩個以上時附新的假設;相等元素
|
|
82
|
+
的先後同 `sort` 的規則附 `sort.order`。
|
|
83
|
+
- 新的原語:`__cella_equal_means_same(x)`、`__cella_trivially_copy_assignable(x)`、`__cella_negative_zero(x)`;`ClassMembers` 多一個欄位
|
|
84
|
+
`assignsTrivially`(**不相容**:建構 `ClassMembers` 要多給一個欄位)、`CppExpr` 多一個建構子 `negativeZero`;新的內部名字
|
|
85
|
+
`Classes.assignsTriviallyOf`、`Primitives.typeAnswer`、`Primitives.sameWhenEqual`、`Primitives.triviallyCopyAssignable`、
|
|
86
|
+
`Primitives.negativeZeroTest`、`Primitives.negativeZeroValue`;函式庫的 `std::__equal_alike`(`<utility>`、`<string>`)、
|
|
87
|
+
`std::__order_seen`、`std::__apart`、`std::__sort` 與 stable_sort/partial_sort/nth_element 的 libc++ 內部函式。
|
|
88
|
+
- `<algorithm>` 現在也帶進 `<utility>`(libc++ 的 `<algorithm>` 就帶進 `std::pair`):只 include `<algorithm>` 的程式用 `pair` 之前
|
|
89
|
+
判拒絕或不知道,現在照 clang 接受。
|
|
90
|
+
- 判決的變化(都仍是 accept,輸出不變):預設 `<` 排整數、字串、pair 等的程式少了 `sort.order` 的假設。測試:
|
|
91
|
+
`tests/cases/sort_order/`(23 支,輸出對過 clang++ -std=c++17 與 libc++ 18)。
|
|
92
|
+
|
|
93
|
+
- **函式樣板的實例以程式的類別為引數時就地做出,不再重新準備整個程式**(判決的時間變短,判決不變):樣板的實例由名字做出時,引數的
|
|
94
|
+
寫法之前只認純量(`twice<int>`),類別(`twice<P>`、`__sort<reverse_iterator<__wrap_iter<int *>>>`)的實例都要求重新準備並重新檢查
|
|
95
|
+
整個程式,一次呼叫鏈可以重來十幾次。現在引數是程式已有的類別(或樣板類別的實例)時也就地做出。`Templates.unspelled` 多一個參數
|
|
96
|
+
`classes`(**不相容**:呼叫要多給程式的類別)。量到的(同一台機器、快取已暖):`sort(vec.rbegin(), vec.rend())` 加上一支有 struct
|
|
97
|
+
與 `operator<` 的程式,523 秒變 58 秒;`struct` 加 `operator<` 加 `sort(A, A + n)` 一支,129 秒變 24 秒。測試:
|
|
98
|
+
`tests/cases/template_instances/`(輸出對過 clang++ -std=c++17)。
|
|
99
|
+
- **一般函式與函式樣板同名時,樣板之間照偏序選最特化的**([over.match.best]p2.5、[temp.func.order]):`template <class T> bool alike(const T &)`、
|
|
100
|
+
`template <class A, class B> bool alike(const pair<A, B> &)` 與一般的 `bool alike(const string &)` 同名,`alike` 一個 `pair<int, int>`
|
|
101
|
+
之前判 reject("call to 'alike' is ambiguous");現在和只有樣板的名字一樣,先比引數的轉換、再比特化,選 `pair` 那個,照 clang 接受。
|
|
102
|
+
新的內部名字:`Templates.viable`、`Templates.bestViable`(`Templates.chosen` 也改用它們)。
|
|
103
|
+
測試:`tests/cases/template_instances/overload_order_through_pointer.cpp`、`overload_order_through_vector.cpp`。
|
|
104
|
+
|
|
8
105
|
- **同樣建構的類別陣列只建構第一個元素,其餘是它的副本(判決的步數變少)**:類別的預設建構子讓每個物件都一樣、而且不寫別的東西時
|
|
9
106
|
(`ClassMembers.constructsAlike`:沒有虛擬函式與虛擬基底;隱含的預設建構子,或沒有參數、本體是空的;成員只用字面常數、`()`/`{}`
|
|
10
107
|
初始化或不初始化;成員的型別是算術、列舉、指標、它們的陣列、或也符合的類別,typedef 照它代表的型別),宣告的陣列(全域、區域、成員)
|
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.friends.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.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
|