nadesiko3 3.2.46 → 3.2.47

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.
package/src/nako_gen.js CHANGED
@@ -45,9 +45,18 @@ class NakoGen {
45
45
  canAsync = (ua.indexOf('MSIE') === -1)
46
46
  }
47
47
  if (canAsync) {
48
- js = '// <nadesiko3::gen::async>\n' +
49
- `(async () => {\n${js}\n})();\n` +
50
- '// </nadesiko3::gen::async>\n'
48
+ js = `
49
+ // <nadesiko3::gen::async>
50
+ (async () => { // async::main
51
+ ${js}
52
+ }).call(this).catch(err => {
53
+ if (!(err instanceof this.NakoRuntimeError)) {
54
+ err = new this.NakoRuntimeError(err, this.__varslist[0].line);
55
+ }
56
+ this.logger.error(err);
57
+ throw err;
58
+ }); // async::main
59
+ // <nadesiko3::gen::async>\n`
51
60
  }
52
61
  }
53
62
 
@@ -1218,7 +1227,7 @@ try {
1218
1227
 
1219
1228
  // 関数呼び出しで、引数の末尾にthisを追加する-システム情報を参照するため
1220
1229
  args.push('__self')
1221
- const funcDef = 'function'
1230
+ let funcDef = 'function'
1222
1231
  let funcBegin = ''
1223
1232
  let funcEnd = ''
1224
1233
  // setter?
@@ -1292,6 +1301,7 @@ try {
1292
1301
 
1293
1302
  let funcCall = `${res.js}(${argsCode})`
1294
1303
  if (func.asyncFn) {
1304
+ funcDef = `async ${funcDef}`
1295
1305
  funcCall = `await ${funcCall}`
1296
1306
  this.numAsyncFn++
1297
1307
  }
@@ -1325,6 +1335,7 @@ try {
1325
1335
 
1326
1336
  let code = ''
1327
1337
  if (func.return_none) {
1338
+ // 戻り値のない関数の場合
1328
1339
  if (funcEnd === '') {
1329
1340
  if (funcBegin === '') {
1330
1341
  code = `${funcCall};\n`
@@ -1335,6 +1346,7 @@ try {
1335
1346
  code = `${funcBegin}try {\n${indent(funcCall, 1)};\n} finally {\n${indent(funcEnd, 1)}}\n`
1336
1347
  }
1337
1348
  } else {
1349
+ // 戻り値のある関数の場合
1338
1350
  let sorePrefex = ''
1339
1351
  if (this.speedMode.invalidSore === 0) {
1340
1352
  sorePrefex = `${this.varname('それ')} = `
@@ -1,5 +1,5 @@
1
1
  const NakoColors = require('./nako_colors')
2
-
2
+ const {NakoRuntimeError} = require('./nako_errors')
3
3
  /**
4
4
  * コンパイルされたなでしこのプログラムで、グローバル空間のthisが指すオブジェクト
5
5
  */
@@ -23,6 +23,7 @@ class NakoGlobal {
23
23
  this.__stack = []
24
24
  this.__labels = []
25
25
  this.__genMode = gen.genMode
26
+ this.NakoRuntimeError = NakoRuntimeError
26
27
 
27
28
  // PluginSystemとdestroy()から参照するため
28
29
  this.__module = { ...compiler.__module } // shallow copy
@@ -1,8 +1,8 @@
1
1
  // なでしこバージョン
2
2
  const nakoVersion = {
3
- version: '3.2.46',
3
+ version: '3.2.47',
4
4
  major: 3,
5
5
  minor: 2,
6
- patch: 46
6
+ patch: 47
7
7
  }
8
8
  module.exports = nakoVersion