nadesiko3 3.6.3 → 3.6.4

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 (39) hide show
  1. package/core/deno/README.md +16 -0
  2. package/core/package.json +1 -1
  3. package/core/src/nako_gen.mjs +15 -4
  4. package/core/src/nako_gen.mts +15 -4
  5. package/core/test/func_call.mjs +15 -0
  6. package/package.json +1 -1
  7. package/release/editor.js +1 -1
  8. package/release/editor.js.LICENSE.txt +69 -7
  9. package/release/editor.js.map +1 -1
  10. package/release/plugin_caniuse.js +2 -1
  11. package/release/plugin_caniuse.js.map +1 -1
  12. package/release/plugin_datetime.js +2 -1
  13. package/release/plugin_datetime.js.map +1 -1
  14. package/release/plugin_kansuji.js +2 -1
  15. package/release/plugin_kansuji.js.map +1 -1
  16. package/release/plugin_markup.js +2 -1
  17. package/release/plugin_markup.js.map +1 -1
  18. package/release/plugin_turtle.js +2 -1
  19. package/release/plugin_turtle.js.map +1 -1
  20. package/release/plugin_webworker.js +2 -1
  21. package/release/plugin_webworker.js.map +1 -1
  22. package/release/plugin_weykturtle3d.js +2 -1
  23. package/release/plugin_weykturtle3d.js.map +1 -1
  24. package/release/stats.json +1 -1
  25. package/release/version.js +1 -1
  26. package/release/version.js.LICENSE.txt +59 -23
  27. package/release/version.js.map +1 -1
  28. package/release/wnako3.js +1 -1
  29. package/release/wnako3.js.LICENSE.txt +341 -1
  30. package/release/wnako3.js.map +1 -1
  31. package/release/wnako3webworker.js +2 -1
  32. package/release/wnako3webworker.js.map +1 -1
  33. package/src/plugin_turtle.mjs +97 -100
  34. package/src/plugin_turtle.mts +116 -105
  35. package/src/plugin_webworker.mjs +11 -0
  36. package/tools/nako3edit/html/files.html +28 -6
  37. package/tools/nako3edit/html/nako3edit.css +30 -2
  38. package/tools/nako3edit/index.mjs +36 -0
  39. package/tools/nako3edit/a.sqlite3 +0 -0
@@ -0,0 +1,16 @@
1
+ # 日本語プログラミング言語「なでしこ3」言語エンジン (Deno版)
2
+
3
+ 本リポジトリのこのディレクトリには、なでしこ3の言語エンジンのみを取り出し、JavaScriptの実行エンジンDenoを使って簡単なコマンドを実行できるようにしたものです。最小限の構成となっています。
4
+
5
+ ## 簡単な使い方
6
+
7
+ ```sh
8
+ deno run --allow-all deno/snako.ts (なでしこのプログラム).nako3
9
+ ```
10
+
11
+ ## 参考リポジトリ
12
+
13
+ このディレクトリにあるDenoは最小構成になっているため、Denoの機能をもっと利用したい場合には、次のリポジトリを確認してください。
14
+
15
+ - [なでしこ3(Deno版)](https://github.com/kujirahand/nadesiko3deno/)
16
+
package/core/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nadesiko3core",
3
- "version": "3.6.3",
3
+ "version": "3.6.4",
4
4
  "description": "Japanese Programming Language Nadesiko v3 core",
5
5
  "main": "index.mjs",
6
6
  "type": "module",
@@ -745,7 +745,8 @@ export class NakoGen {
745
745
  }
746
746
  let variableDeclarations = '';
747
747
  const indent = ' ';
748
- const popStack = '';
748
+ let pushStack = '';
749
+ let popStack = '';
749
750
  const initialNames = new Set();
750
751
  if (this.speedMode.invalidSore === 0) {
751
752
  initialNames.add('それ');
@@ -755,8 +756,18 @@ export class NakoGen {
755
756
  this.varslistSet.push(this.varsSet);
756
757
  // JSの引数と引数をバインド
757
758
  variableDeclarations += indent + 'const 引数 = arguments;\n';
758
- // ローカル変数を生成
759
- variableDeclarations += indent + 'const __vars = new Map();\n';
759
+ // ローカル変数を生成 (再帰関数呼び出しで引数の値が壊れる問題がある #1663)
760
+ // 暫定変数__localVarsに現在のローカル変数の値をPUSHし、変数を抜ける時にPOPする)
761
+ // 関数として宣言しているが、JS関数となでしこ関数では変数管理の方法が異なるため、完全なローカル変数としては使えない
762
+ // 必ず、pushStack/popStack する必要がある
763
+ pushStack += '\n// PUSH STACK\n';
764
+ pushStack += 'const __localvars = __self.__vars;\n';
765
+ pushStack += '__self.__vars = new Map();\n';
766
+ pushStack += 'try {\n';
767
+ popStack += '} finally {\n';
768
+ popStack += indent + '// POP STACK\n';
769
+ popStack += indent + 'self.__vars = __localvars;\n';
770
+ popStack += '}\n';
760
771
  // 宣言済みの名前を保存
761
772
  const varsDeclared = Array.from(this.varsSet.names.values());
762
773
  let code = '';
@@ -836,7 +847,7 @@ export class NakoGen {
836
847
  const tof = (this.usedAsyncFn) ? topOfFunctionAsync : topOfFunction;
837
848
  // 関数コード全体を構築
838
849
  const lineInfo = ' ' + this.convLineno(node, true, 1) + '\n';
839
- code = tof + performanceMonitorInjectAtStart + variableDeclarations + lineInfo + code + popStack;
850
+ code = tof + performanceMonitorInjectAtStart + pushStack + variableDeclarations + lineInfo + code + popStack;
840
851
  code += endOfFunction;
841
852
  // 名前があれば、関数を登録する
842
853
  if (name) {
@@ -807,7 +807,8 @@ export class NakoGen {
807
807
  }
808
808
  let variableDeclarations = ''
809
809
  const indent = ' '
810
- const popStack = ''
810
+ let pushStack = ''
811
+ let popStack = ''
811
812
  const initialNames: Set<string> = new Set()
812
813
  if (this.speedMode.invalidSore === 0) {
813
814
  initialNames.add('それ')
@@ -817,8 +818,18 @@ export class NakoGen {
817
818
  this.varslistSet.push(this.varsSet)
818
819
  // JSの引数と引数をバインド
819
820
  variableDeclarations += indent + 'const 引数 = arguments;\n'
820
- // ローカル変数を生成
821
- variableDeclarations += indent + 'const __vars = new Map();\n'
821
+ // ローカル変数を生成 (再帰関数呼び出しで引数の値が壊れる問題がある #1663)
822
+ // 暫定変数__localVarsに現在のローカル変数の値をPUSHし、変数を抜ける時にPOPする)
823
+ // 関数として宣言しているが、JS関数となでしこ関数では変数管理の方法が異なるため、完全なローカル変数としては使えない
824
+ // 必ず、pushStack/popStack する必要がある
825
+ pushStack += '\n// PUSH STACK\n'
826
+ pushStack += 'const __localvars = __self.__vars;\n'
827
+ pushStack += '__self.__vars = new Map();\n'
828
+ pushStack += 'try {\n'
829
+ popStack += '} finally {\n'
830
+ popStack += indent + '// POP STACK\n'
831
+ popStack += indent + 'self.__vars = __localvars;\n'
832
+ popStack += '}\n'
822
833
  // 宣言済みの名前を保存
823
834
  const varsDeclared = Array.from(this.varsSet.names.values())
824
835
  let code = ''
@@ -895,7 +906,7 @@ export class NakoGen {
895
906
  const tof = (this.usedAsyncFn) ? topOfFunctionAsync : topOfFunction
896
907
  // 関数コード全体を構築
897
908
  const lineInfo = ' ' + this.convLineno(node, true, 1) + '\n'
898
- code = tof + performanceMonitorInjectAtStart + variableDeclarations + lineInfo + code + popStack
909
+ code = tof + performanceMonitorInjectAtStart + pushStack + variableDeclarations + lineInfo + code + popStack
899
910
  code += endOfFunction
900
911
 
901
912
  // 名前があれば、関数を登録する
@@ -160,4 +160,19 @@ describe('関数呼び出しテスト', async () => {
160
160
  'TMPを表示。\n'
161
161
  await cmp(code, '<<あいうえお>>')
162
162
  })
163
+ it('再帰呼び出しでローカル関数の引数が壊れる #1663', async () => {
164
+ const code = '' +
165
+ 'CHECK=0\n' +
166
+ '●(AとBで)AAAとは\n' +
167
+ '  もし、A<0ならば、0で戻る。\n' +
168
+ '  REC1=A\n' +
169
+ '  (A-1)と0でAAA\n' +
170
+ '  REC2=A\n' +
171
+ '  もし、REC1=REC2ならば、CHECK=1\n' + // 再帰呼び出ししても、引数Aの値は変わらないはず
172
+ '  (A+B)を戻す\n' +
173
+ 'ここまで\n' +
174
+ '4と0でAAA;\n' +
175
+ 'CHECKを表示\n'
176
+ await cmp(code, '1')
177
+ })
163
178
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nadesiko3",
3
- "version": "3.6.3",
3
+ "version": "3.6.4",
4
4
  "description": "Japanese Programming Language",
5
5
  "type": "module",
6
6
  "main": "src/index.mjs",