Skip to content

Add Visitor Pass #727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 79 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
b8e8ee1
Added all dependencies to library files
willemneal Apr 16, 2019
c161742
Works but requires reading in all files
willemneal May 17, 2019
ff91130
Working
willemneal May 17, 2019
a380ed4
freeze
willemneal May 17, 2019
277853e
Working but need to add test
willemneal May 17, 2019
1dae71a
Merge remote-tracking branch 'upstream/master' into module_resolution
willemneal Jun 6, 2019
ef9ebdf
Merge remote-tracking branch 'upstream/master' into module_resolution
willemneal Jun 13, 2019
0c42af4
Updated to lazily find packages
willemneal Jun 13, 2019
af33db0
Update dist files
willemneal Jun 13, 2019
cd875dc
Added tests
willemneal Jun 14, 2019
6ffb5ff
Fixed output for resolution trace and file list
willemneal Jun 14, 2019
5869b57
Reverted dist files
willemneal Jun 14, 2019
b9a29b7
Actually revert dist files and add PR to tests
willemneal Jun 14, 2019
0e3f1a8
I really mean it this time
willemneal Jun 14, 2019
671d49c
For some reason it says it doesn't exist on master...
willemneal Jun 14, 2019
7d4e478
Copied from master
willemneal Jun 14, 2019
deb8942
forgot a space
willemneal Jun 14, 2019
92e03e5
change but it says file contents unchanged
willemneal Jun 14, 2019
29ac93e
Changed output to stderr and removed template literals
willemneal Jun 14, 2019
9b8a1d3
Removed all dependencies
willemneal Jun 14, 2019
79c08f2
Update .gitignore
willemneal Jun 15, 2019
84d2429
Update .gitignore
willemneal Jun 15, 2019
e5beacf
Format comment
willemneal Jun 15, 2019
117ce01
Fix PR issues
willemneal Jun 19, 2019
c7f6ad0
wrapped JSON.parse in a try/catch
Jun 19, 2019
1c86edc
nit fixes
willemneal Jun 20, 2019
edcf1a0
Search node_modules by default
willemneal Jun 21, 2019
78907a1
Merge remote-tracking branch 'upstream/master' into module_resolution
willemneal Jun 28, 2019
50c2342
Add dependee to backlog
willemneal Jun 28, 2019
1b0c4d7
imports start search from dependee
willemneal Jul 1, 2019
aad9ed2
switch to destructuring instead of flat()
willemneal Jul 1, 2019
9f42e76
Changed back to C-like API
willemneal Jul 1, 2019
df4f0df
Removed use of unix test command
willemneal Jul 4, 2019
aa92094
Change script field and change to regex.test
willemneal Jul 4, 2019
f36d31d
Travis test
willemneal Jul 4, 2019
915761c
simplified regex and added flag
willemneal Jul 4, 2019
fad255a
Print out more info
willemneal Jul 4, 2019
8db83c6
Try again
willemneal Jul 4, 2019
4dba3d8
Should work now
willemneal Jul 4, 2019
1795bca
Made hard copies of dependencies for better windows support
willemneal Jul 5, 2019
204791e
formatting [skip ci]
willemneal Jul 5, 2019
5284af8
First step to adding visitor pattern for AST
willemneal Jul 5, 2019
0d8a68b
Added base and printer visitor
willemneal Jul 5, 2019
7317e85
Added test file and implemented more methods
willemneal Jul 6, 2019
42342da
Added Base class
willemneal Jul 8, 2019
9aa137b
Removed using npm all together
willemneal Jul 8, 2019
9d5f39b
Merge remote-tracking branch 'upstream/master' into ast_visitor
willemneal Jul 8, 2019
84fb799
program ast
willemneal Jul 11, 2019
44072a4
Interfaces methods are now noop stubs
willemneal Jul 11, 2019
025ef72
refactor to make more clear
willemneal Jul 11, 2019
55b7f05
Removed all package.json files and scripts
willemneal Jul 12, 2019
02d847a
formatting
willemneal Jul 12, 2019
c7496c2
removed sysPaths from parser and moved to map in asc
Jul 12, 2019
87b6b5f
Changed to map paths to sources
Jul 12, 2019
bffa751
formatting and replaced regex replace
Jul 12, 2019
78a84b3
Fix sep constant and g's test
Jul 12, 2019
afe3276
Removed default baseDir in nodeFileRead
Jul 12, 2019
040fe22
Last nit fixes
Jul 15, 2019
33a742b
Moved virtual to outside of the project.
Jul 15, 2019
b5ff118
Tested on different computer and added script to build visitor
willemneal Jul 15, 2019
e4ca804
Formatting
willemneal Jul 16, 2019
1e29ad2
[skip ci]
willemneal Jul 16, 2019
4a53df2
Improved trace information
willemneal Jul 16, 2019
ed7eb64
fix split of internal path to `/`
willemneal Jul 16, 2019
2c94848
nit [skip ci]
willemneal Jul 16, 2019
a433431
Moved to lib folder
willemneal Jul 16, 2019
e50f4ea
added more to base and added empty
willemneal Jul 17, 2019
45b902e
Added abstract visitor with overloaded visit method
willemneal Jul 17, 2019
86ab897
Fixed instances to use new base visitor
willemneal Jul 17, 2019
590d8fa
Merge branch 'module_resolution' into ast_visitor
willemneal Jul 17, 2019
22b4e04
Trying to get to class instances
willemneal Jul 17, 2019
0b944cd
visit file
willemneal Jul 20, 2019
bc1b2d5
Fix merge
willemneal Jul 20, 2019
d4d4cd8
Merge remote-tracking branch 'upstream/master' into ast_visitor
willemneal Jul 23, 2019
1659538
pass travis
willemneal Jul 24, 2019
b7826d4
Fix ts-lint
willemneal Jul 24, 2019
f448665
Sorta works, but very hacky
Jul 25, 2019
edb6996
Virtual table no longer hard wired
willemneal Jul 31, 2019
e9c4a39
Cleaned up test
willemneal Aug 1, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions cli/asc.js
Original file line number Diff line number Diff line change
Expand Up @@ -583,12 +583,14 @@ exports.main = function main(argv, options, callback) {
assemblyscript.enableFeature(compilerOptions, flag);
}
}


var compiler
var module;
stats.compileCount++;
try {
stats.compileTime += measure(() => {
module = assemblyscript.compileProgram(program, compilerOptions);
compiler = assemblyscript.initializeCompiler(program, compilerOptions);
module = compiler.compile();
});
} catch (e) {
return callback(e);
Expand All @@ -598,6 +600,24 @@ exports.main = function main(argv, options, callback) {
return callback(Error("Compile error"));
}

// Call each visitor
if (args.postCompile) {
let visitors = []
try {
for (let filename of args.postCompile) {
let _filename = path.isAbsolute(filename = filename.trim())
? filename
: path.join(process.cwd(), filename)
visitors.push(require(_filename).default);
}
visitors.forEach(visitor => {
(new visitor(parser, compiler, stderr)).start();
});
} catch (e) {
return callback(e);
}
}

// Validate the module if requested
if (args.validate) {
stats.validateCount++;
Expand Down
23 changes: 22 additions & 1 deletion cli/asc.json
Original file line number Diff line number Diff line change
Expand Up @@ -242,5 +242,26 @@
"-O0z": { "value": { "optimizeLevel": 0, "shrinkLevel": 2 } },
"-O1z": { "value": { "optimizeLevel": 1, "shrinkLevel": 2 } },
"-O2z": { "value": { "optimizeLevel": 2, "shrinkLevel": 2 } },
"-O3z": { "value": { "optimizeLevel": 3, "shrinkLevel": 2 } }
"-O3z": { "value": { "optimizeLevel": 3, "shrinkLevel": 2 } },
"path": {
"description": [
"Comma separated paths to look for dependencies.",
"Looks for folders with package.json that includes a 'ascMain' field",
"or defaults to having an '/assembly' folder."],
"type": "S"
},
"traceResolution": {
"description": "Enable tracing of package resolution.",
"type": "b",
"default": false
},
"listFiles": {
"description": "List files to be compiled and exit.",
"type": "b",
"default": false
},
"postCompile": {
"description": "A pass over the program after compiling to Binaryen IR",
"type": "S"
}
}
16 changes: 16 additions & 0 deletions cli/postCompile.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Definitions for custom compiler transforms that can be applied with the `--postCompile` option.
* @module cli/postTransform
*//***/

import { Parser } from "../src/parser";
import { Compiler } from "../src/compiler";

interface stderr {
write: (str: string)=> void;
}
export interface Vistor {
new(parser: Parser, compiler: Compiler, writer: stderr);
start(): void;
}

76 changes: 76 additions & 0 deletions lib/visitor/as-pect.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
module.exports = {
/**
* A set of globs passed to the glob package that qualify typescript files for testing.
*/
include: ["assembly/__tests__/**/*.spec.ts"],
/**
* A set of globs passed to the glob package that quality files to be added to each test.
*/
add: ["assembly/__tests__/**/*.include.ts"],
/**
* All the compiler flags needed for this test suite. Make sure that a binary file is output.
*/
flags: {
"--validate": [],
"--debug": [],
/** This is required. Do not change this. The filename is ignored, but required by the compiler. */
"--binaryFile": ["output.wasm"],
/** To enable wat file output, use the following flag. The filename is ignored, but required by the compiler. */
"--textFile": ["output.wat"],
/** To select an appropriate runtime, use the --runtime compiler flag. */
"--runtime": ["stub"], // Acceptable values are: full, half, stub (arena), and none,
"--baseDir": process.cwd(),
"--postCompile": "dist/instances/virtual.js",
},
/**
* A set of regexp that will disclude source files from testing.
*/
disclude: [/node_modules/],
/**
* Add your required AssemblyScript imports here.
*/
imports: {},
/**
* All performance statistics reporting can be configured here.
*/
performance: {
/** Enable performance statistics gathering for every test. */
enabled: false,
/** Set the maximum number of samples to run for every test. */
maxSamples: 10000,
/** Set the maximum test run time in milliseconds for every test. */
maxTestRunTime: 5000,
/** Report the median time in the default reporter for every test. */
reportMedian: true,
/** Report the average time in milliseconds for every test. */
reportAverage: true,
/** Report the standard deviation for every test. */
reportStandardDeviation: false,
/** Report the maximum run time in milliseconds for every test. */
reportMax: false,
/** Report the minimum run time in milliseconds for every test. */
reportMin: false,
},
/**
* Add a custom reporter here if you want one. The following example is in typescript.
*
* @example
* import { TestReporter, TestGroup, TestResult, TestContext } from "as-pect";
*
* export class CustomReporter extends TestReporter {
* // implement each abstract method here
* public abstract onStart(suite: TestContext): void;
* public abstract onGroupStart(group: TestGroup): void;
* public abstract onGroupFinish(group: TestGroup): void;
* public abstract onTestStart(group: TestGroup, result: TestResult): void;
* public abstract onTestFinish(group: TestGroup, result: TestResult): void;
* public abstract onFinish(suite: TestContext): void;
* }
*/
// reporter: new CustomReporter(),
/**
* Specify if the binary wasm file should be written to the file system.
*/
outputBinary: false,
compiler: "../.."
};
Loading