Commit 264f6513 authored by Matej Genci's avatar Matej Genci

Make printing without newline possible

parent 4dd3c938
...@@ -11,6 +11,20 @@ ...@@ -11,6 +11,20 @@
/> />
<script> <script>
var EMULATOR_CONSOLE_READ = () => { return window.prompt()}; var EMULATOR_CONSOLE_READ = () => { return window.prompt()};
// Fixes for printing with new lines.
let waccPrintingBuffer = ""
function waccPrint(str) {
printing_buffer += str
}
function waccPrintLn(str) {
waccPrint(str + "\n")
}
function waccPrintFinished() {
console.log(waccPrintingBuffer)
}
</script> </script>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" /> <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!-- <!--
......
...@@ -60,7 +60,10 @@ class App extends React.Component { ...@@ -60,7 +60,10 @@ class App extends React.Component {
clearConsole = () => { clearConsole = () => {
this.setState({consoleReset: this.state.consoleReset + 1}) this.setState({consoleReset: this.state.consoleReset + 1})
} }
processWaccCode = async (code) => { processWaccCode = async (code) => {
eval("waccPrintingBuffer = ''")
let rsp = await sendWaccCode(code); let rsp = await sendWaccCode(code);
let graph = this.state.graphData; let graph = this.state.graphData;
if (typeof rsp.isError !== "undefined") { if (typeof rsp.isError !== "undefined") {
...@@ -73,8 +76,6 @@ class App extends React.Component { ...@@ -73,8 +76,6 @@ class App extends React.Component {
graphData: graph graphData: graph
}) })
} }
} }
render() { render() {
...@@ -90,10 +91,11 @@ class App extends React.Component { ...@@ -90,10 +91,11 @@ class App extends React.Component {
this.processWaccCode(this.state.wacc.code) this.processWaccCode(this.state.wacc.code)
this.clearConsole() this.clearConsole()
}} }}
onStepJsClick={(e) => { onExecuteClick={(e) => {
this.setState({js: {code: "Hello World!"}}) eval(this.state.js.code)
eval("waccPrintFinished()")
}} }}
onStepOverAstClick={(e) => { onStepWaccClick={(e) => {
this.readInputCallBack(e) this.readInputCallBack(e)
}} }}
/> />
......
...@@ -25,7 +25,7 @@ function generateArmMarkers(lineNums) { ...@@ -25,7 +25,7 @@ function generateArmMarkers(lineNums) {
} }
function createGraphNode(node, astMeta){ function createGraphNode(node, astMeta){
let name = node.name; let name = node.name.replace("AST", "");
let value = node.value; let value = node.value;
let childrenIDs = node.children; let childrenIDs = node.children;
let children = []; let children = [];
......
...@@ -3,7 +3,9 @@ import ReactDOM from 'react-dom'; ...@@ -3,7 +3,9 @@ import ReactDOM from 'react-dom';
import './index.css'; import './index.css';
import App from './App'; import App from './App';
import * as serviceWorker from './serviceWorker'; import * as serviceWorker from './serviceWorker';
export var test = "" export var test = ""
ReactDOM.render(<App />, document.getElementById('root')); ReactDOM.render(<App />, document.getElementById('root'));
// If you want your app to work offline and load faster, you can change // If you want your app to work offline and load faster, you can change
......
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