Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add other assignment operator support
- Loading branch information
Showing
4 changed files
with
137 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
var origin = 10; | ||
var sum = origin; | ||
var minus = origin; | ||
var product = origin; | ||
var quotient = origin; | ||
var remainder = origin; | ||
|
||
sum += 10; | ||
minus -= 10; | ||
product *= 10; | ||
quotient /= 10; | ||
remainder %= 10; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
var foo = 10; | ||
var bar = foo = 20; | ||
|
||
var something; | ||
something = foo = 30; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
var esprima = require('esprima'); | ||
var dfatool = require('../dfatool'); | ||
var fs = require('fs'); | ||
var util = require('util'); | ||
var codegen = require('escodegen'); | ||
|
||
var argv = process.argv.slice(2); | ||
var fileName = argv[0]; | ||
|
||
if( ! fileName){ | ||
console.error("Input scripts needed, 'node outline.js cases/array.js'"); | ||
return; | ||
} | ||
fs.readFile(fileName, 'utf-8', function(err, data){ | ||
|
||
var ast = esprima.parse(data, { | ||
loc : true | ||
}); | ||
var globalScope = dfatool.globalScope | ||
dfatool.buildScope(ast, globalScope); | ||
|
||
globalScope.initialize(); | ||
globalScope.derivation() | ||
|
||
var outline = {}; | ||
for(var name in globalScope._defines){ | ||
var variable = globalScope._defines[name]; | ||
var value = variable.inference(); | ||
if( value ){ | ||
outline[variable.name] = value.toJSON(); | ||
} | ||
} | ||
|
||
console.log(util.inspect(outline, false, null)); | ||
|
||
dfatool.flushlog("log.txt"); | ||
}) |