rapydscript-ng 0.7.24 → 0.8.0

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 (114) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +72 -26
  3. package/bin/package.json +1 -0
  4. package/bin/rapydscript +65 -62
  5. package/editor-plugins/nvim/rapydscript/README.md +184 -0
  6. package/editor-plugins/nvim/rapydscript/bin/rapydscript.so +0 -0
  7. package/editor-plugins/nvim/rapydscript/ftdetect/rapydscript.lua +10 -0
  8. package/editor-plugins/nvim/rapydscript/lua/rapydscript/health.lua +88 -0
  9. package/editor-plugins/nvim/rapydscript/lua/rapydscript/init.lua +279 -0
  10. package/local-agent.md +28 -0
  11. package/package.json +4 -5
  12. package/release/baselib-plain-pretty.js +448 -326
  13. package/release/baselib-plain-ugly.js +3 -3
  14. package/release/compiler.js +2528 -1672
  15. package/release/signatures.json +17 -17
  16. package/src/ast.pyj +73 -25
  17. package/src/baselib-builtins.pyj +2 -2
  18. package/src/baselib-containers.pyj +153 -151
  19. package/src/baselib-internal.pyj +3 -3
  20. package/src/baselib-str.pyj +5 -5
  21. package/src/lib/aes.pyj +1 -1
  22. package/src/lib/encodings.pyj +1 -1
  23. package/src/lib/pythonize.pyj +1 -1
  24. package/src/lib/re.pyj +2 -2
  25. package/src/lib/traceback.pyj +165 -28
  26. package/src/lib/uuid.pyj +1 -1
  27. package/src/output/codegen.pyj +10 -3
  28. package/src/output/functions.pyj +31 -40
  29. package/src/output/literals.pyj +11 -14
  30. package/src/output/loops.pyj +25 -87
  31. package/src/output/modules.pyj +5 -47
  32. package/src/output/statements.pyj +1 -1
  33. package/src/output/stream.pyj +58 -31
  34. package/src/parse.pyj +777 -427
  35. package/src/tokenizer.pyj +16 -4
  36. package/src/utils.pyj +1 -1
  37. package/test/_treeshake_mod.pyj +30 -0
  38. package/test/_treeshake_side_effect.pyj +9 -0
  39. package/test/ast_serialization.pyj +392 -0
  40. package/test/async.pyj +95 -0
  41. package/test/baselib.pyj +1 -2
  42. package/test/embedded_compiler.pyj +57 -0
  43. package/test/fmt.pyj +201 -0
  44. package/test/generic.pyj +7 -3
  45. package/test/imports.pyj +8 -6
  46. package/test/internationalization.pyj +38 -37
  47. package/test/lint.pyj +120 -117
  48. package/test/lsp.pyj +222 -0
  49. package/test/repl.pyj +70 -65
  50. package/test/sourcemaps.pyj +315 -0
  51. package/test/starargs.pyj +46 -39
  52. package/test/traceback.pyj +263 -0
  53. package/test/treeshaking.pyj +181 -0
  54. package/test/web_repl_export.pyj +88 -0
  55. package/tools/ast_serialize.mjs +557 -0
  56. package/tools/cli.mjs +510 -0
  57. package/tools/compile.mjs +201 -0
  58. package/tools/compiler.mjs +127 -0
  59. package/tools/{completer.js → completer.mjs} +6 -6
  60. package/tools/{embedded_compiler.js → embedded_compiler.mjs} +17 -13
  61. package/tools/export.js +109 -56
  62. package/tools/fmt.mjs +735 -0
  63. package/tools/{gettext.js → gettext.mjs} +46 -53
  64. package/tools/{ini.js → ini.mjs} +9 -10
  65. package/tools/{lint.js → lint.mjs} +78 -55
  66. package/tools/lsp.mjs +914 -0
  67. package/tools/lsp_protocol.mjs +259 -0
  68. package/tools/lsp_symbols.mjs +418 -0
  69. package/tools/{msgfmt.js → msgfmt.mjs} +18 -18
  70. package/tools/{repl.js → repl.mjs} +52 -41
  71. package/tools/{self.js → self.mjs} +56 -46
  72. package/tools/sourcemap.mjs +123 -0
  73. package/tools/test.mjs +152 -0
  74. package/tools/treeshake.mjs +400 -0
  75. package/tools/{utils.js → utils.mjs} +26 -23
  76. package/tools/{web_repl.js → web_repl.mjs} +15 -13
  77. package/tools/web_repl_export.mjs +93 -0
  78. package/tree-sitter/README.md +101 -0
  79. package/tree-sitter/grammar.js +992 -0
  80. package/tree-sitter/package.json +43 -0
  81. package/tree-sitter/queries/rapydscript/highlights.scm +232 -0
  82. package/tree-sitter/queries/rapydscript/indents.scm +64 -0
  83. package/tree-sitter/queries/rapydscript/injections.scm +14 -0
  84. package/tree-sitter/queries/rapydscript/locals.scm +108 -0
  85. package/tree-sitter/src/grammar.json +4976 -0
  86. package/tree-sitter/src/node-types.json +2901 -0
  87. package/tree-sitter/src/parser.c +196465 -0
  88. package/tree-sitter/src/scanner.c +294 -0
  89. package/tree-sitter/src/tree_sitter/alloc.h +54 -0
  90. package/tree-sitter/src/tree_sitter/array.h +330 -0
  91. package/tree-sitter/src/tree_sitter/parser.h +286 -0
  92. package/tree-sitter/test/corpus/chaining.txt +99 -0
  93. package/tree-sitter/test/corpus/classes.txt +147 -0
  94. package/tree-sitter/test/corpus/comprehensions.txt +155 -0
  95. package/tree-sitter/test/corpus/containers.txt +242 -0
  96. package/tree-sitter/test/corpus/control_flow.txt +361 -0
  97. package/tree-sitter/test/corpus/decorators.txt +64 -0
  98. package/tree-sitter/test/corpus/existential.txt +102 -0
  99. package/tree-sitter/test/corpus/functions.txt +293 -0
  100. package/tree-sitter/test/corpus/imports.txt +117 -0
  101. package/tree-sitter/test/corpus/literals.txt +135 -0
  102. package/tree-sitter/test/corpus/operators.txt +296 -0
  103. package/tree-sitter/test/corpus/statements.txt +189 -0
  104. package/tree-sitter/test/corpus/strings.txt +90 -0
  105. package/tree-sitter/test/corpus/subscripts.txt +227 -0
  106. package/tree-sitter/tree-sitter.json +36 -0
  107. package/web-repl/env.js +35 -23
  108. package/web-repl/main.js +8 -8
  109. package/bin/export +0 -75
  110. package/bin/web-repl-export +0 -102
  111. package/tools/cli.js +0 -523
  112. package/tools/compile.js +0 -184
  113. package/tools/compiler.js +0 -84
  114. package/tools/test.js +0 -110
@@ -2,26 +2,162 @@
2
2
  # License: BSD Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
3
3
  # globals: ρσ_str, ρσ_last_exception
4
4
 
5
+ _traceback_state = {'source_map': None, 'decoded': None}
6
+
7
+ _VLQ_BASE64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
8
+
9
+
10
+ def set_source_map_data(data):
11
+ _traceback_state['source_map'] = data
12
+ _traceback_state['decoded'] = None
13
+
14
+
15
+ def serialize_error_for_formatting(err):
16
+ return {
17
+ 'name': err.name or 'Error',
18
+ 'stack': err.stack or '',
19
+ 'message': err.message or '',
20
+ }
21
+
22
+ def unserialize_error_for_formatting(err):
23
+ ans = new Error()
24
+ ans.name = err.name
25
+ ans.stack = err.stack
26
+ ans.message = err.message
27
+ return ans
28
+
29
+
30
+ def _vlq_decode(encoded):
31
+ result = v'[]'
32
+ i = 0
33
+ n = encoded.length
34
+ while i < n:
35
+ value = 0
36
+ shift = 0
37
+ has_more = True
38
+ while has_more:
39
+ digit = _VLQ_BASE64.indexOf(encoded[i])
40
+ i += 1
41
+ has_more = (digit & 32) != 0
42
+ value += (digit & 31) << shift
43
+ shift += 5
44
+ if value & 1:
45
+ value = -(value >> 1)
46
+ else:
47
+ value = value >> 1
48
+ result.push(value)
49
+ return result
50
+
51
+
52
+ def _decode_source_map(smap):
53
+ sources = smap.sources or v'[]'
54
+ source_root = smap.sourceRoot or ''
55
+ mappings_str = smap.mappings or ''
56
+ mapping_lines = mappings_str.split(';')
57
+ decoded = v'[]'
58
+ prev_src_idx = 0
59
+ prev_src_line = 0
60
+ prev_src_col = 0
61
+ for gen_line in range(mapping_lines.length):
62
+ line_str = mapping_lines[gen_line]
63
+ line_entries = v'[]'
64
+ if line_str:
65
+ segments = line_str.split(',')
66
+ prev_col = 0
67
+ for seg_str in segments:
68
+ if not seg_str:
69
+ continue
70
+ fields = _vlq_decode(seg_str)
71
+ if fields.length >= 4:
72
+ gen_col = prev_col + fields[0]
73
+ prev_col = gen_col
74
+ src_idx = prev_src_idx + fields[1]
75
+ prev_src_idx = src_idx
76
+ src_line = prev_src_line + fields[2]
77
+ prev_src_line = src_line
78
+ src_col = prev_src_col + fields[3]
79
+ prev_src_col = src_col
80
+ src_file = sources[src_idx] if src_idx >= 0 and src_idx < sources.length else ''
81
+ if source_root and src_file:
82
+ src_file = source_root + src_file
83
+ line_entries.push({'gen_col': gen_col, 'src_file': src_file, 'src_line': src_line, 'src_col': src_col})
84
+ elif fields.length >= 1:
85
+ prev_col += fields[0]
86
+ decoded.push(line_entries)
87
+ return decoded
88
+
89
+
90
+ def _find_mapping(decoded, gen_line, gen_col):
91
+ if not decoded or gen_line < 0 or gen_line >= decoded.length:
92
+ return None
93
+ line_entries = decoded[gen_line]
94
+ if not line_entries or not line_entries.length:
95
+ return None
96
+ best = None
97
+ for entry in line_entries:
98
+ if entry.gen_col <= gen_col:
99
+ if best is None or entry.gen_col > best.gen_col:
100
+ best = entry
101
+ return best
102
+
103
+
104
+ def _parse_stack_frame(line):
105
+ # Chrome/Node: " at functionName (file:line:col)"
106
+ m = /^\s*at\s+(.*?)\s+\((.+):(\d+):(\d+)\)/.exec(line)
107
+ if m:
108
+ return {'func': m[1] or None, 'file': m[2], 'line': parseInt(m[3], 10) - 1, 'col': parseInt(m[4], 10) - 1}
109
+ # Chrome/Node: " at file:line:col"
110
+ m = /^\s*at (.+):(\d+):(\d+)$/.exec(line)
111
+ if m:
112
+ return {'func': None, 'file': m[1], 'line': parseInt(m[2], 10) - 1, 'col': parseInt(m[3], 10) - 1}
113
+ # Firefox: "functionName@file:line:col"
114
+ m = /^(.*?)@(.+):(\d+):(\d+)$/.exec(line)
115
+ if m:
116
+ return {'func': m[1] or None, 'file': m[2], 'line': parseInt(m[3], 10) - 1, 'col': parseInt(m[4], 10) - 1}
117
+ return None
118
+
119
+
120
+ def _get_decoded_map():
121
+ if _traceback_state['decoded'] is None and _traceback_state['source_map']:
122
+ _traceback_state['decoded'] = _decode_source_map(_traceback_state['source_map'])
123
+ return _traceback_state['decoded']
124
+
5
125
 
6
126
  def _get_internal_traceback(err):
7
- if isinstance(err, Exception) and err.stack:
8
- lines = ρσ_str.splitlines(err.stack)
9
- final_lines = v'[]'
10
- found_sentinel = False
11
- for i, line in enumerate(lines):
12
- sline = ρσ_str.strip(line)
13
- if i is 0:
14
- final_lines.push(line)
15
- continue
16
- if found_sentinel:
17
- final_lines.push(line)
18
- continue
19
- # These two conditions work on desktop Chrome and Firefox to identify the correct
20
- # line in the traceback.
21
- if sline.startsWith('at new ' + err.name) or sline.startsWith(err.name + '@'):
22
- found_sentinel = True
23
- return final_lines.join('\n')
24
- return err and err.stack
127
+ lines = ρσ_str.splitlines(err.stack or '')
128
+ final_lines = v'[]'
129
+ start_line_idx = -1
130
+ for i, line in enumerate(lines):
131
+ if i > 0:
132
+ line = line.trim()
133
+ if line.startsWith('at new ' + err.name) or line.startsWith(err.name + '@'):
134
+ # this is the constructor for a RapydScript Exception
135
+ start_line_idx = i + 1
136
+ break
137
+ if start_line_idx < 0:
138
+ start_line_idx = 1
139
+ for i, xline in enumerate(lines):
140
+ if i > 0:
141
+ line = xline.trim()
142
+ if v"line.startsWith('at ') || line.includes('@') || /:\d+:\d+$/.test(line)":
143
+ start_line_idx = i
144
+ break
145
+ frame_lines = lines[start_line_idx:]
146
+ final_lines = final_lines.concat(frame_lines)
147
+ decoded = _get_decoded_map()
148
+ mapped_lines = v'[]'
149
+ if decoded:
150
+ for frame_line in frame_lines:
151
+ frame = _parse_stack_frame(frame_line)
152
+ if frame:
153
+ mapping = _find_mapping(decoded, frame.line, frame.col)
154
+ if mapping:
155
+ loc = ' File "' + mapping.src_file + '", line ' + (mapping.src_line + 1) + ', col ' + (mapping.src_col + 1)
156
+ if frame.func:
157
+ loc += ', in ' + frame.func
158
+ mapped_lines.push(loc)
159
+ return lines[0], final_lines, mapped_lines
160
+
25
161
 
26
162
  def format_exception(exc, limit):
27
163
  if jstype(exc) is 'undefined':
@@ -30,17 +166,18 @@ def format_exception(exc, limit):
30
166
  if exc and exc.toString:
31
167
  return [exc.toString()]
32
168
  return []
33
- tb = _get_internal_traceback(exc)
34
- if tb:
35
- lines = ρσ_str.splitlines(tb)
36
- e = lines[0]
37
- lines = lines[1:]
169
+ e, js_lines, rs_lines = _get_internal_traceback(exc)
170
+ if js_lines.length > 0:
38
171
  if limit:
39
- lines = lines[:limit+1] if limit > 0 else lines[limit:]
40
- lines.reverse()
41
- lines.push(e)
42
- lines.insert(0, 'Traceback (most recent call last):')
43
- return [l+'\n' for l in lines]
172
+ js_lines = js_lines[:limit] if limit > 0 else js_lines[limit:]
173
+ rs_lines = rs_lines[:limit] if limit > 0 else rs_lines[limit:]
174
+ js_lines.reverse()
175
+ rs_lines.reverse()
176
+ js_lines.push(e)
177
+ js_lines = v"['Traceback (most recent call last):'].concat(js_lines)"
178
+ if rs_lines.length > 0:
179
+ js_lines = js_lines.concat(['', 'Mapped Traceback (RapydScript):']).concat(rs_lines)
180
+ return [l+'\n' for l in js_lines]
44
181
  return [exc.toString()]
45
182
 
46
183
  def format_exc(limit):
package/src/lib/uuid.pyj CHANGED
@@ -47,7 +47,7 @@ def uuid4():
47
47
  def num_to_string(numbers, alphabet, pad_to_length):
48
48
  ans = v'[]'
49
49
  alphabet_len = alphabet.length
50
- numbers = Array.prototype.slice.call(numbers)
50
+ numbers = Array.from(numbers)
51
51
  for v'var i = 0; i < numbers.length - 1; i++':
52
52
  x = divmod(numbers[i], alphabet_len)
53
53
  numbers[i] = x[0]
@@ -2,7 +2,7 @@
2
2
  # License: BSD Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
3
3
  from __python__ import hash_literals
4
4
 
5
- # globals:console,regenerate,writefile
5
+ # globals:console
6
6
 
7
7
  from utils import noop
8
8
  from parse import PRECEDENCE
@@ -18,7 +18,7 @@ from ast import (
18
18
  AST_Statement, AST_StatementWithBody, AST_String, AST_Sub, AST_ItemAccess,
19
19
  AST_Symbol, AST_This, AST_Throw, AST_Toplevel, AST_Try, AST_Unary,
20
20
  AST_UnaryPrefix, AST_Undefined, AST_Var, AST_VarDef, AST_Assert,
21
- AST_Verbatim, AST_While, AST_With, AST_Yield, TreeWalker, AST_Existential
21
+ AST_Verbatim, AST_While, AST_With, AST_Yield, AST_Await, TreeWalker, AST_Existential
22
22
  )
23
23
  from output.exceptions import print_try
24
24
  from output.classes import print_class
@@ -48,10 +48,12 @@ def generate_code():
48
48
  if force_parens or self.needs_parens(stream):
49
49
  stream.with_parens(def():
50
50
  self.add_comments(stream)
51
+ stream.add_mapping(self)
51
52
  generator(self, stream)
52
53
  )
53
54
  else:
54
55
  self.add_comments(stream)
56
+ stream.add_mapping(self)
55
57
  generator(self, stream)
56
58
 
57
59
  stream.pop_node()
@@ -134,7 +136,7 @@ def generate_code():
134
136
  )
135
137
  PARENS(AST_New, def(output):
136
138
  p = output.parent()
137
- if this.args.length is 0 and (is_node_type(p, AST_PropAccess) or is_node_type(p, AST_BaseCall) and p.expression is this):
139
+ if this.args.args.length is 0 and (is_node_type(p, AST_PropAccess) or is_node_type(p, AST_BaseCall) and p.expression is this):
138
140
  # (new foo)(bar)
139
141
  return True
140
142
  )
@@ -261,6 +263,11 @@ def generate_code():
261
263
  DEFPRINT(AST_Yield, def(self, output):
262
264
  self._do_print(output, "yield" + ('*' if self.is_yield_from else ''))
263
265
  )
266
+ DEFPRINT(AST_Await, def(self, output):
267
+ output.print("await")
268
+ output.space()
269
+ self.value.print(output)
270
+ )
264
271
  DEFPRINT(AST_Return, def(self, output):
265
272
  self._do_print(output, "return")
266
273
  )
@@ -1,6 +1,5 @@
1
1
  # vim:fileencoding=utf-8
2
2
  # License: BSD Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net>
3
- # globals:regenerate
4
3
  from __python__ import hash_literals
5
4
 
6
5
  from ast import AST_ClassCall, AST_New, has_calls, AST_Dot, AST_SymbolRef, is_node_type
@@ -35,8 +34,8 @@ def decorate(decorators, output, func):
35
34
 
36
35
  def function_args(argnames, output, strip_first):
37
36
  output.with_parens(def():
38
- if argnames and argnames.length and (argnames.is_simple_func is True or argnames.is_simple_func is undefined):
39
- for i, arg in enumerate((argnames.slice(1) if strip_first else argnames)):
37
+ if argnames and argnames.args.length and (argnames.is_simple_func is True or argnames.is_simple_func is undefined):
38
+ for i, arg in enumerate((argnames.args.slice(1) if strip_first else argnames.args)):
40
39
  if i:
41
40
  output.comma()
42
41
  arg.print(output)
@@ -51,7 +50,7 @@ def function_preamble(node, output, offset):
51
50
  fname = node.name.name if node.name else anonfunc
52
51
  kw = 'arguments[arguments.length-1]'
53
52
  # Define all formal parameters
54
- for c, arg in enumerate(a):
53
+ for c, arg in enumerate(a.args):
55
54
  i = c - offset
56
55
  if i >= 0:
57
56
  output.indent()
@@ -97,7 +96,7 @@ def function_preamble(node, output, offset):
97
96
 
98
97
  if a.starargs is not undefined:
99
98
  # Define the *args parameter, putting in whatever is left after assigning the formal parameters and the options object
100
- nargs = a.length - offset
99
+ nargs = a.args.length - offset
101
100
  output.indent()
102
101
  output.spaced('var', a.starargs.name, '=', 'Array.prototype.slice.call(arguments,', nargs + ')')
103
102
  output.end_statement()
@@ -110,7 +109,7 @@ def function_preamble(node, output, offset):
110
109
  def has_annotations(self):
111
110
  if self.return_annotation:
112
111
  return True
113
- for arg in self.argnames:
112
+ for arg in self.argnames.args:
114
113
  if arg.annotation:
115
114
  return True
116
115
  return False
@@ -123,13 +122,13 @@ def function_annotation(self, output, strip_first, name):
123
122
  if has_annotations(self):
124
123
  props.__annotations__ = def():
125
124
  output.print('{')
126
- if self.argnames and self.argnames.length:
127
- for i, arg in enumerate(self.argnames):
125
+ if self.argnames and self.argnames.args.length:
126
+ for i, arg in enumerate(self.argnames.args):
128
127
  if arg.annotation:
129
128
  arg.print(output)
130
129
  output.print(':'), output.space()
131
130
  arg.annotation.print(output)
132
- if i < self.argnames.length - 1 or self.return_annotation:
131
+ if i < self.argnames.args.length - 1 or self.return_annotation:
133
132
  output.comma()
134
133
  if self.return_annotation:
135
134
  output.print('return:'), output.space()
@@ -154,14 +153,14 @@ def function_annotation(self, output, strip_first, name):
154
153
  output.print('true')
155
154
 
156
155
  # Create __argnames__
157
- if self.argnames.length > (1 if strip_first else 0):
156
+ if self.argnames.args.length > (1 if strip_first else 0):
158
157
  props.__argnames__ = def():
159
158
  output.print('[')
160
- for i, arg in enumerate(self.argnames):
159
+ for i, arg in enumerate(self.argnames.args):
161
160
  if strip_first and i is 0:
162
161
  continue
163
162
  output.print(JSON.stringify(arg.name))
164
- if i is not self.argnames.length - 1:
163
+ if i is not self.argnames.args.length - 1:
165
164
  output.comma()
166
165
  output.print(']')
167
166
 
@@ -197,6 +196,8 @@ def function_definition(self, output, strip_first, as_expression):
197
196
  output.set_indentation(output.next_indent())
198
197
  output.spaced('(function()', '{'), output.newline()
199
198
  output.indent(), output.spaced('var', anonfunc, '='), output.space()
199
+ if self.is_async:
200
+ output.print("async"), output.space()
200
201
  output.print("function"), output.space()
201
202
  if self.name:
202
203
  self.name.print(output)
@@ -204,21 +205,10 @@ def function_definition(self, output, strip_first, as_expression):
204
205
  if self.is_generator:
205
206
  output.print('()'), output.space()
206
207
  output.with_block(def():
207
- if output.options.js_version >= 6:
208
- output.indent()
209
- output.print('function* js_generator')
210
- function_args(self.argnames, output, strip_first)
211
- print_bracketed(self, output, True, function_preamble)
212
- else:
213
- temp = OutputStream({'beautify':True})
214
- temp.print('function* js_generator')
215
- function_args(self.argnames, temp, strip_first)
216
- print_bracketed(self, temp, True, function_preamble)
217
- transpiled = regenerate(temp.get(), output.options.beautify).replace(/regeneratorRuntime.(wrap|mark)/g, 'ρσ_regenerator.regeneratorRuntime.$1')
218
- if output.options.beautify:
219
- ci = output.make_indent(0)
220
- transpiled = [ci + x for x in transpiled.split('\n')].join('\n')
221
- output.print(transpiled)
208
+ output.indent()
209
+ output.print('function* js_generator')
210
+ function_args(self.argnames, output, strip_first)
211
+ print_bracketed(self, output, True, function_preamble)
222
212
  output.newline()
223
213
  output.indent()
224
214
  output.spaced('var', 'result', '=', 'js_generator.apply(this,', 'arguments)')
@@ -338,19 +328,20 @@ def print_function_call(self, output):
338
328
  def print_positional_args():
339
329
  # basic arguments
340
330
  i = 0
341
- while i < self.args.length:
342
- expr = self.args[i]
331
+ pargs = self.args.args
332
+ while i < pargs.length:
333
+ expr = pargs[i]
343
334
  is_first = i is 0
344
335
  if not is_first:
345
336
  output.print('.concat(')
346
337
  if expr.is_array:
347
- expr.print(output)
338
+ expr.value.print(output)
348
339
  i += 1
349
340
  else:
350
341
  output.print('[')
351
- while i < self.args.length and not self.args[i].is_array:
352
- self.args[i].print(output)
353
- if i + 1 < self.args.length and not self.args[i+1].is_array:
342
+ while i < pargs.length and not pargs[i].is_array:
343
+ pargs[i].value.print(output)
344
+ if i + 1 < pargs.length and not pargs[i+1].is_array:
354
345
  output.print(',')
355
346
  output.space()
356
347
  i += 1
@@ -364,7 +355,7 @@ def print_function_call(self, output):
364
355
  is_new = is_node_type(self, AST_New)
365
356
  is_repeatable = True
366
357
 
367
- if is_new and not self.args.length and not has_kwargs and not self.args.starargs:
358
+ if is_new and not self.args.args.length and not has_kwargs and not self.args.starargs:
368
359
  output.print('new'), output.space()
369
360
  print_function_name()
370
361
  return # new A is the same as new A() in javascript
@@ -375,10 +366,10 @@ def print_function_call(self, output):
375
366
  output.print('new'), output.space()
376
367
  print_function_name()
377
368
  output.with_parens(def():
378
- for i, a in enumerate(self.args):
369
+ for i, a in enumerate(self.args.args):
379
370
  if i:
380
371
  output.comma()
381
- a.print(output)
372
+ a.value.print(output)
382
373
  )
383
374
  return
384
375
 
@@ -404,18 +395,18 @@ def print_function_call(self, output):
404
395
  output.print('.apply(')
405
396
  do_print_this()
406
397
 
407
- if is_prototype_call and self.args.length > 1:
408
- self.args.shift()
398
+ if is_prototype_call and self.args.args.length > 1:
399
+ self.args.args.shift()
409
400
 
410
401
  print_positional_args()
411
402
 
412
403
  if has_kwargs:
413
- if self.args.length:
404
+ if self.args.args.length:
414
405
  output.print('.concat(')
415
406
  output.print('[')
416
407
  print_kwargs()
417
408
  output.print(']')
418
- if self.args.length:
409
+ if self.args.args.length:
419
410
  output.print(')')
420
411
 
421
412
  output.print(')')
@@ -5,20 +5,17 @@ from __python__ import hash_literals
5
5
  from ast import AST_Binary, is_node_type
6
6
 
7
7
  def print_array(self, output):
8
- output.print('ρσ_list_decorate')
9
- output.with_parens(def():
10
- output.with_square(def():
11
- a = self.elements
12
- len_ = a.length
13
- if len_ > 0:
14
- output.space()
15
- for i, exp in enumerate(a):
16
- if i:
17
- output.comma()
18
- exp.print(output)
19
- if len_ > 0:
20
- output.space()
21
- )
8
+ output.with_square(def():
9
+ a = self.elements
10
+ len_ = a.length
11
+ if len_ > 0:
12
+ output.space()
13
+ for i, exp in enumerate(a):
14
+ if i:
15
+ output.comma()
16
+ exp.print(output)
17
+ if len_ > 0:
18
+ output.space()
22
19
  )
23
20
 
24
21