mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-04-22 20:48:01 +00:00
Add all resolc dependencies to resolc_web.js file (#176)
This commit is contained in:
committed by
GitHub
parent
374563bbe5
commit
79ec4dd04b
+55
-52
@@ -1,54 +1,57 @@
|
||||
var Module = {
|
||||
stdinData: null,
|
||||
stdinDataPosition: 0,
|
||||
stdoutData: [],
|
||||
stderrData: [],
|
||||
Module.stdinData = null;
|
||||
Module.stdinDataPosition = 0;
|
||||
Module.stdoutData = [];
|
||||
Module.stderrData = [];
|
||||
|
||||
// Function to read and return all collected stdout data as a string
|
||||
readFromStdout: function() {
|
||||
if (!this.stdoutData.length) return "";
|
||||
const decoder = new TextDecoder('utf-8');
|
||||
const data = decoder.decode(new Uint8Array(this.stdoutData));
|
||||
this.stdoutData = [];
|
||||
return data;
|
||||
},
|
||||
|
||||
// Function to read and return all collected stderr data as a string
|
||||
readFromStderr: function() {
|
||||
if (!this.stderrData.length) return "";
|
||||
const decoder = new TextDecoder('utf-8');
|
||||
const data = decoder.decode(new Uint8Array(this.stderrData));
|
||||
this.stderrData = [];
|
||||
return data;
|
||||
},
|
||||
|
||||
// Function to set input data for stdin
|
||||
writeToStdin: function(data) {
|
||||
const encoder = new TextEncoder();
|
||||
this.stdinData = encoder.encode(data);
|
||||
this.stdinDataPosition = 0;
|
||||
},
|
||||
|
||||
// `preRun` is called before the program starts running
|
||||
preRun: function() {
|
||||
// Define a custom stdin function
|
||||
function customStdin() {
|
||||
if (!Module.stdinData || Module.stdinDataPosition >= Module.stdinData.length) {
|
||||
return null; // End of input (EOF)
|
||||
}
|
||||
return Module.stdinData[Module.stdinDataPosition++];
|
||||
}
|
||||
|
||||
// Define a custom stdout function
|
||||
function customStdout(char) {
|
||||
Module.stdoutData.push(char);
|
||||
}
|
||||
|
||||
// Define a custom stderr function
|
||||
function customStderr(char) {
|
||||
Module.stderrData.push(char);
|
||||
}
|
||||
|
||||
FS.init(customStdin, customStdout, customStderr);
|
||||
},
|
||||
// Method to read all collected stdout data
|
||||
Module.readFromStdout = function () {
|
||||
if (!Module.stdoutData.length) return "";
|
||||
const decoder = new TextDecoder("utf-8");
|
||||
const data = decoder.decode(new Uint8Array(Module.stdoutData));
|
||||
Module.stdoutData = [];
|
||||
return data;
|
||||
};
|
||||
|
||||
// Method to read all collected stderr data
|
||||
Module.readFromStderr = function () {
|
||||
if (!Module.stderrData.length) return "";
|
||||
const decoder = new TextDecoder("utf-8");
|
||||
const data = decoder.decode(new Uint8Array(Module.stderrData));
|
||||
Module.stderrData = [];
|
||||
return data;
|
||||
};
|
||||
|
||||
// Method to write data to stdin
|
||||
Module.writeToStdin = function (data) {
|
||||
const encoder = new TextEncoder();
|
||||
Module.stdinData = encoder.encode(data);
|
||||
Module.stdinDataPosition = 0;
|
||||
};
|
||||
|
||||
// Override the `preRun` method to customize file system initialization
|
||||
Module.preRun = Module.preRun || [];
|
||||
Module.preRun.push(function () {
|
||||
// Custom stdin function
|
||||
function customStdin() {
|
||||
if (
|
||||
!Module.stdinData ||
|
||||
Module.stdinDataPosition >= Module.stdinData.length
|
||||
) {
|
||||
return null; // End of input (EOF)
|
||||
}
|
||||
return Module.stdinData[Module.stdinDataPosition++];
|
||||
}
|
||||
|
||||
// Custom stdout function
|
||||
function customStdout(char) {
|
||||
Module.stdoutData.push(char);
|
||||
}
|
||||
|
||||
// Custom stderr function
|
||||
function customStderr(char) {
|
||||
Module.stderrData.push(char);
|
||||
}
|
||||
|
||||
// Initialize the FS (File System) with custom handlers
|
||||
FS.init(customStdin, customStdout, customStderr);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user