Skip to content

連想配列の追加(再)#738

Open
FineArchs wants to merge 16 commits into
aiscript-dev:masterfrom
FineArchs:dic
Open

連想配列の追加(再)#738
FineArchs wants to merge 16 commits into
aiscript-dev:masterfrom
FineArchs:dic

Conversation

@FineArchs

Copy link
Copy Markdown
Member

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

@codecov-commenter

codecov-commenter commented Aug 22, 2024

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ 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 ⚠️
src/interpreter/util.ts 36.00% 16 Missing ⚠️
src/interpreter/index.ts 53.84% 12 Missing ⚠️
src/interpreter/dic.ts 86.66% 6 Missing ⚠️
src/interpreter/value.ts 72.72% 3 Missing ⚠️
src/parser/syntaxes/expressions.ts 95.45% 2 Missing ⚠️
src/utils/mustbenever.ts 33.33% 2 Missing ⚠️
❗ 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%) ⬇️
src/parser/plugins/validate-keyword.ts 88.33% <ø> (-0.29%) ⬇️
src/parser/scanner.ts 94.41% <100.00%> (+5.64%) ⬆️
src/parser/token.ts 100.00% <100.00%> (ø)
src/utils/random/genrng.ts 52.27% <100.00%> (+0.18%) ⬆️
src/parser/syntaxes/expressions.ts 91.92% <95.45%> (+2.73%) ⬆️
src/utils/mustbenever.ts 33.33% <33.33%> (ø)
src/interpreter/value.ts 95.71% <72.72%> (-4.29%) ⬇️
src/interpreter/dic.ts 86.66% <86.66%> (ø)
src/interpreter/index.ts 92.48% <53.84%> (+6.68%) ⬆️
... and 2 more

... and 21 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.