rapydscript-ng 0.8.0 → 0.8.1
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/CHANGELOG.md +9 -0
- package/README.md +8 -0
- package/bin/build.ts +117 -0
- package/build_wheels.py +133 -0
- package/editor-plugins/README.md +80 -0
- package/editor-plugins/nvim.lua +321 -0
- package/package.json +1 -1
- package/publish.py +27 -17
- package/release/compiler.js +8125 -8093
- package/release/signatures.json +27 -27
- package/release/stdlib_modules.json +1 -0
- package/src/ast.pyj +379 -279
- package/src/baselib-builtins.pyj +47 -26
- package/src/baselib-containers.pyj +105 -92
- package/src/baselib-errors.pyj +8 -1
- package/src/baselib-internal.pyj +35 -20
- package/src/baselib-itertools.pyj +13 -7
- package/src/baselib-str.pyj +55 -80
- package/src/compiler.pyj +4 -4
- package/src/errors.pyj +3 -4
- package/src/lib/aes.pyj +46 -32
- package/src/lib/elementmaker.pyj +11 -9
- package/src/lib/encodings.pyj +15 -5
- package/src/lib/gettext.pyj +9 -4
- package/src/lib/math.pyj +106 -45
- package/src/lib/operator.pyj +10 -10
- package/src/lib/pythonize.pyj +2 -1
- package/src/lib/random.pyj +28 -21
- package/src/lib/re.pyj +490 -17
- package/src/lib/traceback.pyj +7 -2
- package/src/lib/uuid.pyj +2 -2
- package/src/output/classes.pyj +28 -27
- package/src/output/codegen.pyj +80 -83
- package/src/output/comments.pyj +8 -8
- package/src/output/exceptions.pyj +20 -21
- package/src/output/functions.pyj +37 -26
- package/src/output/literals.pyj +14 -10
- package/src/output/loops.pyj +63 -59
- package/src/output/modules.pyj +52 -23
- package/src/output/operators.pyj +40 -29
- package/src/output/statements.pyj +20 -14
- package/src/output/stream.pyj +33 -34
- package/src/output/utils.pyj +12 -8
- package/src/parse.pyj +234 -233
- package/src/string_interpolation.pyj +5 -3
- package/src/tokenizer.pyj +176 -148
- package/src/utils.pyj +31 -14
- package/test/fmt.pyj +94 -4
- package/test/generic.pyj +9 -0
- package/test/lsp.pyj +35 -0
- package/test/str.pyj +8 -0
- package/tools/cli.mjs +25 -4
- package/tools/compile.mjs +7 -3
- package/tools/compiler.mjs +34 -2
- package/tools/fmt.mjs +262 -22
- package/tools/ini.mjs +112 -1
- package/tools/lsp.mjs +56 -6
- package/tools/repl.mjs +5 -2
- package/tools/self.mjs +15 -0
- package/tools/test.mjs +100 -0
- package/tools/web_repl_export.mjs +4 -0
- package/tree-sitter/package.json +1 -1
- package/tree-sitter/tree-sitter.json +1 -1
- package/editor-plugins/nvim/rapydscript/README.md +0 -184
- package/editor-plugins/nvim/rapydscript/bin/rapydscript.so +0 -0
- package/editor-plugins/nvim/rapydscript/ftdetect/rapydscript.lua +0 -10
- package/editor-plugins/nvim/rapydscript/lua/rapydscript/health.lua +0 -88
- package/editor-plugins/nvim/rapydscript/lua/rapydscript/init.lua +0 -279
- /package/tree-sitter/queries/{rapydscript/highlights.scm → highlights.scm} +0 -0
- /package/tree-sitter/queries/{rapydscript/indents.scm → indents.scm} +0 -0
- /package/tree-sitter/queries/{rapydscript/injections.scm → injections.scm} +0 -0
- /package/tree-sitter/queries/{rapydscript/locals.scm → locals.scm} +0 -0
package/src/output/comments.pyj
CHANGED
|
@@ -7,13 +7,13 @@ from ast import AST_Exit, is_node_type
|
|
|
7
7
|
|
|
8
8
|
def output_comments(comments, output, nlb):
|
|
9
9
|
for comm in comments:
|
|
10
|
-
if comm.type is
|
|
11
|
-
output.print(
|
|
10
|
+
if comm.type is 'comment1':
|
|
11
|
+
output.print('//' + comm.value + '\n')
|
|
12
12
|
output.indent()
|
|
13
|
-
elif comm.type is
|
|
14
|
-
output.print(
|
|
13
|
+
elif comm.type is 'comment2':
|
|
14
|
+
output.print('/*' + comm.value + '*/')
|
|
15
15
|
if nlb:
|
|
16
|
-
output.print(
|
|
16
|
+
output.print('\n')
|
|
17
17
|
output.indent()
|
|
18
18
|
else:
|
|
19
19
|
output.space()
|
|
@@ -34,11 +34,11 @@ def print_comments(self, output):
|
|
|
34
34
|
self.value.start.comments_before = v'[]'
|
|
35
35
|
|
|
36
36
|
if c.test:
|
|
37
|
-
comments = comments.filter(def(comment):
|
|
37
|
+
comments = comments.filter(def (comment):
|
|
38
38
|
return c.test(comment.value)
|
|
39
39
|
)
|
|
40
|
-
elif jstype(c) is
|
|
41
|
-
comments = comments.filter(def(comment):
|
|
40
|
+
elif jstype(c) is 'function':
|
|
41
|
+
comments = comments.filter(def (comment):
|
|
42
42
|
return c(self, comment)
|
|
43
43
|
)
|
|
44
44
|
|
|
@@ -7,12 +7,13 @@ from output.statements import print_bracketed
|
|
|
7
7
|
|
|
8
8
|
def print_try(self, output):
|
|
9
9
|
else_var_name = None
|
|
10
|
+
|
|
10
11
|
def update_output_var(output):
|
|
11
12
|
output.indent(), output.assign(else_var_name), output.print('true'), output.end_statement()
|
|
12
13
|
if self.belse:
|
|
13
14
|
else_var_name = output.new_try_else_counter()
|
|
14
15
|
output.assign('var ' + else_var_name), output.print('false'), output.end_statement(), output.indent()
|
|
15
|
-
output.print(
|
|
16
|
+
output.print('try')
|
|
16
17
|
output.space()
|
|
17
18
|
print_bracketed(self, output, False, None, None, update_output_var if else_var_name else None)
|
|
18
19
|
if self.bcatch:
|
|
@@ -28,35 +29,33 @@ def print_try(self, output):
|
|
|
28
29
|
|
|
29
30
|
|
|
30
31
|
def print_catch(self, output):
|
|
31
|
-
output.print(
|
|
32
|
+
output.print('catch')
|
|
32
33
|
output.space()
|
|
33
|
-
output.with_parens(def():
|
|
34
|
-
output.print(
|
|
34
|
+
output.with_parens(def ():
|
|
35
|
+
output.print('ρσ_Exception')
|
|
35
36
|
)
|
|
36
37
|
output.space()
|
|
37
|
-
output.with_block(def():
|
|
38
|
+
output.with_block(def ():
|
|
38
39
|
output.indent()
|
|
39
40
|
output.spaced('ρσ_last_exception', '=', 'ρσ_Exception'), output.end_statement()
|
|
40
41
|
output.indent()
|
|
41
42
|
no_default = True
|
|
42
43
|
for i, exception in enumerate(self.body):
|
|
43
44
|
if i:
|
|
44
|
-
output.print(
|
|
45
|
-
|
|
45
|
+
output.print('else ')
|
|
46
46
|
if exception.errors.length:
|
|
47
|
-
output.print(
|
|
47
|
+
output.print('if')
|
|
48
48
|
output.space()
|
|
49
|
-
output.with_parens(def():
|
|
49
|
+
output.with_parens(def ():
|
|
50
50
|
for i, err in enumerate(exception.errors):
|
|
51
51
|
if i:
|
|
52
52
|
output.newline()
|
|
53
53
|
output.indent()
|
|
54
|
-
output.print(
|
|
54
|
+
output.print('||')
|
|
55
55
|
output.space()
|
|
56
|
-
|
|
57
|
-
output.print("ρσ_Exception")
|
|
56
|
+
output.print('ρσ_Exception')
|
|
58
57
|
output.space()
|
|
59
|
-
output.print(
|
|
58
|
+
output.print('instanceof')
|
|
60
59
|
output.space()
|
|
61
60
|
if err.name is 'Exception':
|
|
62
61
|
output.print('Error')
|
|
@@ -69,13 +68,13 @@ def print_catch(self, output):
|
|
|
69
68
|
print_bracketed(exception, output, True)
|
|
70
69
|
output.space()
|
|
71
70
|
if no_default:
|
|
72
|
-
output.print(
|
|
71
|
+
output.print('else')
|
|
73
72
|
output.space()
|
|
74
|
-
output.with_block(def():
|
|
73
|
+
output.with_block(def ():
|
|
75
74
|
output.indent()
|
|
76
|
-
output.print(
|
|
75
|
+
output.print('throw')
|
|
77
76
|
output.space()
|
|
78
|
-
output.print(
|
|
77
|
+
output.print('ρσ_Exception')
|
|
79
78
|
output.semicolon()
|
|
80
79
|
output.newline()
|
|
81
80
|
)
|
|
@@ -84,13 +83,13 @@ def print_catch(self, output):
|
|
|
84
83
|
|
|
85
84
|
|
|
86
85
|
def print_finally(self, output, belse, else_var_name):
|
|
87
|
-
output.print(
|
|
86
|
+
output.print('finally')
|
|
88
87
|
output.space()
|
|
89
88
|
if else_var_name:
|
|
90
|
-
output.with_block(def():
|
|
91
|
-
output.indent(), output.print(
|
|
89
|
+
output.with_block(def ():
|
|
90
|
+
output.indent(), output.print('try')
|
|
92
91
|
output.space()
|
|
93
|
-
output.with_block(def():
|
|
92
|
+
output.with_block(def ():
|
|
94
93
|
print_else(belse, else_var_name, output)
|
|
95
94
|
)
|
|
96
95
|
print_finally(self, output)
|
package/src/output/functions.pyj
CHANGED
|
@@ -3,14 +3,15 @@
|
|
|
3
3
|
from __python__ import hash_literals
|
|
4
4
|
|
|
5
5
|
from ast import AST_ClassCall, AST_New, has_calls, AST_Dot, AST_SymbolRef, is_node_type
|
|
6
|
-
from output.
|
|
6
|
+
from output.operators import print_getattr
|
|
7
7
|
from output.statements import print_bracketed
|
|
8
|
+
from output.stream import OutputStream
|
|
8
9
|
from output.utils import create_doctring
|
|
9
|
-
from output.operators import print_getattr
|
|
10
10
|
|
|
11
11
|
anonfunc = 'ρσ_anonfunc'
|
|
12
12
|
module_name = 'null'
|
|
13
13
|
|
|
14
|
+
|
|
14
15
|
def set_module_name(x):
|
|
15
16
|
nonlocal module_name
|
|
16
17
|
module_name = '"' + x + '"' if x else 'null'
|
|
@@ -18,22 +19,25 @@ def set_module_name(x):
|
|
|
18
19
|
|
|
19
20
|
# Function definition {{{
|
|
20
21
|
|
|
22
|
+
|
|
21
23
|
def decorate(decorators, output, func):
|
|
22
24
|
pos = 0
|
|
25
|
+
|
|
23
26
|
def wrap():
|
|
24
27
|
nonlocal pos
|
|
25
28
|
if pos < decorators.length:
|
|
26
29
|
decorators[pos].expression.print(output)
|
|
27
30
|
pos += 1
|
|
28
|
-
output.with_parens(def():
|
|
31
|
+
output.with_parens(def ():
|
|
29
32
|
wrap()
|
|
30
33
|
)
|
|
31
34
|
else:
|
|
32
35
|
func()
|
|
33
36
|
wrap()
|
|
34
37
|
|
|
38
|
+
|
|
35
39
|
def function_args(argnames, output, strip_first):
|
|
36
|
-
output.with_parens(def():
|
|
40
|
+
output.with_parens(def ():
|
|
37
41
|
if argnames and argnames.args.length and (argnames.is_simple_func is True or argnames.is_simple_func is undefined):
|
|
38
42
|
for i, arg in enumerate((argnames.args.slice(1) if strip_first else argnames.args)):
|
|
39
43
|
if i:
|
|
@@ -42,6 +46,7 @@ def function_args(argnames, output, strip_first):
|
|
|
42
46
|
)
|
|
43
47
|
output.space()
|
|
44
48
|
|
|
49
|
+
|
|
45
50
|
def function_preamble(node, output, offset):
|
|
46
51
|
a = node.argnames
|
|
47
52
|
if not a or a.is_simple_func:
|
|
@@ -54,7 +59,7 @@ def function_preamble(node, output, offset):
|
|
|
54
59
|
i = c - offset
|
|
55
60
|
if i >= 0:
|
|
56
61
|
output.indent()
|
|
57
|
-
output.print(
|
|
62
|
+
output.print('var')
|
|
58
63
|
output.space()
|
|
59
64
|
output.assign(arg)
|
|
60
65
|
if Object.prototype.hasOwnProperty.call(a.defaults, arg.name):
|
|
@@ -83,7 +88,7 @@ def function_preamble(node, output, offset):
|
|
|
83
88
|
for dname in Object.keys(a.defaults):
|
|
84
89
|
output.indent()
|
|
85
90
|
output.spaced('if', '(Object.prototype.hasOwnProperty.call(' + kw + ',', '"' + dname + '"))')
|
|
86
|
-
output.with_block(def():
|
|
91
|
+
output.with_block(def ():
|
|
87
92
|
output.indent()
|
|
88
93
|
output.spaced(dname, '=', kw + '.' + dname)
|
|
89
94
|
output.end_statement()
|
|
@@ -106,6 +111,7 @@ def function_preamble(node, output, offset):
|
|
|
106
111
|
output.print('.pop()')
|
|
107
112
|
output.end_statement()
|
|
108
113
|
|
|
114
|
+
|
|
109
115
|
def has_annotations(self):
|
|
110
116
|
if self.return_annotation:
|
|
111
117
|
return True
|
|
@@ -114,13 +120,14 @@ def has_annotations(self):
|
|
|
114
120
|
return True
|
|
115
121
|
return False
|
|
116
122
|
|
|
123
|
+
|
|
117
124
|
def function_annotation(self, output, strip_first, name):
|
|
118
125
|
fname = name or (self.name.name if self.name else anonfunc)
|
|
119
126
|
props = Object.create(None)
|
|
120
127
|
|
|
121
128
|
# Create __annotations__
|
|
122
129
|
if has_annotations(self):
|
|
123
|
-
props.__annotations__ = def():
|
|
130
|
+
props.__annotations__ = def ():
|
|
124
131
|
output.print('{')
|
|
125
132
|
if self.argnames and self.argnames.args.length:
|
|
126
133
|
for i, arg in enumerate(self.argnames.args):
|
|
@@ -139,7 +146,7 @@ def function_annotation(self, output, strip_first, name):
|
|
|
139
146
|
defaults = self.argnames.defaults
|
|
140
147
|
dkeys = Object.keys(self.argnames.defaults)
|
|
141
148
|
if dkeys.length:
|
|
142
|
-
props.__defaults__ = def():
|
|
149
|
+
props.__defaults__ = def ():
|
|
143
150
|
output.print('{')
|
|
144
151
|
for i, k in enumerate(dkeys):
|
|
145
152
|
output.print(k + ':'), defaults[k].print(output)
|
|
@@ -149,12 +156,12 @@ def function_annotation(self, output, strip_first, name):
|
|
|
149
156
|
|
|
150
157
|
# Create __handles_kwarg_interpolation__
|
|
151
158
|
if not self.argnames.is_simple_func:
|
|
152
|
-
props.__handles_kwarg_interpolation__ = def():
|
|
159
|
+
props.__handles_kwarg_interpolation__ = def ():
|
|
153
160
|
output.print('true')
|
|
154
161
|
|
|
155
162
|
# Create __argnames__
|
|
156
163
|
if self.argnames.args.length > (1 if strip_first else 0):
|
|
157
|
-
props.__argnames__ = def():
|
|
164
|
+
props.__argnames__ = def ():
|
|
158
165
|
output.print('[')
|
|
159
166
|
for i, arg in enumerate(self.argnames.args):
|
|
160
167
|
if strip_first and i is 0:
|
|
@@ -166,10 +173,10 @@ def function_annotation(self, output, strip_first, name):
|
|
|
166
173
|
|
|
167
174
|
# Create __doc__
|
|
168
175
|
if output.options.keep_docstrings and self.docstrings and self.docstrings.length:
|
|
169
|
-
props.__doc__ = def():
|
|
176
|
+
props.__doc__ = def ():
|
|
170
177
|
output.print(JSON.stringify(create_doctring(self.docstrings)))
|
|
171
178
|
|
|
172
|
-
props.__module__ = def():
|
|
179
|
+
props.__module__ = def ():
|
|
173
180
|
output.print(module_name)
|
|
174
181
|
|
|
175
182
|
names = Object.keys(props)
|
|
@@ -178,7 +185,7 @@ def function_annotation(self, output, strip_first, name):
|
|
|
178
185
|
# can happen if the function definition is inside a loop, for example.
|
|
179
186
|
output.spaced('if', '(!' + fname + '.' + names[0] + ')', 'Object.defineProperties(' + fname)
|
|
180
187
|
output.comma()
|
|
181
|
-
output.with_block(def():
|
|
188
|
+
output.with_block(def ():
|
|
182
189
|
for v'var i = 0; i < names.length; i++':
|
|
183
190
|
name = names[i]
|
|
184
191
|
output.indent(), output.spaced(name, ':', '{value:', ''), props[name](), output.print('}')
|
|
@@ -197,14 +204,14 @@ def function_definition(self, output, strip_first, as_expression):
|
|
|
197
204
|
output.spaced('(function()', '{'), output.newline()
|
|
198
205
|
output.indent(), output.spaced('var', anonfunc, '='), output.space()
|
|
199
206
|
if self.is_async:
|
|
200
|
-
output.print(
|
|
201
|
-
output.print(
|
|
207
|
+
output.print('async'), output.space()
|
|
208
|
+
output.print('function'), output.space()
|
|
202
209
|
if self.name:
|
|
203
210
|
self.name.print(output)
|
|
204
211
|
|
|
205
212
|
if self.is_generator:
|
|
206
213
|
output.print('()'), output.space()
|
|
207
|
-
output.with_block(def():
|
|
214
|
+
output.with_block(def ():
|
|
208
215
|
output.indent()
|
|
209
216
|
output.print('function* js_generator')
|
|
210
217
|
function_args(self.argnames, output, strip_first)
|
|
@@ -230,15 +237,16 @@ def function_definition(self, output, strip_first, as_expression):
|
|
|
230
237
|
function_annotation(self, output, strip_first, anonfunc)
|
|
231
238
|
output.indent(), output.spaced('return', anonfunc), output.end_statement()
|
|
232
239
|
output.set_indentation(orig_indent)
|
|
233
|
-
output.indent(), output.print(
|
|
240
|
+
output.indent(), output.print('})()')
|
|
241
|
+
|
|
234
242
|
|
|
235
243
|
def print_function(output):
|
|
236
244
|
self = this
|
|
237
245
|
if self.decorators and self.decorators.length:
|
|
238
|
-
output.print(
|
|
246
|
+
output.print('var')
|
|
239
247
|
output.space()
|
|
240
248
|
output.assign(self.name.name)
|
|
241
|
-
decorate(self.decorators, output, def():function_definition(self, output, False, True);)
|
|
249
|
+
decorate(self.decorators, output, def (): function_definition(self, output, False, True);)
|
|
242
250
|
output.end_statement()
|
|
243
251
|
else:
|
|
244
252
|
function_definition(self, output, False)
|
|
@@ -249,12 +257,14 @@ def print_function(output):
|
|
|
249
257
|
|
|
250
258
|
# Function call {{{
|
|
251
259
|
|
|
260
|
+
|
|
252
261
|
def find_this(expression):
|
|
253
262
|
if is_node_type(expression, AST_Dot):
|
|
254
263
|
return expression.expression
|
|
255
264
|
if not is_node_type(expression, AST_SymbolRef):
|
|
256
265
|
return expression
|
|
257
266
|
|
|
267
|
+
|
|
258
268
|
def print_this(expression, output):
|
|
259
269
|
obj = find_this(expression)
|
|
260
270
|
if obj:
|
|
@@ -262,6 +272,7 @@ def print_this(expression, output):
|
|
|
262
272
|
else:
|
|
263
273
|
output.print('this')
|
|
264
274
|
|
|
275
|
+
|
|
265
276
|
def print_function_call(self, output):
|
|
266
277
|
is_prototype_call = False
|
|
267
278
|
|
|
@@ -271,15 +282,15 @@ def print_function_call(self, output):
|
|
|
271
282
|
# class methods are called through the prototype unless static
|
|
272
283
|
if self.static:
|
|
273
284
|
self.class.print(output)
|
|
274
|
-
output.print(
|
|
285
|
+
output.print('.')
|
|
275
286
|
output.print(self.method)
|
|
276
287
|
else:
|
|
277
288
|
is_prototype_call = True
|
|
278
289
|
self.class.print(output)
|
|
279
|
-
output.print(
|
|
290
|
+
output.print('.prototype.')
|
|
280
291
|
output.print(self.method)
|
|
281
292
|
if not no_call:
|
|
282
|
-
output.print(
|
|
293
|
+
output.print('.call')
|
|
283
294
|
else:
|
|
284
295
|
if not is_repeatable:
|
|
285
296
|
output.print('ρσ_expr_temp')
|
|
@@ -341,7 +352,7 @@ def print_function_call(self, output):
|
|
|
341
352
|
output.print('[')
|
|
342
353
|
while i < pargs.length and not pargs[i].is_array:
|
|
343
354
|
pargs[i].value.print(output)
|
|
344
|
-
if i + 1 < pargs.length and not pargs[i+1].is_array:
|
|
355
|
+
if i + 1 < pargs.length and not pargs[i + 1].is_array:
|
|
345
356
|
output.print(',')
|
|
346
357
|
output.space()
|
|
347
358
|
i += 1
|
|
@@ -358,14 +369,14 @@ def print_function_call(self, output):
|
|
|
358
369
|
if is_new and not self.args.args.length and not has_kwargs and not self.args.starargs:
|
|
359
370
|
output.print('new'), output.space()
|
|
360
371
|
print_function_name()
|
|
361
|
-
return
|
|
372
|
+
return # new A is the same as new A() in javascript
|
|
362
373
|
|
|
363
374
|
if not has_kwargs and not self.args.starargs:
|
|
364
375
|
# A simple function call, do nothing special
|
|
365
376
|
if is_new:
|
|
366
377
|
output.print('new'), output.space()
|
|
367
378
|
print_function_name()
|
|
368
|
-
output.with_parens(def():
|
|
379
|
+
output.with_parens(def ():
|
|
369
380
|
for i, a in enumerate(self.args.args):
|
|
370
381
|
if i:
|
|
371
382
|
output.comma()
|
|
@@ -412,4 +423,4 @@ def print_function_call(self, output):
|
|
|
412
423
|
output.print(')')
|
|
413
424
|
if not is_repeatable:
|
|
414
425
|
output.print(')')
|
|
415
|
-
# }}}
|
|
426
|
+
# }}}
|
package/src/output/literals.pyj
CHANGED
|
@@ -4,8 +4,9 @@ from __python__ import hash_literals
|
|
|
4
4
|
|
|
5
5
|
from ast import AST_Binary, is_node_type
|
|
6
6
|
|
|
7
|
+
|
|
7
8
|
def print_array(self, output):
|
|
8
|
-
output.with_square(def():
|
|
9
|
+
output.with_square(def ():
|
|
9
10
|
a = self.elements
|
|
10
11
|
len_ = a.length
|
|
11
12
|
if len_ > 0:
|
|
@@ -20,9 +21,9 @@ def print_array(self, output):
|
|
|
20
21
|
|
|
21
22
|
|
|
22
23
|
def print_obj_literal(self, output):
|
|
23
|
-
output.with_parens(def():
|
|
24
|
+
output.with_parens(def ():
|
|
24
25
|
output.print('function()')
|
|
25
|
-
output.with_block(def():
|
|
26
|
+
output.with_block(def ():
|
|
26
27
|
output.indent()
|
|
27
28
|
if self.is_pydict:
|
|
28
29
|
output.spaced.apply(output, 'var ρσ_d = ρσ_dict()'.split(' '))
|
|
@@ -33,14 +34,14 @@ def print_obj_literal(self, output):
|
|
|
33
34
|
output.indent()
|
|
34
35
|
if self.is_pydict:
|
|
35
36
|
output.print('ρσ_d.set')
|
|
36
|
-
output.with_parens(def():
|
|
37
|
+
output.with_parens(def ():
|
|
37
38
|
prop.key.print(output)
|
|
38
39
|
output.print(','), output.space()
|
|
39
40
|
prop.value.print(output)
|
|
40
41
|
)
|
|
41
42
|
else:
|
|
42
43
|
output.print('ρσ_d')
|
|
43
|
-
output.with_square(def():prop.key.print(output);)
|
|
44
|
+
output.with_square(def (): prop.key.print(output);)
|
|
44
45
|
output.space(), output.print('='), output.space()
|
|
45
46
|
prop.value.print(output)
|
|
46
47
|
output.end_statement()
|
|
@@ -51,6 +52,7 @@ def print_obj_literal(self, output):
|
|
|
51
52
|
)
|
|
52
53
|
output.print('.call(this)')
|
|
53
54
|
|
|
55
|
+
|
|
54
56
|
def print_object(self, output):
|
|
55
57
|
if self.is_pydict:
|
|
56
58
|
if self.properties.length > 0:
|
|
@@ -61,22 +63,23 @@ def print_object(self, output):
|
|
|
61
63
|
if self.properties.length > 0:
|
|
62
64
|
print_obj_literal(self, output)
|
|
63
65
|
else:
|
|
64
|
-
output.print(
|
|
66
|
+
output.print('Object.create(null)' if self.is_jshash else '{}')
|
|
67
|
+
|
|
65
68
|
|
|
66
69
|
def print_set(self, output):
|
|
67
70
|
if self.items.length is 0:
|
|
68
71
|
output.print('ρσ_set()')
|
|
69
72
|
return
|
|
70
|
-
output.with_parens(def():
|
|
73
|
+
output.with_parens(def ():
|
|
71
74
|
output.print('function()')
|
|
72
|
-
output.with_block(def():
|
|
75
|
+
output.with_block(def ():
|
|
73
76
|
output.indent()
|
|
74
77
|
output.spaced.apply(output, 'var s = ρσ_set()'.split(' '))
|
|
75
78
|
output.end_statement()
|
|
76
79
|
for item in self.items:
|
|
77
80
|
output.indent()
|
|
78
81
|
output.print('s.jsset.add')
|
|
79
|
-
output.with_parens(def():item.value.print(output);)
|
|
82
|
+
output.with_parens(def (): item.value.print(output);)
|
|
80
83
|
output.end_statement()
|
|
81
84
|
output.indent()
|
|
82
85
|
output.spaced('return', 's')
|
|
@@ -85,6 +88,7 @@ def print_set(self, output):
|
|
|
85
88
|
)
|
|
86
89
|
output.print('()')
|
|
87
90
|
|
|
91
|
+
|
|
88
92
|
def print_regexp(self, output):
|
|
89
93
|
str_ = self.value.toString()
|
|
90
94
|
if output.options.ascii_only:
|
|
@@ -92,4 +96,4 @@ def print_regexp(self, output):
|
|
|
92
96
|
output.print(str_)
|
|
93
97
|
p = output.parent()
|
|
94
98
|
if is_node_type(p, AST_Binary) and /^in/.test(p.operator) and p.left is self:
|
|
95
|
-
output.print(
|
|
99
|
+
output.print(' ')
|