Browse Source

add Super node

value-tracking
Rich Harris 8 years ago
parent
commit
bc788047ce
  1. 6
      src/ast/nodes/Identifier.js
  2. 13
      src/ast/nodes/Super.js
  3. 2
      src/ast/nodes/index.js
  4. 1
      test/form/dedupes-external-imports/_config.js

6
src/ast/nodes/Identifier.js

@ -17,6 +17,12 @@ function isAssignmentPatternLhs ( node, parent ) {
} }
export default class Identifier extends Node { export default class Identifier extends Node {
activate () {
if ( this.declaration ) {
this.declaration.activate();
}
}
bind ( scope ) { bind ( scope ) {
if ( isReference( this, this.parent ) || isAssignmentPatternLhs( this, this.parent ) ) { if ( isReference( this, this.parent ) || isAssignmentPatternLhs( this, this.parent ) ) {
this.declaration = scope.findDeclaration( this.name ); this.declaration = scope.findDeclaration( this.name );

13
src/ast/nodes/Super.js

@ -0,0 +1,13 @@
import Node from '../Node.js';
export default class Super extends Node {
call ( context, args ) {
const classDeclaration = this.findParent( /ClassDeclaration/ );
context = 'TODO';
classDeclaration.call( context, args ); // TODO call constructor, not the class itself...
}
markReturnStatements () {
// noop?
}
}

2
src/ast/nodes/index.js

@ -27,6 +27,7 @@ import NewExpression from './NewExpression.js';
import ObjectExpression from './ObjectExpression.js'; import ObjectExpression from './ObjectExpression.js';
import ReturnStatement from './ReturnStatement.js'; import ReturnStatement from './ReturnStatement.js';
import Statement from './shared/Statement.js'; import Statement from './shared/Statement.js';
import Super from './Super.js';
import TemplateLiteral from './TemplateLiteral.js'; import TemplateLiteral from './TemplateLiteral.js';
import ThisExpression from './ThisExpression.js'; import ThisExpression from './ThisExpression.js';
import ThrowStatement from './ThrowStatement.js'; import ThrowStatement from './ThrowStatement.js';
@ -65,6 +66,7 @@ export default {
NewExpression, NewExpression,
ObjectExpression, ObjectExpression,
ReturnStatement, ReturnStatement,
Super,
SwitchStatement: Statement, SwitchStatement: Statement,
TemplateLiteral, TemplateLiteral,
ThisExpression, ThisExpression,

1
test/form/dedupes-external-imports/_config.js

@ -1,4 +1,5 @@
module.exports = { module.exports = {
solo: true,
description: 'dedupes external imports', description: 'dedupes external imports',
options: { options: {
external: [ 'external' ], external: [ 'external' ],

Loading…
Cancel
Save