aiscript
aiscript copied to clipboard
連想配列の追加(再)
手違いにより #693 が閉じられてしまったので再作成します。
概要
let sampledic = dic {
[1]: null
['hoge']: 'fuga'
[[1, 2, 4]]: [4, 5, 6]
[Core:add]: @(){ print(1) }
}
let key = [1, 2, 4]
<: sampledic[key] // [4, 5, 6]
名前空間記法との兼ね合いから、キーは全て[ ]で囲うようになっています。
キーの等価性はdeep-equalになっています(関数のみ参照比較)。
実装
トライ木の構造を採用しています。 その都合上、キーを直列化する仕組みを導入しています。
Why
#225
備考
- 循環参照対策はまだしていません
- 同時書き込み対策はまだしていません
- console.jsが書き換わっているのはついでです。変数が保持されるようになっています
- 別PRで組み込みプロパティの追加もしたいです
:warning: Please install the to ensure uploads and comments are reliably processed by Codecov.
Codecov Report
Attention: Patch coverage is 59.45946% with 120 lines in your changes missing coverage. Please review.
:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.
| Files with missing lines | Coverage Δ | |
|---|---|---|
| src/node.ts | 71.42% <100.00%> (-26.95%) |
:arrow_down: |
| src/parser/plugins/validate-keyword.ts | 88.33% <ø> (-0.29%) |
:arrow_down: |
| src/parser/scanner.ts | 94.41% <100.00%> (+5.64%) |
:arrow_up: |
| src/parser/token.ts | 100.00% <100.00%> (ø) |
|
| src/utils/random/genrng.ts | 52.27% <100.00%> (+0.18%) |
:arrow_up: |
| src/parser/syntaxes/expressions.ts | 91.92% <95.45%> (+2.73%) |
:arrow_up: |
| src/utils/mustbenever.ts | 33.33% <33.33%> (ø) |
|
| src/interpreter/value.ts | 95.71% <72.72%> (-4.29%) |
:arrow_down: |
| src/interpreter/dic.ts | 86.66% <86.66%> (ø) |
|
| src/interpreter/index.ts | 92.48% <53.84%> (+6.68%) |
:arrow_up: |
| ... and 2 more |