Commit d473c2ca authored by d11e9's avatar d11e9

show usage in ballot

parent 47c7f112
......@@ -24,7 +24,13 @@
var multi = function(func) { return func.toString().match(/[^]*\/\*([^]*)\*\/\}$/)[1]; }
var BALLOT_EXAMPLE = multi(function(){/*contract Ballot {
var BALLOT_EXAMPLE = multi(function(){/*
// create a new file called 'test' :)
import "test";
contract Ballot {
struct Voter {
uint weight;
bool voted;
......
......@@ -285,12 +285,11 @@ THE SOFTWARE.
editor.getSession().clearAnnotations();
sourceAnnotations = [];
editor.getSession().removeMarker(errMarkerId);
$('#output').empty();
var input = editor.getValue();
$('#output').empty();
var input = editor.getValue();
var inputIncludingImports = includeLocalImports( input );
console.log( inputIncludingImports )
var optimize = document.querySelector('#optimize').checked;
try {
var optimize = document.querySelector('#optimize').checked;
try {
var data = $.parseJSON(compileJSON(inputIncludingImports, optimize ? 1 : 0));
} catch (exception) {
renderError("Uncaught JavaScript Exception:\n" + exception);
......@@ -325,15 +324,14 @@ THE SOFTWARE.
$('#version').text(Module.cwrap("version", "string", [])());
previousInput = '';
onChange();
};
};
function includeLocalImports( input ) {
var importRegex = /import\s[\'\"]([^\'\"]+)[\'\"]/g
var importRegex = /import\s[\'\"]([^\'\"]+)[\'\"];/g
var imports = [];
var matches = [];
var match;
while ((match = importRegex.exec(input)) !== null) {
console.log("match:", match[0])
if (match[1] && solFiles.indexOf(match[1]) !== -1) {
imports.push( match[1] )
matches.push( match[0] )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment