remix-project mirror
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
remix-project/test-browser/mockcompiler/compiler.js

42 lines
1.0 KiB

8 years ago
var Module = { // eslint-disable-line
cwrap: function () { return arguments[0] === 'version' ? version : compile },
8 years ago
writeStringToMemory: function () {},
setValue: function () {},
Pointer_stringify: function () {},
Runtime: {
addFunction: function () {},
removeFunction: function () {}
},
_compileJSONMulti: {},
_compileJSONCallback: {},
_compileJSON: {}
}
8 years ago
function compile (source, optimization, missingInputs) {
if (typeof source === 'string') {
source = JSON.parse(source)
8 years ago
}
var key = optimization.toString()
8 years ago
for (var k in source.sources) {
key += k + source.sources[k]
8 years ago
}
key = key.replace(/(\t)|(\n)|( )/g, '')
var data = mockData[key] // eslint-disable-line
8 years ago
if (data === undefined) {
return JSON.stringify({
errors: ['mock compiler: source not found']
})
8 years ago
} else {
data.missingInputs.map(function (item, i) {
if (missingInputs) {
missingInputs(item)
8 years ago
}
})
8 years ago
}
return JSON.stringify(data.result)
8 years ago
}
function version () {
return 'mock compiler'
8 years ago
}