From 90549d61a5ac27c190548a3ff49d30d118e50037 Mon Sep 17 00:00:00 2001 From: taichanne30 Date: Sat, 13 May 2023 07:06:06 +0900 Subject: [PATCH 1/2] feat: Add return str (https://github.com/syuilo/aiscript/issues/268) --- src/interpreter/util.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/interpreter/util.ts b/src/interpreter/util.ts index d7df51b0..c6b5d45c 100644 --- a/src/interpreter/util.ts +++ b/src/interpreter/util.ts @@ -100,6 +100,7 @@ export function valToString(val: Value, simple = false): string { if (val.type === 'str') return `"${val.value}"`; if (val.type === 'arr') return `[${val.value.map(item => valToString(item, true)).join(', ')}]`; if (val.type === 'null') return '(null)'; + if (val.type === 'return') return valToString(val.value, true); } const label = val.type === 'num' ? val.value : @@ -108,6 +109,7 @@ export function valToString(val: Value, simple = false): string { val.type === 'fn' ? '...' : val.type === 'obj' ? '...' : val.type === 'null' ? '' : + val.type === 'return' ? valToString(val.value) : null; return `${val.type}<${label}>`; } From b85079e0c1e0c4711523db2898bb70dddc0b3b50 Mon Sep 17 00:00:00 2001 From: taichanne30 Date: Sat, 13 May 2023 07:09:24 +0900 Subject: [PATCH 2/2] update CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4412a793..511b5ef4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ [Read translated version (en)](./translations/en/CHANGELOG.md) +- インタプリタがreturn文を文字列化できるように + # 0.13.2 - `Date:year`,`Date:month`,`Date:day`,`Date:hour`,`Date:minute`,`Date:second`に時間数値の引数を渡して時刻指定可能に - array.sortとString用比較関数Str:lt, Str:gtの追加