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/apps/remix-ide/test-browser/mockcompiler/compiler.js

39 lines
1.0 KiB

'use strict'
8 years ago
var Module = { // eslint-disable-line
7 years ago
cwrap: function () { return arguments[0] === 'version' ? version : compileStandard },
8 years ago
writeStringToMemory: function () {},
setValue: function () {},
Pointer_stringify: function (value) { return value },
8 years ago
Runtime: {
addFunction: function () { return arguments[0] },
8 years ago
removeFunction: function () {}
},
_compileJSONMulti: {},
_compileJSONCallback: {},
_compileJSON: {},
7 years ago
_malloc: function () {},
_compileStandard: compileStandard
}
8 years ago
7 years ago
function compileStandard (source, missingInputs) {
source = source.replace(/(\t)|(\n)|(\\n)|( )/g, '')
var data = mockData[source] // eslint-disable-line
8 years ago
if (data === undefined) {
return JSON.stringify({
7 years ago
errors: [{ formattedMessage: 'mock compiler: source not found', severity: 'error' }]
})
8 years ago
} else {
data.missingInputs.map(function (item, i) {
if (missingInputs) {
missingInputs(item, '', '')
8 years ago
}
})
8 years ago
}
7 years ago
return data.result
8 years ago
}
function version () {
8 years ago
return mockCompilerVersion // eslint-disable-line
8 years ago
}