@cella-lang/cpp 0.1.202611070815 → 0.1.202611080136

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.
Files changed (48) hide show
  1. package/CHANGES.md +67 -1
  2. package/cpp.arrays.cell +0 -0
  3. package/cpp.cell +0 -0
  4. package/cpp.classes.cell +0 -0
  5. package/cpp.classrules.cell +0 -0
  6. package/cpp.construction.cell +0 -0
  7. package/cpp.constructs.cell +0 -0
  8. package/cpp.copies.cell +0 -0
  9. package/cpp.exceptions.cell +0 -0
  10. package/cpp.inheritance.cell +0 -0
  11. package/cpp.lambdas.cell +0 -0
  12. package/cpp.layouts.cell +0 -0
  13. package/cpp.library.algorithms.cell +0 -0
  14. package/cpp.library.bitsets.cell +0 -0
  15. package/cpp.library.cell +0 -0
  16. package/cpp.library.comparisons.cell +0 -0
  17. package/cpp.library.deques.cell +0 -0
  18. package/cpp.library.iterators.cell +0 -0
  19. package/cpp.library.lists.cell +0 -0
  20. package/cpp.library.maps.cell +0 -0
  21. package/cpp.library.numerics.cell +0 -0
  22. package/cpp.library.pairs.cell +0 -0
  23. package/cpp.library.queues.cell +0 -0
  24. package/cpp.library.sets.cell +0 -0
  25. package/cpp.library.stacks.cell +0 -0
  26. package/cpp.library.strings.cell +0 -0
  27. package/cpp.library.trees.cell +0 -0
  28. package/cpp.library.tuples.cell +0 -0
  29. package/cpp.library.unorderedmaps.cell +0 -0
  30. package/cpp.library.vectors.cell +0 -0
  31. package/cpp.memberpointers.cell +0 -0
  32. package/cpp.names.cell +0 -0
  33. package/cpp.objects.cell +0 -0
  34. package/cpp.operators.cell +0 -0
  35. package/cpp.overloading.cell +0 -0
  36. package/cpp.polymorphism.cell +0 -0
  37. package/cpp.primitives.cell +0 -0
  38. package/cpp.ranges.cell +0 -0
  39. package/cpp.references.cell +0 -0
  40. package/cpp.runtimetypes.cell +0 -0
  41. package/cpp.standardexceptions.cell +0 -0
  42. package/cpp.standardfunctions.cell +0 -0
  43. package/cpp.staticmembers.cell +0 -0
  44. package/cpp.streams.cell +0 -0
  45. package/cpp.templates.cell +0 -0
  46. package/cpp.userconversions.cell +0 -0
  47. package/index.json +1149 -989
  48. package/package.json +5 -5
package/CHANGES.md CHANGED
@@ -5,6 +5,53 @@
5
5
 
6
6
  ## 未發佈
7
7
 
8
+ - **之前判 unknown(orderUncompared,why=access)、現在判 accept**:`std::to_string` 旁邊讀成員或經指標的值
9
+ (`return to_string(re) + (im < 0 ? "-" : "+") + to_string(im < 0 ? -im : im) + "i";`,re、im 是成員)。to_string 的本體只用
10
+ snprintf 寫自己的區域陣列,之前被算成「寫別處」。程式自己的函式用 snprintf、memcpy、strcpy 寫自己的區域陣列也一樣。真的寫到
11
+ 被讀的記憶體的(經指標參數、寫全域陣列、寫成員陣列)照舊 unknown。根因與 API 見 `@cella-lang/cfamily`。
12
+ - **之前錯的 accept、現在 unknown**:呼叫寫全域變數或物件、旁邊讀它的元素或成員(`setg() + g[0]`);呼叫經 `auto` 推導的指標寫
13
+ (`auto p = g; p[0] = 5;`)、旁邊讀 `g[0]`。
14
+
15
+ - **之前判 reject(callArguments)、現在判 accept**:範圍建構子 `vector(i, j)`、`string(i, j)`、`deque(i, j)`([sequence.reqmts]
16
+ 的 X(i, j);任何輸入迭代器)。`int a[3] = {3, 1, 2}; vector<int> v(a, a + 3); cout << v.size();` 印 3(之前「no matching
17
+ constructor for initialization of 'std::vector<int>'」);範圍可以是陣列的指標、另一個容器(vector、string、set、deque)的
18
+ 迭代器,元素型別可以不同(`vector<double> h(a, a + 2)`)。vector 照 libc++ 的 `__init_with_size`:剛好那些元素的區塊,空的
19
+ 範圍不配置(`capacity()` 是 0)。兩個整數照舊選計數的版本(`vector<int> v(3, 7)`)。semorphe 照舊送
20
+ `sDeclC { t: vector<int>, args: [eVar a, eBin(+, eVar a, 3)] }`。範圍的兩端倒過來判 reject(`ubLib`;libc++ 丟 length_error 停下)。
21
+ - **建構子樣板**(一般化,使用者自己寫的也可以;語意樹 `mbCtorTemplate` 見 `@cella-lang/cfamily`):建構時照 [temp.deduct.call]
22
+ 推導,預設樣板引數代換失敗的不參加(`enable_if_t`);和一般的建構子一樣好時一般的勝([over.match.best]p2.4),樣板的完全
23
+ 符合勝過一般的轉換;explicit 的不用在複製初始化(`E e = 1;` 判 reject「no viable conversion」)。類別樣板的建構子樣板也可以
24
+ (`Holder<double> h(1.5, 2)`)。判 unknown:有虛擬基底的類別的建構子樣板。不做:經由建構子樣板的隱式轉換(傳引數、回傳值)。
25
+ - **成員初始化串列的大括號**(語意樹 `minitList` 見 `@cella-lang/cfamily`;之前 semorphe 只能降級):照 [dcl.init.list] 直接串列
26
+ 初始化——有建構子的類別選建構子(`k{6, 7}`;有 initializer_list 建構子的從串列建,`v{1, 2}`),聚合體(含有預設成員初始化子的、
27
+ 聚合體基底 `Base{7, 8}`)、陣列(`c{1, 2, 3}`、巢狀的 `rows{{1, 2}, {3, 4}}`)、純量(`z{9}`)先零初始化再依序存各項,沒列到的
28
+ 是預設成員初始化子或零;`d{}` 值初始化。元素窄化(`c{1.5}`)與多出的項判 reject(clang++ 不編譯)。判 unknown:委派建構子的
29
+ 大括號(`C() : C{1} {}`)、建構子引數裡的巢狀大括號、元素是有建構子的類別的陣列成員、聚合體裡有建構子或解構子的成員。
30
+ - `Constructor`(類別表的建構子)多一欄 `templated : Bool`(建構子樣板:function 是函式樣板 `C::C#ck`)。
31
+ ⚠️ 不相容:`Constructor` 的記錄字面量要多寫 `templated`。
32
+
33
+ - **之前錯的 accept(輸出錯)、現在照 clang++**:回傳參照的呼叫直接當條件(`if (K[i])` 的 `vector<bool>`、`vector<int>`、`deque`、
34
+ `map` 的 `[]`、`front()`、`at()`、`bool &f()`;if、while、for、do 的條件與 switch 的控制運算式),之前讀到元素的位址、永遠是真
35
+ (`vector<bool> K(5, 0); K[1] = 1; K[3] = 1;` 之後 `if (K[i]) cout << i;` 印 `1234`,clang++ 印 `13`;走出範圍的迴圈則判
36
+ reject `pointer out of bounds`)。`!K[i]`、`K[i] == 0`、`K[i] && x`、`?:` 本來就對。根因在 `@cella-lang/cfamily`(條件的暫時
37
+ 變數和呼叫結果的暫時物件同名)。
38
+ - **之前錯的 reject、現在判 accept**:`string` 的位置版 `insert`([string.insert])——`insert(pos, const char*)`、`insert(pos, s, n)`、
39
+ `insert(pos, const string&)`、`insert(pos, str, pos2, n)`、`insert(pos, n, c)`,迭代器版 `insert(p, c)`、`insert(p, n, c)`(回傳第一個
40
+ 插入的位置)。`s.insert(3, "l")` 之前判 reject「template argument deduction failed」(只有範圍版本的樣板,推導失敗)。
41
+ `pos`(或另一個字串的起點)超過 `size()` 丟 `out_of_range("basic_string")`;迭代器不是這個字串的判 reject(越界)。
42
+ - **之前判 unknown、現在判 accept**:`string` 的 `replace`([string.replace])——索引與長度換成 C 字串(的前 n 個)、另一個字串
43
+ (的一段)、n 個字元;迭代器的兩端換成同樣的幾種與任何輸入迭代器的範圍。換上的可以是自己的字元。
44
+ - **之前判 unknown、現在判 accept**:`<algorithm>` 的 `std::copy`、`copy_n`、`copy_backward`、`copy_if`([alg.copy]),來源與目的地是
45
+ 指標或任何容器的迭代器。之前判 unknown「std::copy is not supported yet」。違反前置條件(copy 的目的地在 `[first, last)` 裡、
46
+ copy_backward 的在 `(first, last]` 裡、copy_if 的兩個範圍重疊;只有指標看得出來)判 reject(`ubLib`);libc++ 用 memmove 照常結束。
47
+ - 函式樣板(含成員函式樣板)的引數推導不出來時,訊息照 clang:`no matching function for call to 'f'`、成員的是
48
+ `no matching member function for call to 'f'`(問題的種類 `callArguments`,和一般函式不符合的相同;之前是
49
+ 「template argument deduction failed」)。函式庫類別的成員只有樣板、推導不出來時改判 unknown(「the model's 'C' has no overload of
50
+ 'f' for these arguments」,同一般成員函式):之前判 reject,例如 `deque<int> d; d.assign(3, 7);`(模型的 deque 還沒有計數的
51
+ `assign`)。
52
+ - 一般函式與函式樣板同名時,同名的每個樣板都推導(之前只看第一個):string 的迭代器版 insert、replace 因此選得到。
53
+ - `Cpp.nameParts`、`Cpp.libraryOwner`、`Cpp.mismatchOf` 從模組 `cpp` 移到 `cpp.classes`(名字不變,雜湊改變)。
54
+
8
55
  - **之前判 unknown、現在判 accept**:元素是類別的可變長度陣列(GNU 的擴充;`P a[n];`、`std::string b[n];`、`std::vector<int> adj[n];`,
9
56
  `n` 從輸入讀)。之前判 unknown(`unsupported`,"a variable length array of objects of a class")。現在照 clang/g++ 執行:元素照索引
10
57
  逐一預設建構,離開時反序解構,建構子丟出時已建好的反序解構;判決帶假設 `{"implementation":"gcc","choice":"vla"}`(和純量的
@@ -31,7 +78,7 @@
31
78
  v.begin() + 1)`、`v.assign(v.end(), v.end())`、`d.assign(d.begin() + 1, d.end())`;要求表的前置條件),範圍的兩端倒過來
32
79
  (`v.insert(v.end(), a + 3, a)`)。libc++ 不檢查(clang 照常結束),標準說未定義。string 的範圍可以是自己的字元
33
80
  (標準把它們定成先做出 `basic_string(i, j)`),照常 accept。deque 的範圍指向自己只在範圍不空時判。
34
- - 沒變(照舊 unknown):範圍建構子 `vector(i, j)`、`string(i, j)`、`deque(i, j)`(要建構子樣板,模型還沒有);string 的計數
81
+ - 沒變(照舊 unknown):範圍建構子(見上面,同一個未發佈的版本裡已補上);string 的計數
35
82
  版本;`deque::insert`。兩個整數的寫法(`v.assign(3, 7)`)選計數的版本,不會選到範圍版本(算術型別與列舉不參加多載,
36
83
  [sequence.reqmts]p14)。
37
84
  - 模型的樣板特徵多 `std::is_arithmetic_v`、`std::is_enum_v`(預設樣板引數裡的 `std::enable_if_t<!std::is_arithmetic_v<T>>`)。
@@ -41,6 +88,25 @@
41
88
  - **之前判 unknown(ubPtrOrder)、現在判 accept**:空的 vector 的 `insert(v.begin(), x)`、`erase(v.begin(), v.end())`。位置的
42
89
  前置條件改用 `==` 與「指向區塊之內」問(空的 vector 的區塊是 null,之前用 `<` 比兩個 null 被當成跨物件的比較)。
43
90
  - `vector::insert(p, n, x)`、`vector::assign(n, x)`(計數的版本)新增;`assign(n, x)` 的 x 是自己的元素判 reject(`ubLib`,要求表的前置條件)。
91
+ - **之前判 unknown、現在判 accept**:成員函式呼叫的物件先於引數(C++17 [expr.call]p8),運算子寫法的多載呼叫照內建運算子的
92
+ 順序([over.match.oper]p2)。`log << 1 << 2`、`r << "items:" << prices[0] << 7`(`Log &operator<<` 成員,或程式的
93
+ `Log &operator<<(Log &, int)`)、`a << next() << next()`、`get()[i()]`、`get().add(f())` 之前判 unknown(`ubOrder`「the calls
94
+ are in an unspecified order and the two orders give different results」,或 `orderUncompared`,why=budget),現在照 C++17
95
+ 的順序跑。`<<`、`>>`、`[]`、`()`、`->*`、`&&`、`||`、`,` 左先於右;類別的 `=`、`+=` 等**右先於左**:
96
+ `left() = right()` 之前先跑 `left()`(並判 unknown),現在先跑 `right()`(clang++ 一樣)。照舊不定序(結果依順序時 unknown)的:
97
+ 引數之間(`c.f(g(), h())`)、`+`、`==` 等運算子的兩邊、明寫的 `a.operator+(b())`。
98
+ - **之前判 reject、現在判 accept**:其餘參數有預設值的建構子也是轉換建構子([class.conv.ctor]p1):
99
+ `F(int a = 0, int b = 1)` 的類別,`num(7)`(參數 `const F &`)、`h -= 3`、`g = 4`、`return 7;`、`F x = 7;`,之前判
100
+ reject「no matching function for call to 'num'」/「no matching member function for call to 'operator-='」/
101
+ 「incompatible struct types」/「this conversion needs a temporary, which cannot be made here」(類別標成函式庫時是 unknown
102
+ 「the model's 'F' has no overload of ...」)。呼叫時其餘參數取預設值。
103
+ - **之前判 accept(輸出錯)、現在輸出照 clang++**:第一個參數之後有預設值的複製/移動建構子(`X(const X &o, int k = 5)`,
104
+ [class.copy.ctor]p1)之前不算複製建構子,複製時逐位元複製、不呼叫它;現在照複製建構子呼叫(其餘參數取預設值)。
105
+ - `Constructor`(`cpp.constructs`)多一欄 `required : Nat`(沒有預設值的參數數),**不相容**:自己建 `Constructor` 記錄的
106
+ 程式要補這一欄。改變的定義:`Classes.callOf`(回傳 `Kept`)、`UserConversion.made`(多 `g` 參數)、`Classes.isCopyParameters`、
107
+ `Classes.isMoveParameters`、`Copies.assignment`、`Operators.call`、`Operators.functionLvalue`、`Operators.index`;新增 `Kept`(與 `Kept.Checked`、`Kept.checkWith`、`Classes.checkedCall`)、
108
+ `Classes.kept`、`Classes.objectFirst`、`Classes.isOperatorName`、`Classes.allDefaulted`、`Operators.keptLeft`、
109
+ `Copies.keptRight`、`Copies.constructorCall`。語意樹的形狀不變。
44
110
 
45
111
  - **之前判 reject、現在判 accept**(0.1.202611061934 的退步):型別只由推導得到的類別樣板實例(`auto t = make_tuple(1, 2, 3); auto [a, b, c] = t;`),函式定義當下也看得到([temp.inst]p2:隱式實例化在需要的地方就完整)。之前判 reject「a structured binding needs an array, a struct or a class」。用名字定義、在函式之後才定義的類別照舊判 reject。
46
112
  - **新增 `cpp.verdictReport`**(和 `cpp.verdict` 同參數、同型別):判決的 JSON 原封不動,最後多一個 `"steps": N`——這次執行用掉
package/cpp.arrays.cell CHANGED
Binary file
package/cpp.cell CHANGED
Binary file
package/cpp.classes.cell CHANGED
Binary file
Binary file
Binary file
Binary file
package/cpp.copies.cell CHANGED
Binary file
Binary file
Binary file
package/cpp.lambdas.cell CHANGED
Binary file
package/cpp.layouts.cell CHANGED
Binary file
Binary file
Binary file
package/cpp.library.cell CHANGED
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/cpp.names.cell CHANGED
Binary file
package/cpp.objects.cell CHANGED
Binary file
Binary file
Binary file
Binary file
Binary file
package/cpp.ranges.cell CHANGED
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/cpp.streams.cell CHANGED
Binary file
Binary file
Binary file