aiscript icon indicating copy to clipboard operation
aiscript copied to clipboard

連想配列の追加(再)

Open FineArchs opened this issue 1 year ago • 1 comments

手違いにより #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で組み込みプロパティの追加もしたいです

FineArchs avatar Jul 30 '24 11:07 FineArchs

:warning: Please install the 'codecov app svg image' 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.

Files with missing lines Patch % Lines
src/interpreter/serial-expression.ts 41.91% 79 Missing :warning:
src/interpreter/util.ts 36.00% 16 Missing :warning:
src/interpreter/index.ts 53.84% 12 Missing :warning:
src/interpreter/dic.ts 86.66% 6 Missing :warning:
src/interpreter/value.ts 72.72% 3 Missing :warning:
src/parser/syntaxes/expressions.ts 95.45% 2 Missing :warning:
src/utils/mustbenever.ts 33.33% 2 Missing :warning:

: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

... and 21 files with indirect coverage changes

codecov-commenter avatar Aug 22 '24 03:08 codecov-commenter