nadesiko3 3.7.2 → 3.7.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 (159) hide show
  1. package/batch/command.txt +472 -469
  2. package/batch/pickup_command.nako3 +1 -1
  3. package/core/.eslintrc.cjs +10 -3
  4. package/core/package-lock.json +1184 -645
  5. package/core/package.json +4 -5
  6. package/core/src/nako3.mjs +8 -6
  7. package/core/src/nako3.mts +19 -16
  8. package/core/src/nako_ast.mts +2 -3
  9. package/core/src/nako_core_version.mjs +2 -2
  10. package/core/src/nako_core_version.mts +2 -2
  11. package/core/src/nako_csv.mjs +1 -0
  12. package/core/src/nako_csv.mts +3 -2
  13. package/core/src/nako_from_dncl.mjs +1 -1
  14. package/core/src/nako_from_dncl.mts +1 -1
  15. package/core/src/nako_from_dncl2.mjs +1 -1
  16. package/core/src/nako_from_dncl2.mts +2 -2
  17. package/core/src/nako_gen.mjs +37 -35
  18. package/core/src/nako_gen.mts +70 -67
  19. package/core/src/nako_global.mjs +3 -2
  20. package/core/src/nako_global.mts +3 -2
  21. package/core/src/nako_lexer.mjs +3 -3
  22. package/core/src/nako_lexer.mts +3 -3
  23. package/core/src/nako_logger.mjs +1 -1
  24. package/core/src/nako_logger.mts +2 -2
  25. package/core/src/nako_parser3.mjs +67 -59
  26. package/core/src/nako_parser3.mts +96 -90
  27. package/core/src/nako_parser_base.mts +3 -3
  28. package/core/src/nako_prepare.mjs +1 -1
  29. package/core/src/nako_prepare.mts +1 -1
  30. package/core/src/nako_source_mapping.mts +0 -1
  31. package/core/src/nako_token.mts +8 -8
  32. package/core/src/nako_types.mts +1 -1
  33. package/core/src/plugin_api.mts +1 -1
  34. package/core/src/plugin_csv.mjs +1 -0
  35. package/core/src/plugin_csv.mts +2 -1
  36. package/core/src/plugin_math.mjs +2 -2
  37. package/core/src/plugin_math.mts +3 -3
  38. package/core/src/plugin_promise.mjs +1 -1
  39. package/core/src/plugin_promise.mts +1 -1
  40. package/core/src/plugin_system.mjs +117 -40
  41. package/core/src/plugin_system.mts +132 -58
  42. package/core/src/plugin_test.mjs +3 -1
  43. package/core/src/plugin_test.mts +3 -1
  44. package/core/test/basic_test.mjs +16 -0
  45. package/core/test/calc_test.mjs +7 -0
  46. package/core/test/plugin_system_test.mjs +33 -0
  47. package/doc/files.md +4 -4
  48. package/doc/plugins.md +1 -1
  49. package/package.json +9 -9
  50. package/release/_hash.txt +36 -121
  51. package/release/_script-tags.txt +16 -33
  52. package/release/command.json +1 -1
  53. package/release/command.json.js +1 -1
  54. package/release/command_cnako3.json +1 -1
  55. package/release/command_list.json +1 -1
  56. package/release/edit_main.js +3 -3
  57. package/release/edit_main.js.map +2 -2
  58. package/release/editor.js +3 -3
  59. package/release/plugin_markup.js +53 -53
  60. package/release/plugin_markup.js.map +3 -3
  61. package/release/plugin_weykturtle3d.js +1 -1
  62. package/release/plugin_weykturtle3d.js.map +4 -4
  63. package/release/version.js +3 -3
  64. package/release/version_main.js +3 -3
  65. package/release/version_main.js.map +2 -2
  66. package/release/wnako3.js +66 -66
  67. package/release/wnako3.js.map +3 -3
  68. package/release/wnako3webworker.js +58 -58
  69. package/release/wnako3webworker.js.map +3 -3
  70. package/src/browsers.txt +30 -20
  71. package/src/cnako3mod.mjs +19 -18
  72. package/src/cnako3mod.mts +17 -16
  73. package/src/deno_wrapper.mjs +6 -6
  74. package/src/deno_wrapper.mts +11 -11
  75. package/src/nako_version.mjs +2 -2
  76. package/src/nako_version.mts +2 -2
  77. package/src/plugin_browser.mjs +2 -2
  78. package/src/plugin_browser.mts +5 -5
  79. package/src/plugin_browser_ajax.mjs +2 -2
  80. package/src/plugin_browser_ajax.mts +2 -2
  81. package/src/plugin_browser_api.mts +0 -1
  82. package/src/plugin_browser_crypto.mjs +8 -8
  83. package/src/plugin_browser_crypto.mts +13 -13
  84. package/src/plugin_browser_dom_basic.mjs +3 -3
  85. package/src/plugin_browser_dom_basic.mts +5 -7
  86. package/src/plugin_browser_dom_event.mjs +1 -1
  87. package/src/plugin_browser_dom_event.mts +2 -1
  88. package/src/plugin_browser_dom_parts.mjs +33 -18
  89. package/src/plugin_browser_dom_parts.mts +60 -59
  90. package/src/plugin_browser_speech.mjs +1 -1
  91. package/src/plugin_browser_speech.mts +1 -1
  92. package/src/plugin_node.mjs +5 -3
  93. package/src/plugin_node.mts +6 -4
  94. package/src/plugin_weykturtle3d.mjs +38 -15
  95. package/src/plugin_weykturtle3d.mts +279 -240
  96. package/src/plugin_weykturtle3d_three.mjs +3 -0
  97. package/src/plugin_weykturtle3d_three.mts +214 -0
  98. package/src/plugin_weykturtle3d_threeutil.mjs +28 -0
  99. package/src/plugin_weykturtle3d_threeutil.mts +31 -0
  100. package/src/wnako3.mjs +1 -0
  101. package/src/wnako3.mts +1 -0
  102. package/src/wnako3mod.mjs +5 -2
  103. package/src/wnako3mod.mts +6 -3
  104. package/batch/command_nakopad.txt +0 -1177
  105. package/core/__report.txt +0 -617
  106. package/core/command/plugin_snako.mjs +0 -112
  107. package/core/command/snako.mjs +0 -108
  108. package/release/core_src_nako_josi_list_mjs.js +0 -3
  109. package/release/core_src_nako_josi_list_mjs.js.LICENSE.txt +0 -3
  110. package/release/core_src_nako_josi_list_mjs.js.map +0 -1
  111. package/release/core_src_nako_reserved_words_mjs.js +0 -3
  112. package/release/core_src_nako_reserved_words_mjs.js.LICENSE.txt +0 -3
  113. package/release/core_src_nako_reserved_words_mjs.js.map +0 -1
  114. package/release/editor/edit_main.js +0 -48
  115. package/release/editor/edit_main.js.map +0 -7
  116. package/release/editor/version_main.js +0 -44
  117. package/release/editor/version_main.js.map +0 -7
  118. package/release/editor.js.LICENSE.txt +0 -91
  119. package/release/editor.js.map +0 -1
  120. package/release/nako_gen_async.js +0 -2
  121. package/release/nako_gen_async.js.LICENSE.txt +0 -21
  122. package/release/nako_gen_async.js.map +0 -1
  123. package/release/plugin_caniuse.js.LICENSE.txt +0 -15
  124. package/release/plugin_datetime.js.LICENSE.txt +0 -21
  125. package/release/plugin_kansuji.js.LICENSE.txt +0 -3
  126. package/release/plugin_markup.js.LICENSE.txt +0 -15
  127. package/release/plugin_toml.js +0 -295
  128. package/release/plugin_toml.js.map +0 -7
  129. package/release/plugin_turtle.js.LICENSE.txt +0 -9
  130. package/release/plugin_webworker.js.LICENSE.txt +0 -3
  131. package/release/plugin_weykturtle3d.js.LICENSE.txt +0 -3
  132. package/release/src/plugin_caniuse.js +0 -2
  133. package/release/src/plugin_caniuse.js.map +0 -7
  134. package/release/src/plugin_datetime.js +0 -2
  135. package/release/src/plugin_datetime.js.map +0 -7
  136. package/release/src/plugin_kansuji.js +0 -2
  137. package/release/src/plugin_kansuji.js.map +0 -7
  138. package/release/src/plugin_keigo.js +0 -2
  139. package/release/src/plugin_keigo.js.map +0 -7
  140. package/release/src/plugin_markup.js +0 -64
  141. package/release/src/plugin_markup.js.map +0 -7
  142. package/release/src/plugin_three.js +0 -2
  143. package/release/src/plugin_three.js.map +0 -7
  144. package/release/src/plugin_turtle.js +0 -2
  145. package/release/src/plugin_turtle.js.map +0 -7
  146. package/release/src/plugin_webworker.js +0 -4
  147. package/release/src/plugin_webworker.js.map +0 -7
  148. package/release/src/plugin_weykturtle3d.js +0 -2
  149. package/release/src/plugin_weykturtle3d.js.map +0 -7
  150. package/release/src/wnako3.js +0 -482
  151. package/release/src/wnako3.js.map +0 -7
  152. package/release/src/wnako3webworker.js +0 -428
  153. package/release/src/wnako3webworker.js.map +0 -7
  154. package/release/stats.json +0 -1
  155. package/release/version.js.LICENSE.txt +0 -65
  156. package/release/version.js.map +0 -1
  157. package/release/wnako3.js.LICENSE.txt +0 -341
  158. package/release/wnako3webworker.js.LICENSE.txt +0 -209
  159. package/src/plugin_three.mts +0 -240
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/restrict-template-expressions */
1
2
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
3
  /**
3
4
  * パーサーが生成した中間オブジェクトを実際のJavaScriptのコードに変換する。
@@ -281,7 +282,7 @@ export class NakoGen {
281
282
  * @param {string} name
282
283
  * @param {string} jsvalue
283
284
  */
284
- varname_set_sys(name: string, jsvalue: string): string {
285
+ varname_set_sys (name: string, jsvalue: string): string {
285
286
  return `__self.__setSysVar(${JSON.stringify(name)}, (${jsvalue}))`
286
287
  }
287
288
 
@@ -303,11 +304,12 @@ export class NakoGen {
303
304
 
304
305
  /** @param {Ast} node */
305
306
  static convPrint (node: Ast): string {
307
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
306
308
  return `__print(${node});`
307
309
  }
308
310
 
309
311
  /** @param {AstStrValue} node */
310
- convRequire(node: AstStrValue): string {
312
+ convRequire (node: AstStrValue): string {
311
313
  const moduleName = node.value
312
314
  return this.convLineno(node, false) +
313
315
  `__module['${moduleName}'] = require('${moduleName}');\n`
@@ -335,7 +337,7 @@ export class NakoGen {
335
337
  code += 'const __line = (lineno) => { __self.__v0.set(\'__line\', lineno); }\n'
336
338
  code += '__v0.set(\'__line\', \'l0:__getDefFuncCode\');\n'
337
339
  code += '__v0.set(\'__forceClose\', false);\n'
338
- code += `__v0.set('__useDebug', ${this.debugOption.useDebug});\n`
340
+ code += `__v0.set('__useDebug', ${String(this.debugOption.useDebug)});\n`
339
341
  // 定数を埋め込む
340
342
  code += '__self.constPools = ' + JSON.stringify(this.constPools) + ';\n'
341
343
  code += '__self.constPoolsTemplate = ' + JSON.stringify(this.constPoolsTemplate) + ';\n'
@@ -358,7 +360,7 @@ export class NakoGen {
358
360
  let testCode = 'const __tests = [];\n'
359
361
  this.nakoTestFuncs.forEach((value) => {
360
362
  const f = value.fn
361
- testCode += `${f};\n`
363
+ testCode += `${String(f)};\n`
362
364
  })
363
365
  if (testCode !== '') {
364
366
  code += '__v0.set(\'__line\', \'テストの定義\');\n'
@@ -423,7 +425,7 @@ export class NakoGen {
423
425
 
424
426
  /** 関数一覧 */
425
427
  const funcList: {name: string; node:Ast}[] = []
426
-
428
+
427
429
  // なでしこ関数を定義して this.nako_func[name] に定義する
428
430
  const registFunc = (t: AstDefFunc) => {
429
431
  // (t.type == 'def_func') はチェック済み
@@ -440,7 +442,7 @@ export class NakoGen {
440
442
  // eslint-disable-next-line @typescript-eslint/no-empty-function
441
443
  fn: () => {},
442
444
  type: 'func',
443
- asyncFn: t.asyncFn ? true : false,
445
+ asyncFn: !!t.asyncFn,
444
446
  isExport: t.isExport
445
447
  })
446
448
  funcList.push({ name, node: t })
@@ -450,7 +452,7 @@ export class NakoGen {
450
452
  if ((ast as AstBlocks).blocks) {
451
453
  // 各ブロックをくまなく巡回チェック
452
454
  for (const t of (ast as AstBlocks).blocks) {
453
- if (t.type == 'def_func') { // 関数定義
455
+ if (t.type === 'def_func') { // 関数定義
454
456
  registFunc(t as AstDefFunc)
455
457
  } else {
456
458
  registFuncs(t)
@@ -500,7 +502,7 @@ export class NakoGen {
500
502
  }
501
503
  if (node === null) { return 'null' }
502
504
  if (node === undefined) { return 'undefined' }
503
- if (typeof (node) !== 'object') { return '' + node }
505
+ if (typeof (node) !== 'object') { return '' + String(node) }
504
506
  // switch
505
507
  switch (node.type) {
506
508
  case 'nop':
@@ -563,7 +565,7 @@ export class NakoGen {
563
565
  code += this.convRenbun(node as AstOperator)
564
566
  break
565
567
  case 'not':
566
- code += '((' + this._convGen((node as AstBlocks).blocks[0] as Ast, true) + ')?false:true)'
568
+ code += '((' + this._convGen((node as AstBlocks).blocks[0], true) + ')?false:true)'
567
569
  break
568
570
  case 'func':
569
571
  case 'func_pointer':
@@ -661,7 +663,7 @@ export class NakoGen {
661
663
  name,
662
664
  isTop: false,
663
665
  js: `__self.__varslist[${i}].get(${JSON.stringify(name)})`,
664
- js_set: `__self.__varslist[${i}].set(${JSON.stringify(name)}, ${jsvalue})`
666
+ js_set: `__self.__varslist[${i}].set(${JSON.stringify(name)}, ${jsvalue ?? 'undefined'})`
665
667
  }
666
668
  }
667
669
  }
@@ -698,7 +700,7 @@ export class NakoGen {
698
700
  // システム関数・変数の場合
699
701
  if (i === 0) {
700
702
  const pv = this.__self.getNakoFunc(name)
701
- if (!pv) { return `${res.js}/*[link_error]l${lno}:${position.file}*/` }
703
+ if (!pv) { return `${res.js}/*[link_error]l${lno}:${position.file ?? 'unknown'}*/` }
702
704
  if (pv.type === 'const' || pv.type === 'var') { return res.js }
703
705
  if (pv.type === 'func') {
704
706
  if (!pv.josi || pv.josi.length === 0) { return `(${res.js}())` }
@@ -710,7 +712,7 @@ export class NakoGen {
710
712
  return res.js
711
713
  }
712
714
 
713
- convGetVar(node: AstStrValue): string {
715
+ convGetVar (node: AstStrValue): string {
714
716
  // 変数名を得る
715
717
  const name = node.value
716
718
  // 変数を取得するコードを生成
@@ -757,7 +759,7 @@ export class NakoGen {
757
759
 
758
760
  const astValue = node.blocks[0]
759
761
  const lno = this.convLineno(node, false)
760
-
762
+
761
763
  // 戻り値のコードを得る
762
764
  let value = ''
763
765
  if (astValue.type !== 'nop') {
@@ -765,7 +767,7 @@ export class NakoGen {
765
767
  } else if (this.speedMode.invalidSore === 0) {
766
768
  value = this.varname_get('それ')
767
769
  }
768
-
770
+
769
771
  // 戻り値のない関数の場合
770
772
  if (value === '') {
771
773
  return lno + 'return;'
@@ -792,15 +794,15 @@ export class NakoGen {
792
794
 
793
795
  addConstPool (msg: string, args: string[], file: any, line: any): number {
794
796
  // file
795
- file = '' + file
797
+ file = String(file)
796
798
  const fileNo = this.getConstPoolsTemplateId(file)
797
799
  // msg
798
800
  const msgNo = this.getConstPoolsTemplateId(msg)
799
801
  // args
800
802
  const args2: number[] = []
801
- for (const i in args) {
802
- const arg = '' + args[i]
803
- const argNo = this.getConstPoolsTemplateId(arg)
803
+ for (const arg of args) {
804
+ const argStr = '' + String(arg)
805
+ const argNo = this.getConstPoolsTemplateId(argStr)
804
806
  args2.push(argNo)
805
807
  }
806
808
  const poolIndex = this.constPools.length
@@ -817,7 +819,7 @@ export class NakoGen {
817
819
  return this.convLineno(node) + cmd + ';'
818
820
  }
819
821
 
820
- convDefFuncCommon(node: AstDefFunc, name: string): string {
822
+ convDefFuncCommon (node: AstDefFunc, name: string): string {
821
823
  // 定義中の関数名を記録
822
824
  this.defFuncName = name
823
825
  // 変数をJS変数に展開するかどうか (TODO)
@@ -869,7 +871,7 @@ export class NakoGen {
869
871
  } else {
870
872
  variableDeclarations += indent + '__self.__vars.set(\'引数\', arguments);\n'
871
873
  }
872
-
874
+
873
875
  // ローカル変数を生成 (再帰関数呼び出しで引数の値が壊れる問題があるので修正 #1663 / タイミングによって壊れるので修理 #1758)
874
876
  // 暫定変数__localVarsに現在のローカル変数の値をPUSHし、変数を抜ける時にPOPする)
875
877
  // 関数として宣言しているが、JS関数となでしこ関数では変数管理の方法が異なるため、完全なローカル変数としては使えない
@@ -889,7 +891,7 @@ export class NakoGen {
889
891
  // 引数をローカル変数に設定
890
892
  const meta: FuncListItem|undefined = node.meta
891
893
  if (!meta) { throw new Error('[System Error] 関数の定義でメタ情報が指定されていません') }
892
- if (!meta.varnames) { meta.varnames = []}
894
+ if (!meta.varnames) { meta.varnames = [] }
893
895
  for (let i = 0; i < meta.varnames.length; i++) {
894
896
  const word = meta.varnames[i]
895
897
  if (word === '引数') { continue }
@@ -938,7 +940,7 @@ export class NakoGen {
938
940
  }
939
941
  // パフォーマンスモニタ:ユーザ関数のinject
940
942
  code += performanceMonitorInjectAtEnd
941
-
943
+
942
944
  // 名前のある関数で非同期関数であれば、関数にasyncを付与する
943
945
  if (name && this.usedAsyncFn) {
944
946
  const f = this.nakoFuncList.get(name)
@@ -993,7 +995,7 @@ export class NakoGen {
993
995
  let code = `__tests.push({ name: '${name}', f: () => {\n`
994
996
 
995
997
  // ブロックを解析
996
- const block = this._convGen(node.blocks[0] as Ast, false)
998
+ const block = this._convGen(node.blocks[0], false)
997
999
 
998
1000
  code += ` ${block}\n` +
999
1001
  '}});'
@@ -1064,7 +1066,7 @@ export class NakoGen {
1064
1066
  const list: Ast[] | undefined = node.index
1065
1067
  if (!list) { return code }
1066
1068
  for (let i = 0; i < list.length; i++) {
1067
- const idx = this._convGen(list[i] as Ast, true)
1069
+ const idx = this._convGen(list[i], true)
1068
1070
  code += '[' + idx + ']'
1069
1071
  }
1070
1072
  return code
@@ -1174,7 +1176,7 @@ export class NakoGen {
1174
1176
  `const ${varFrom} = ${kara};\n` +
1175
1177
  `const ${varTo} = ${made};\n` +
1176
1178
  `if (${varFrom} <= ${varTo}) { // up\n` +
1177
- ` if (${flagUp}) {` +
1179
+ ` if (${String(flagUp)}) {` +
1178
1180
  ` for (let ${varI} = ${varFrom}; ${varI} <= ${varTo}; ${varI}+= ${inc}) {\n` +
1179
1181
  ` ${sorePrefex};${loopVarSetter}\n` +
1180
1182
  ' // for block begin\n' +
@@ -1183,7 +1185,7 @@ export class NakoGen {
1183
1185
  ' };\n' +
1184
1186
  ' };\n' +
1185
1187
  '} else { // down\n' +
1186
- ` if (${flagDown}) {` +
1188
+ ` if (${String(flagDown)}) {` +
1187
1189
  ` for (let ${varI} = ${varFrom}; ${varI} >= ${varTo}; ${varI}-= ${inc}) {\n` +
1188
1190
  ` ${sorePrefex};${loopVarSetter}\n` +
1189
1191
  ' // for block begin\n' +
@@ -1209,7 +1211,7 @@ export class NakoGen {
1209
1211
  const soreTemp = `$nako_foreach_sore_temp${id}`
1210
1212
 
1211
1213
  // 「対象」「対象キー」を取得 --- blockより早く変数を定義する必要がある
1212
- let taisyoPrefex = this.varname_set_sys('対象', loopValueVar);
1214
+ let taisyoPrefex = this.varname_set_sys('対象', loopValueVar)
1213
1215
  if (node.word !== '') { // 対象変数がある場合、対象は設定されない
1214
1216
  const valueVar = node.word
1215
1217
  this.varsSet.names.add(valueVar)
@@ -1367,7 +1369,7 @@ export class NakoGen {
1367
1369
  return code
1368
1370
  }
1369
1371
 
1370
- convAtohantei(node: AstAtohantei): string {
1372
+ convAtohantei (node: AstAtohantei): string {
1371
1373
  const id = this.loopId++
1372
1374
  const varId = `$nako_i${id}`
1373
1375
  const cond = this._convGen(node.blocks[0], true)
@@ -1394,13 +1396,13 @@ export class NakoGen {
1394
1396
  ' break\n'
1395
1397
  }
1396
1398
  const code =
1397
- '// [switch]\n' +
1399
+ '// [switch]\n' +
1398
1400
  `switch (${expr})` + '{\n' +
1399
1401
  `${body}` + '\n' +
1400
1402
  ' default:\n' +
1401
1403
  ` ${defaultStr}\n` +
1402
1404
  '}\n' +
1403
- '// [/switch]\n'
1405
+ '// [/switch]\n'
1404
1406
  return this.convLineno(node, false) + code
1405
1407
  }
1406
1408
 
@@ -1430,10 +1432,10 @@ export class NakoGen {
1430
1432
  return code
1431
1433
  }
1432
1434
 
1433
- convFuncGetArgsCalcType(_funcName: string, _func: any, node: AstCallFunc): [any, any] {
1435
+ convFuncGetArgsCalcType (_funcName: string, _func: any, node: AstCallFunc): [any, any] {
1434
1436
  const args = []
1435
1437
  const opts: {[key: string]: boolean} = {}
1436
- const nodeArgs = (node.blocks) ? node.blocks : []
1438
+ const nodeArgs = (node.blocks) ? node.blocks : []
1437
1439
  for (let i = 0; i < nodeArgs.length; i++) {
1438
1440
  const arg = nodeArgs[i]
1439
1441
  if (i === 0 && arg === null && this.speedMode.invalidSore === 0) {
@@ -1441,8 +1443,8 @@ export class NakoGen {
1441
1443
  opts.sore = true
1442
1444
  } else {
1443
1445
  let argCode = this._convGen(arg, true)
1444
- if (argCode === "") { argCode = 'undefined' }
1445
- if (typeof argCode !== 'string') { argCode = "undefined"; }
1446
+ if (argCode === '') { argCode = 'undefined' }
1447
+ if (typeof argCode !== 'string') { argCode = 'undefined' }
1446
1448
  args.push(`/*arg${i}*/${argCode}`)
1447
1449
  }
1448
1450
  }
@@ -1462,7 +1464,7 @@ export class NakoGen {
1462
1464
  * @returns string コード
1463
1465
  */
1464
1466
  convCallFunc (node: AstCallFunc, isExpression: boolean): string {
1465
- const funcName = NakoGen.getFuncName(node.name as string)
1467
+ const funcName = NakoGen.getFuncName(node.name)
1466
1468
  const res = this.findVar(funcName)
1467
1469
  if (res === null) {
1468
1470
  throw NakoSyntaxError.fromNode(`関数『${funcName}』が見当たりません。有効プラグイン=[` + this.getPluginList().join(', ') + ']', node)
@@ -1478,7 +1480,7 @@ export class NakoGen {
1478
1480
  } else {
1479
1481
  func = this.nakoFuncList.get(funcName)
1480
1482
  // 無名関数の可能性
1481
- if (func === undefined) { func = { return_none: false, asyncFn: node.asyncFn ? true : false } }
1483
+ if (func === undefined) { func = { return_none: false, asyncFn: !!node.asyncFn } }
1482
1484
  }
1483
1485
  // 関数の参照渡しか?
1484
1486
  if (node.type === 'func_pointer') {
@@ -1487,7 +1489,7 @@ export class NakoGen {
1487
1489
 
1488
1490
  // 関数の参照渡しでない場合
1489
1491
  // 関数定義より助詞を一つずつ調べる
1490
- const argsInfo = this.convFuncGetArgsCalcType(funcName, func, node as AstCallFunc)
1492
+ const argsInfo = this.convFuncGetArgsCalcType(funcName, func, node)
1491
1493
  const args = argsInfo[0]
1492
1494
  const argsOpts = argsInfo[1]
1493
1495
  // function
@@ -1692,15 +1694,15 @@ export class NakoGen {
1692
1694
  return code
1693
1695
  }
1694
1696
 
1695
- convRenbun(node: AstOperator): string {
1696
- const right = this._convGen(node.blocks[1] as Ast, true)
1697
- const left = this._convGen(node.blocks[0] as Ast, false)
1697
+ convRenbun (node: AstOperator): string {
1698
+ const right = this._convGen(node.blocks[1], true)
1699
+ const left = this._convGen(node.blocks[0], false)
1698
1700
  this.numAsyncFn++
1699
1701
  this.usedAsyncFn = true
1700
1702
  return `/*[連文]*/await (async function(){ ${left}; return ${right} }).call(this)/*[/連文]*/`
1701
1703
  }
1702
1704
 
1703
- convOp(node: AstOperator): string {
1705
+ convOp (node: AstOperator): string {
1704
1706
  // トークン名からJS演算子への変換 - 単純な変換が可能なものをここで定義
1705
1707
  const OP_TBL: {[key: string]: string} = {
1706
1708
  '&': '+""+',
@@ -1723,7 +1725,7 @@ export class NakoGen {
1723
1725
  let right = this._convGen(node.blocks[1], true)
1724
1726
  let left = this._convGen(node.blocks[0], true)
1725
1727
  if (op === '+' && this.speedMode.implicitTypeCasting === 0) {
1726
- if (node.blocks[0] && (node.blocks[0]).type !== 'number' && (node.blocks[0] as Ast).type !== 'bigint') {
1728
+ if (node.blocks[0] && (node.blocks[0]).type !== 'number' && (node.blocks[0]).type !== 'bigint') {
1727
1729
  left = `self.__parseFloatOrBigint(${left})`
1728
1730
  }
1729
1731
  if (node.blocks[1] && (node.blocks[1]).type !== 'number' && (node.blocks[1]).type !== 'bigint') {
@@ -1745,13 +1747,13 @@ export class NakoGen {
1745
1747
  // idを得る
1746
1748
  const id = this.loopId++
1747
1749
  const valueVar = `$nako_v${id}`
1748
-
1750
+
1749
1751
  // もし値が省略されていたら、変数「それ」に代入する
1750
1752
  let incValue = '1'
1751
1753
  if (this.speedMode.invalidSore === 0) { incValue = this.varname_get('それ') }
1752
1754
  const astValue = node.blocks[0]
1753
1755
  if (astValue.type !== 'nop') { incValue = this._convGen(astValue, true) }
1754
-
1756
+
1755
1757
  // 配列への代入か(core#86)
1756
1758
  let code = ''
1757
1759
  let varGetter = ''
@@ -1830,9 +1832,9 @@ export class NakoGen {
1830
1832
  }
1831
1833
 
1832
1834
  // プロパティへの代入式 (#1793)
1833
- convLetProp(node: AstLet): string {
1834
- if (!node.index || node.index.length == 0) { throw NakoSyntaxError.fromNode('代入する先のプロパティ名がありません。', node) }
1835
- if (!node.blocks || node.blocks.length == 0) { throw NakoSyntaxError.fromNode('代入する値がありません。', node) }
1835
+ convLetProp (node: AstLet): string {
1836
+ if (!node.index || node.index.length === 0) { throw NakoSyntaxError.fromNode('代入する先のプロパティ名がありません。', node) }
1837
+ if (!node.blocks || node.blocks.length === 0) { throw NakoSyntaxError.fromNode('代入する値がありません。', node) }
1836
1838
  const propList = node.index as AstStrValue[]
1837
1839
  const propTopAst = propList.pop()
1838
1840
  if (propTopAst === undefined) { throw NakoSyntaxError.fromNode('代入する先のプロパティ名がありません。', node) }
@@ -1872,8 +1874,9 @@ export class NakoGen {
1872
1874
  code += `${nameJs}['${propTop}'] = ${value} }};`
1873
1875
  return ';' + this.convLineno(node, false) + code + '\n'
1874
1876
  }
1877
+
1875
1878
  // プロパティへの参照 (#1793)
1876
- convRefProp(node: Ast): string {
1879
+ convRefProp (node: Ast): string {
1877
1880
  const name = this._convGen(node.name as Ast, true)
1878
1881
  const list: Ast[] | undefined = node.index
1879
1882
  if (!list || list.length <= 0) {
@@ -1883,13 +1886,13 @@ export class NakoGen {
1883
1886
  const propList = list as AstStrValue[]
1884
1887
  if (propList.length <= 1) {
1885
1888
  const propKey = propList[0].value
1886
- const code_call = `${name}.__getProp('${propKey}', __self)`
1887
- const code_prop = `${name}['${propKey}']`
1888
- const code_checkAccessor = `__self.__checkPropAccessor('get', ${name});\n` +
1889
- `if (typeof ${name}.__getProp === 'function') { return ${code_call} }\n` +
1890
- `return ${code_prop}\n`
1891
- const code_if = `if (${name}.__getProp) { return ${code_call} } else { ${code_checkAccessor} }`
1892
- code = `( (()=>{ ${code_if} })() )`
1889
+ const codeCall = `${name}.__getProp('${propKey}', __self)`
1890
+ const codeProp = `${name}['${propKey}']`
1891
+ const codeCheckAccessor = `__self.__checkPropAccessor('get', ${name});\n` +
1892
+ `if (typeof ${name}.__getProp === 'function') { return ${codeCall} }\n` +
1893
+ `return ${codeProp}\n`
1894
+ const codeIf = `if (${name}.__getProp) { return ${codeCall} } else { ${codeCheckAccessor} }`
1895
+ code = `( (()=>{ ${codeIf} })() )`
1893
1896
  } else {
1894
1897
  const arrs = []
1895
1898
  const keys = []
@@ -1900,24 +1903,24 @@ export class NakoGen {
1900
1903
  }
1901
1904
  const keyStr = keys.join('')
1902
1905
  const arrStr = '[' + arrs.join(',') + ']'
1903
- const code_call = `${name}.__getProp(${arrStr}, __self)`
1904
- const code_prop = `${name}${keyStr}`
1905
- const code_checkAccessor = `__self.__checkPropAccessor('get', ${name});\n` +
1906
- `if (${name}.__getProp) { return ${code_call} }\n` +
1907
- `return ${code_prop}\n`
1908
- const code_if = `if (${name}.__getProp) { return ${code_call} } else { ${code_checkAccessor} }`
1909
- code = `( (()=>{ ${code_if} })() )`
1906
+ const codeCall = `${name}.__getProp(${arrStr}, __self)`
1907
+ const codeProp = `${name}${keyStr}`
1908
+ const codeCheckAccessor = `__self.__checkPropAccessor('get', ${name});\n` +
1909
+ `if (${name}.__getProp) { return ${codeCall} }\n` +
1910
+ `return ${codeProp}\n`
1911
+ const codeIf = `if (${name}.__getProp) { return ${codeCall} } else { ${codeCheckAccessor} }`
1912
+ code = `( (()=>{ ${codeIf} })() )`
1910
1913
  }
1911
1914
  return code
1912
1915
  }
1913
1916
 
1914
- convDefLocalVar(node: AstDefVar): string {
1917
+ convDefLocalVar (node: AstDefVar): string {
1915
1918
  const astValue = node.blocks[0]
1916
1919
  let value = '0'
1917
1920
  if (astValue.type !== 'nop') {
1918
1921
  value = this._convGen(astValue, true)
1919
1922
  }
1920
- const name = node.name as string // 変数名
1923
+ const name = node.name // 変数名
1921
1924
  const vtype = node.vartype // 変数 or 定数
1922
1925
  // 二重定義?
1923
1926
  if (this.varsSet.names.has(name)) { throw NakoSyntaxError.fromNode(`${vtype}『${name}』の二重定義はできません。`, node) }
@@ -1932,7 +1935,7 @@ export class NakoGen {
1932
1935
  }
1933
1936
 
1934
1937
  // #563 複数変数への代入
1935
- convDefLocalVarlist(node: AstDefVarList): string {
1938
+ convDefLocalVarlist (node: AstDefVarList): string {
1936
1939
  let code = ''
1937
1940
  const vtype = node.vartype // 変数 or 定数
1938
1941
  // 初期値を取得
@@ -1970,7 +1973,7 @@ export class NakoGen {
1970
1973
  }
1971
1974
 
1972
1975
  convString (node: AstConst): string {
1973
- let value = '' + node.value
1976
+ let value = String(node.value)
1974
1977
  value = value.replace(/\\/g, '\\\\')
1975
1978
  value = value.replace(/"/g, '\\"')
1976
1979
  value = value.replace(/\r/g, '\\r')
@@ -2129,7 +2132,7 @@ export function generateJS (com: NakoCompiler, ast: Ast, opt: NakoGenOptions): N
2129
2132
  const jsInit = gen.getDefFuncCode(com, opt)
2130
2133
 
2131
2134
  // ランダムな関数名を生成
2132
- const funcID = '' + (new Date()).getTime() + '_' + Math.floor(0xFFFFFFFF * Math.random())
2135
+ const funcID = String((new Date()).getTime()) + '_' + Math.floor(0xFFFFFFFF * Math.random()).toString()
2133
2136
  // テストの実行
2134
2137
  if (js && opt.isTest) {
2135
2138
  js += '\n__self._runTests(__tests);\n'
@@ -93,7 +93,8 @@ export class NakoGlobal {
93
93
  pass++;
94
94
  }
95
95
  catch (err) {
96
- text += `${NakoColors.color.red}☓${NakoColors.color.reset} ${t.name}: ${err.message}\n`;
96
+ const errorMessage = (err instanceof Error) ? err.message : String(err);
97
+ text += `${NakoColors.color.red}☓${NakoColors.color.reset} ${t.name}: ${errorMessage}\n`;
97
98
  numFailures++;
98
99
  }
99
100
  }
@@ -120,7 +121,7 @@ export class NakoGlobal {
120
121
  po[clearName].fn(this);
121
122
  }
122
123
  catch (e) {
123
- this.logger.error(`プラグイン『${pname}』のクリア関数でエラーが発生しました:` + e.message);
124
+ this.logger.error(`プラグイン『${pname}』のクリア関数でエラーが発生しました:` + String(e.message));
124
125
  }
125
126
  }
126
127
  }
@@ -129,7 +129,8 @@ export class NakoGlobal {
129
129
  text += `${NakoColors.color.green}✔${NakoColors.color.reset} ${t.name}\n`
130
130
  pass++
131
131
  } catch (err: any) {
132
- text += `${NakoColors.color.red}☓${NakoColors.color.reset} ${t.name}: ${err.message}\n`
132
+ const errorMessage = (err instanceof Error) ? err.message : String(err)
133
+ text += `${NakoColors.color.red}☓${NakoColors.color.reset} ${t.name}: ${errorMessage}\n`
133
134
  numFailures++
134
135
  }
135
136
  }
@@ -155,7 +156,7 @@ export class NakoGlobal {
155
156
  try {
156
157
  po[clearName].fn(this)
157
158
  } catch (e: any) {
158
- this.logger.error(`プラグイン『${pname}』のクリア関数でエラーが発生しました:` + e.message)
159
+ this.logger.error(`プラグイン『${pname}』のクリア関数でエラーが発生しました:` + String(e.message))
159
160
  }
160
161
  }
161
162
  }
@@ -265,7 +265,7 @@ export class NakoLexer {
265
265
  isExport = true;
266
266
  }
267
267
  else {
268
- logger.warn(`不明な関数属性『${attr}』が指定されています。`);
268
+ logger.warn(`不明な関数属性『${String(attr)}』が指定されています。`);
269
269
  }
270
270
  i++;
271
271
  if (tokens[i] && tokens[i].type === '}') {
@@ -367,7 +367,7 @@ export class NakoLexer {
367
367
  // 関数を強制的に置換( word => func )
368
368
  if (t.type === 'word' && t.value !== 'それ') {
369
369
  // 関数を変換
370
- const funcName = t.value;
370
+ const funcName = String(t.value);
371
371
  if (funcName.indexOf('__') < 0) {
372
372
  // 自身のモジュール名を検索
373
373
  const gname1 = `${modSelf}__${funcName}`;
@@ -437,7 +437,7 @@ export class NakoLexer {
437
437
  tokens[i].value *= -1;
438
438
  }
439
439
  else {
440
- tokens[i].value = '-' + tokens[i].value;
440
+ tokens[i].value = '-' + String(tokens[i].value);
441
441
  }
442
442
  }
443
443
  }
@@ -251,7 +251,7 @@ export class NakoLexer {
251
251
  if (tokens[i] && tokens[i].type === '{') {
252
252
  i++
253
253
  const attr = tokens[i] && tokens[i].type === 'word' ? tokens[i].value : ''
254
- if (attr === '公開') { isExport = true } else if (attr === '非公開') { isExport = false } else if (attr === 'エクスポート') { isExport = true } else { logger.warn(`不明な関数属性『${attr}』が指定されています。`) }
254
+ if (attr === '公開') { isExport = true } else if (attr === '非公開') { isExport = false } else if (attr === 'エクスポート') { isExport = true } else { logger.warn(`不明な関数属性『${String(attr)}』が指定されています。`) }
255
255
  i++
256
256
  if (tokens[i] && tokens[i].type === '}') { i++ }
257
257
  }
@@ -361,7 +361,7 @@ export class NakoLexer {
361
361
  // 関数を強制的に置換( word => func )
362
362
  if (t.type === 'word' && t.value !== 'それ') {
363
363
  // 関数を変換
364
- const funcName = t.value
364
+ const funcName = String(t.value)
365
365
  if (funcName.indexOf('__') < 0) {
366
366
  // 自身のモジュール名を検索
367
367
  const gname1 = `${modSelf}__${funcName}`
@@ -430,7 +430,7 @@ export class NakoLexer {
430
430
  if (tokenType === 'number') {
431
431
  tokens[i].value *= -1
432
432
  } else {
433
- tokens[i].value = '-' + tokens[i].value
433
+ tokens[i].value = '-' + String(tokens[i].value)
434
434
  }
435
435
  }
436
436
  }
@@ -192,7 +192,7 @@ export class NakoLogger {
192
192
  const data = makeData();
193
193
  this.logs += data.noColor + '\n';
194
194
  if (position && this.position !== null) {
195
- this.position = `l${position.line}:${position.file}`;
195
+ this.position = `l${position.line}:${position.file || 'unknown'}`;
196
196
  }
197
197
  }
198
198
  // 登録したリスナーに通知する
@@ -159,7 +159,7 @@ export class NakoLogger {
159
159
  case 'NakoRuntimeError':
160
160
  case 'NakoError':
161
161
  if (message instanceof NakoError) {
162
- const e: NakoError = message as NakoError
162
+ const e: NakoError = message
163
163
  let pos: any = position
164
164
  if (pos === null || pos === undefined) {
165
165
  pos = { file: e.file, line: e.line || 0, startOffset: 0, endOffset: 0 }
@@ -225,7 +225,7 @@ export class NakoLogger {
225
225
  const data = makeData()
226
226
  this.logs += data.noColor + '\n'
227
227
  if (position && this.position !== null) {
228
- this.position = `l${position.line}:${position.file}`
228
+ this.position = `l${position.line}:${position.file || 'unknown'}`
229
229
  }
230
230
  }
231
231
  // 登録したリスナーに通知する