From b75cf3b21f70945641a3e34ff51bbf81d966a18e Mon Sep 17 00:00:00 2001 From: Xiaodong Date: Mon, 30 Sep 2019 11:18:11 +0800 Subject: [PATCH 1/5] name anonymous functions more detailed --- src/closure.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/closure.ts b/src/closure.ts index 51d401dbc..7650a2c20 100644 --- a/src/closure.ts +++ b/src/closure.ts @@ -88,7 +88,10 @@ export default class Closure extends Callable { if (this.node.type === 'FunctionDeclaration' && this.node.id !== null) { this.functionName = this.node.id.name } else { - this.functionName = `Anonymous${++Closure.lambdaCtr}` + this.functionName = + `Anonymous${++Closure.lambdaCtr} (` + + this.node.params.map(o => Object(o).name).join(', ') + + ')' } // TODO: Investigate how relevant this really is. // .fun seems to only be used in interpreter's NewExpression handler, which uses .fun.prototype. From 227dae2846ba96c15bdce446ed5de709826b01f1 Mon Sep 17 00:00:00 2001 From: martin-henz Date: Tue, 1 Oct 2019 13:41:49 +0800 Subject: [PATCH 2/5] Update src/closure.ts Co-Authored-By: Open O. Close <3646725+openorclose@users.noreply.github.com> --- src/closure.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/closure.ts b/src/closure.ts index 7650a2c20..064c88a4e 100644 --- a/src/closure.ts +++ b/src/closure.ts @@ -90,7 +90,7 @@ export default class Closure extends Callable { } else { this.functionName = `Anonymous${++Closure.lambdaCtr} (` + - this.node.params.map(o => Object(o).name).join(', ') + + this.node.params.map((o: es.Identifier) => o.name).join(', ') + ')' } // TODO: Investigate how relevant this really is. From 22b14bea580340aab0ed7b7b253defd79e97345d Mon Sep 17 00:00:00 2001 From: Martin Henz Date: Tue, 1 Oct 2019 18:06:21 +0800 Subject: [PATCH 3/5] anonyomous functions identified by their parameters --- src/closure.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/closure.ts b/src/closure.ts index 064c88a4e..6aac67750 100644 --- a/src/closure.ts +++ b/src/closure.ts @@ -67,9 +67,6 @@ export default class Closure extends Callable { return closure } - /** Keep track how many lambdas are created */ - private static lambdaCtr = 0 - /** Unique ID defined for anonymous closure */ public functionName: string @@ -89,9 +86,9 @@ export default class Closure extends Callable { this.functionName = this.node.id.name } else { this.functionName = - `Anonymous${++Closure.lambdaCtr} (` + + `(` + this.node.params.map((o: es.Identifier) => o.name).join(', ') + - ')' + ') => ...' } // TODO: Investigate how relevant this really is. // .fun seems to only be used in interpreter's NewExpression handler, which uses .fun.prototype. From 7fe0311f9151f2a30787af5385dbff44ebd70dd3 Mon Sep 17 00:00:00 2001 From: Martin Henz Date: Tue, 1 Oct 2019 18:33:34 +0800 Subject: [PATCH 4/5] single parameter prettier now --- src/closure.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/closure.ts b/src/closure.ts index 6aac67750..fabc820d9 100644 --- a/src/closure.ts +++ b/src/closure.ts @@ -86,9 +86,10 @@ export default class Closure extends Callable { this.functionName = this.node.id.name } else { this.functionName = - `(` + + (this.node.params.length === 1 ? '' : '(') + this.node.params.map((o: es.Identifier) => o.name).join(', ') + - ') => ...' + (this.node.params.length === 1 ? '' : ')') + + ' => ...' } // TODO: Investigate how relevant this really is. // .fun seems to only be used in interpreter's NewExpression handler, which uses .fun.prototype. From 32003812e666df7e7b6c5dea84c077724a154a36 Mon Sep 17 00:00:00 2001 From: Martin Henz Date: Tue, 1 Oct 2019 18:59:02 +0800 Subject: [PATCH 5/5] single parameter prettier now --- src/closure.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/closure.ts b/src/closure.ts index fabc820d9..f84fe0df3 100644 --- a/src/closure.ts +++ b/src/closure.ts @@ -89,7 +89,7 @@ export default class Closure extends Callable { (this.node.params.length === 1 ? '' : '(') + this.node.params.map((o: es.Identifier) => o.name).join(', ') + (this.node.params.length === 1 ? '' : ')') + - ' => ...' + ' => ...' } // TODO: Investigate how relevant this really is. // .fun seems to only be used in interpreter's NewExpression handler, which uses .fun.prototype.