Skip to content
This repository has been archived by the owner on Sep 10, 2023. It is now read-only.

Commit

Permalink
refactor: update
Browse files Browse the repository at this point in the history
  • Loading branch information
axetroy committed Mar 6, 2018
1 parent afbef33 commit b560609
Show file tree
Hide file tree
Showing 27 changed files with 4,225 additions and 282 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules
build
.vscode
*.log
.nyc_output
.nyc_output
.DS_Store
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"babylon": "^6.18.0"
},
"devDependencies": {
"@axetroy/libpack": "^0.6.4",
"@types/babel-core": "^6.25.3",
"@types/node": "^9.4.6",
"ava": "^0.25.0",
Expand Down
10 changes: 3 additions & 7 deletions src/evaluate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@ import {
ErrDuplicateDeclard,
ErrUnexpectedToken
} from "./error";
import {EvaluateFunc} from "./type";
import {Scope, ScopeVar, Kind} from "./scope";
import {
_classCallCheck,
_createClass,
_possibleConstructorReturn,
_inherits,
_extends,
_toConsumableArray
} from "./runtime";
import {debug} from "util";

const BREAK_SINGAL: {} = {};
const CONTINUE_SINGAL: {} = {};
Expand Down Expand Up @@ -221,7 +218,7 @@ const evaluate_map = {
ForStatement(node: types.ForStatement, scope: Scope) {
for (
const new_scope = scope.$child("loop"),
init_val = node.init ? evaluate(node.init, new_scope) : null;
_ = node.init ? evaluate(node.init, new_scope) : null;
node.test ? evaluate(node.test, new_scope) : true;
node.update ? evaluate(node.update, new_scope) : void 0
) {
Expand Down Expand Up @@ -380,9 +377,6 @@ const evaluate_map = {
return this_val ? this_val.$get() : null;
},
ArrayExpression(node: types.ArrayExpression, scope: Scope) {
const gotSpreadElement: boolean = !!node.elements.find(v =>
types.isSpreadElement(v)
);
let newArray: any[] = [];
node.elements.forEach(item => {
if (types.isSpreadElement(item)) {
Expand Down Expand Up @@ -782,6 +776,8 @@ const evaluate_map = {
}
};

export type EvaluateFunc = (node: types.Node, scope: Scope, arg?: any) => any;

export default function evaluate(
node: types.Node,
scope: Scope,
Expand Down
80 changes: 0 additions & 80 deletions src/type.ts

This file was deleted.

1 change: 0 additions & 1 deletion test/ArrayExpression.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import test from "ava";
import * as fs from "fs";

import vm from "../src/vm";

Expand Down
2 changes: 0 additions & 2 deletions test/ArrowFunctionExpression.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import test from "ava";
import * as fs from "fs";

import vm from "../src/vm";

test("ArrowFunctionExpression-1", t => {
Expand Down
4 changes: 1 addition & 3 deletions test/ClassDeclaration.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import test from "ava";
import * as fs from "fs";

import vm from "../src/vm";

test("ClassDeclaration-contructor", t => {
Expand Down Expand Up @@ -120,7 +118,7 @@ module.exports = People;
test("ClassDeclaration-extends", t => {
const sandbox: any = vm.createContext({});

const {Life, People} = vm.runInContext(
const {People} = vm.runInContext(
`
class Life{
eat(){
Expand Down
2 changes: 0 additions & 2 deletions test/ConditionalExpression.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import test from "ava";
import * as fs from "fs";

import vm from "../src/vm";

test("ConditionalExpression-1", t => {
Expand Down
2 changes: 0 additions & 2 deletions test/DoWhileStatement.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import test from "ava";
import * as fs from "fs";

import vm from "../src/vm";

test("DoWhileStatement-1", t => {
Expand Down
2 changes: 0 additions & 2 deletions test/ForInStatement.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import test from "ava";
import * as fs from "fs";

import vm from "../src/vm";

test("ForInStatement-1", t => {
Expand Down
2 changes: 0 additions & 2 deletions test/ForStatement.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import test from "ava";
import * as fs from "fs";

import vm from "../src/vm";

test("ForStatement-1", t => {
Expand Down
2 changes: 0 additions & 2 deletions test/FunctionExpression.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import test from "ava";
import * as fs from "fs";

import vm from "../src/vm";

test("FunctionExpression-1", t => {
Expand Down
1 change: 0 additions & 1 deletion test/Hoisting.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import test from "ava";

import vm from "../src/vm";
import {ErrNotDefined} from "../src/error";

Expand Down
2 changes: 0 additions & 2 deletions test/IfStatement.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import test from "ava";
import * as fs from "fs";

import vm from "../src/vm";

test("IfStatement-1", t => {
Expand Down
2 changes: 0 additions & 2 deletions test/LogicalExpression.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import test from "ava";
import * as fs from "fs";

import vm from "../src/vm";

test("LogicalExpression-or-1", t => {
Expand Down
2 changes: 0 additions & 2 deletions test/NewExpression.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import test from "ava";
import * as fs from "fs";

import vm from "../src/vm";

test("NewExpression", t => {
Expand Down
2 changes: 0 additions & 2 deletions test/ObjectDestructuringExpression.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import test from "ava";
import * as fs from "fs";

import vm from "../src/vm";

test("ObjectDestructuringExpression-object", t => {
Expand Down
2 changes: 0 additions & 2 deletions test/ObjectExpression.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import test from "ava";
import * as fs from "fs";

import vm from "../src/vm";

test("ObjectExpression", t => {
Expand Down
2 changes: 0 additions & 2 deletions test/RegExpLiteral.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import test from "ava";
import * as fs from "fs";

import vm from "../src/vm";

test("RegExpLiteral", t => {
Expand Down
2 changes: 0 additions & 2 deletions test/SpreadElement.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import test from "ava";
import * as fs from "fs";

import vm from "../src/vm";

test("SpreadElement-1", t => {
Expand Down
2 changes: 0 additions & 2 deletions test/SwitchStatement.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import test from "ava";
import * as fs from "fs";

import vm from "../src/vm";

test("SwitchStatement", t => {
Expand Down
2 changes: 0 additions & 2 deletions test/TemplateLiteral.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import test from "ava";
import * as fs from "fs";

import vm from "../src/vm";

test("TemplateLiteral-1", t => {
Expand Down
2 changes: 0 additions & 2 deletions test/ThisExpression.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import test from "ava";
import * as fs from "fs";

import vm from "../src/vm";

test("ThisExpression", t => {
Expand Down
2 changes: 0 additions & 2 deletions test/TryStatement.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import test from "ava";
import * as fs from "fs";

import vm from "../src/vm";

test("TryStatement", t => {
Expand Down
2 changes: 0 additions & 2 deletions test/UnaryExpression.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import test from "ava";
import * as fs from "fs";

import vm from "../src/vm";

test("UnaryExpression-typeof", t => {
Expand Down
2 changes: 0 additions & 2 deletions test/WhileStatement.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import test from "ava";
import * as fs from "fs";

import vm from "../src/vm";

test("WhileStatement-1", t => {
Expand Down
Loading

0 comments on commit b560609

Please sign in to comment.