@cella-lang/cpp 0.1.202611060046 → 0.1.202611061710

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 +40 -0
  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 +1531 -1412
  48. package/package.json +6 -5
package/CHANGES.md CHANGED
@@ -5,11 +5,51 @@
5
5
 
6
6
  ## 未發佈
7
7
 
8
+ - **long double**(見 `@cella-lang/cfamily`):`{"k": "tLongDouble"}`、`1.0L`;`sizeof(long double)` 是 16,`cout` 照 x87 的精度輸出,
9
+ `f(double)` 與 `f(long double)` 是不同的多載,`typeid` 的名字是 `e`,模板推導出 long double。判決的 `assumes` 多
10
+ `x86-64-sysv:longDouble.x87Extended`。`<cmath>` 的函式收到 long double(`std::sqrt(2.0L)`、`std::abs(-2.5L)`)判 unknown:模型
11
+ 沒有 long double 的版本。`std::isnan`/`std::isinf` 改成取 long double(一個函式涵蓋全部多載,值不變)。
12
+ `Rules` 多一欄 `mathOverloadedByType := true`。
13
+ - **型別文字改了**(型別查詢 `types().nodes` 的型別、錯誤訊息 reason 裡的型別、除錯器的標籤;判決的 kind、at 與輸出不變):
14
+ 類別樣板的實例不再寫出和預設樣板引數相同的尾端引數,和 clang 印的標準型一樣——`std::tuple<int, int, int>`(之前
15
+ `std::tuple<int, int, int, std::__tuple_nil>`)、`std::tuple<int>`、`std::set<int>`(之前 `std::set<int, std::less<int>>`)、
16
+ `std::map<std::string, int>`(之前帶 `std::less<std::string>`)、`std::queue<std::tuple<int, int, int>>`(之前帶
17
+ `std::deque<...>`)、`std::priority_queue<int>`。不是預設的照寫(`std::set<int, std::greater<int>>`);寫出來但和預設相同的
18
+ (`set<int, less<int>>`)也印 `std::set<int>`(clang 的標準型;模型沒有 typedef 的糖衣)。程式的類別樣板一樣
19
+ (`template <class T, class U = int> struct Box`,`Box<char, int>` 印 `Box<char>`)。例:`the model's 'std::set<int>' has no overload of 'insert' ...`。
20
+ 語意樹的形狀不變。
21
+ - **之前判 reject、現在判 accept**(clang++ 只給 warning 或沒有):對只宣告的類別(`class Helper;`)的指標解參照、不讀值的寫法——
22
+ `*p;`、`(void)*p;`、`*p, 1`、`&*p`、`Helper &r = *p;`、回傳 `Helper &` 的 `return *p;`。C++17 [expr.unary.op]p1:結果是左值;
23
+ [expr]p12:運算式敘述不做左值轉右值。
24
+ - **之前判 accept、現在判 reject**:函式定義以值取只宣告的類別當參數或回傳型別(`void take(Helper h) { }`、`Helper make(...) { ... }`),
25
+ reason `variable has incomplete type`/`incomplete result type in function definition`,at 是函式定義(C++17 [dcl.fct.def.general]p2)。
26
+ - 仍是 reject,reason 改了(kind 照舊 `reject`):`p->v`、`(*p).v` 改成 `member access into incomplete type`;`*p = *q` 改成
27
+ `incomplete type where a complete type is required`(at 是指派);`sizeof(*p)` 改成 `sizeof an incomplete type`(at 是 sizeof)。
28
+ `Helper h = *p`、`Helper h;` 照舊 `variable has an incomplete type`;`p[0]` 照舊。見 `@cella-lang/cfamily`。
29
+
8
30
  - **之前判 accept、現在判 reject(`ubFlowOffEnd`)**:回傳值的函式(main 除外,含成員函式、寫了回傳型別的 lambda)執行到結尾、
9
31
  沒有 return,只呼叫不用值(`int f() {} ... f();`)。C++17 [stmt.return]p2:執行到結尾本身就是未定義行為。用到值的
10
32
  (`int y = f();`)判決照舊是 reject,但種類從 `ubUninit`(`C++17 [dcl.init]p12`,at 是呼叫)改成 `ubFlowOffEnd`(`C++17 [stmt.return]p2`,
11
33
  at 是函式的定義)。只有走到結尾的那次呼叫才算(`if (x) return 1;` 的 `g(1)` 照舊 accept);void 函式、main(結束碼 0)、推導成 void
12
34
  的 lambda 不受影響。見 `@cella-lang/cfamily` 的變更。
35
+ - `<tuple>`(新的模組 `cpp.library.tuples`,`lib/tuple.hpp`):`std::tuple`(一到四個元素,型別各自不同)、`make_tuple`、
36
+ `get<I>`(回傳元素的參考,可以當左值寫入;const 的 tuple 回傳 const 參考)、`tie`(二到四個,`tie(a, b, c) = t`)、
37
+ `tuple_element<I, T>::type`、六個比較運算子(`<` 依字典序只用元素的 `<`,同 pair),結構化綁定 `auto [a, b, c] = t`、
38
+ `auto &[a, b, c] = q.front()`,放進 queue、vector、priority_queue、sort。**之前判 reject**(沒有模型:`unknown type`、`a constructor's arguments for a type that is not a class`),clang++ 接受。
39
+ - 語意樹的形狀(不變,同 pair、queue):`tuple<int, int, int>` 是
40
+ `{"k":"tTemplate","name":"tuple","args":[{"k":"tInt"},{"k":"tInt"},{"k":"tInt"}]}`(寫 `std::tuple` 時 name 是
41
+ `"std::tuple"`),`queue<tuple<int, int, int>>` 是 tTemplate 套 tTemplate;`get<1>(t)` 是
42
+ `{"k":"eCallT","f":"get","targs":[{"k":"tVal","v":1}],"args":[t]}`;`make_tuple(...)`、`tie(...)` 是 `eCall`;
43
+ `auto [r, c, d] = q.front();` 是 `sBind`(`t` 是 `tAuto`,`auto &` 是 `{"k":"tRef","t":{"k":"tAuto"}}`)。
44
+ - 做不到的:五個以上的元素(模型的類別樣板還沒有參數包,寫成四個參數加部分特化)、元素型別不同的 tuple 之間的轉換
45
+ (`tuple<long, long> t = make_tuple(1, 2)`,要類別樣板的成員樣板)、`get<T>`、`tuple_size`、`tuple_cat`、`std::ignore`、
46
+ `tuple t(1, 2, 3)`(類別樣板引數推導)。型別名字和 clang 一樣是 `std::tuple<int, int, int>`(見上面型別文字那一條)。
47
+ - 函式樣板的多載(`Templates.chosen`):兩個樣板都可行時先比引數綁到參考的轉換(`f(T &)` 對非 const 的左值勝過
48
+ `f(const T &)`,[over.ics.rank]p3.2.6),一樣好才用偏序,偏序裡 `const T &` 比 `T &` 特化([temp.deduct.partial]p9);
49
+ 右值(含 xvalue)不再被當成可以綁到非 const 左值參考的參數(那個樣板不可行);偏序比較時同一個類別樣板寫出的實例
50
+ (`Box<T> &` 對 `const Box<T> &`)逐個引數比。之前這些情況判 unknown(「none more specialized than the others」)。
51
+ - 寫了樣板引數的呼叫當左值:`get<1>(t) = 9`、`id<int>(a) = 4`(回傳參考)之前判 reject(expression is not assignable)。
52
+ `References.callAsLvalue` 是新的。
13
53
 
14
54
  - 執行期的問題帶出問題的值(見 `@cella-lang/cfamily`;**reason 文字不變**):`ubBounds` 的 `index`、`size`(指標算術;容器的下標
15
55
  `v[i]` 也帶:vector、deque、string、bitset 的 `operator[]`;空容器的 front/back/pop 不帶)、`ubPastEnd` 的 `index`、`size`、
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