Skip to content

Commit 8402002

Browse files
committed
upgrade ts model dir
1 parent f18935f commit 8402002

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1494
-922
lines changed

lib/builtin.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,22 @@ class Number extends Builtin {
136136

137137
class JSON extends Builtin {
138138
constructor(generator){
139-
const methods = ['stringify'];
139+
const methods = [];
140140
super(generator, 'JSON', methods);
141141
}
142142

143+
stringify(args) {
144+
const expr = args[0];
145+
this.generator.emit('typeof ');
146+
this.generator.visitExpr(expr);
147+
this.generator.emit(' === "string" ? ');
148+
this.generator.visitExpr(expr);
149+
this.generator.emit(' : ');
150+
this.generator.emit('JSON.stringify(');
151+
this.generator.visitExpr(expr);
152+
this.generator.emit(')');
153+
}
154+
143155
parseJSON(args, level){
144156
this.generator.emit(`${this.module }.parse`);
145157
this.generator.visitArgs(args, level);

0 commit comments

Comments
 (0)