@ -56,4 +56,9 @@ export default class BlockStatement extends Statement {
code.remove( this.start, this.next || this.end );
}
run () {
this.scope.initialise();
this.body.forEach( node => node.run() );
@ -91,7 +91,13 @@ export default class Identifier extends Node {
return this.scope.getValue( this.name );
const value = this.scope.getValue( this.name );
if ( !value ) {
console.log( this.name, this.scope.values )
return value;
setValue ( value ) {
@ -133,8 +133,7 @@ export default class MemberExpression extends Node {
const propValue = this.computed ? this.property.run() : this.property.name;
if ( !objectValue ) {
console.log( this.object )
console.log( `${this}` )
console.log( `${this.object} does not contain a value` );
if ( !objectValue.setProperty ) {
@ -23,7 +23,7 @@ export default class FunctionValue {
this.node.isCalling = true;
let returnValue;
this.node.body.scope.initialise();
this.node.body.scope.initialise(); // TODO arrow functions...
args.forEach( ( arg, i ) => {
const param = this.node.params[i];
@ -1,6 +1,7 @@
import Scope from './Scope.js';
import { unknown } from '../values';
// TODO represent things like Array, encodeURIComponent, Math, whatever
class SyntheticGlobalDeclaration {
constructor ( name ) {
this.name = name;
@ -21,7 +22,7 @@ class SyntheticGlobalDeclaration {
call ( args ) {
// TODO assume args can be called?
return unknown;
gatherPossibleValues ( values ) {
@ -107,6 +107,10 @@ export default class Scope {
getValue ( name ) {
if ( name === 'x' ) {
console.log( `this.values`, this.values )
if ( name in this.values ) {
return this.values[ name ];
@ -1,4 +1,5 @@
module.exports = {
solo: true,
description: 'use of arguments is treated as a side-effect',
options: {
moduleName: 'myBundle'