...
 
Commits (3)
......@@ -11,6 +11,20 @@
/>
<script>
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>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
......
......@@ -90,7 +90,10 @@ class App extends React.Component {
clearConsole = () => {
this.setState({consoleReset: this.state.consoleReset + 1})
}
processWaccCode = async (code) => {
eval("waccPrintingBuffer = ''")
let rsp = await sendWaccCode(code);
let graph = this.state.graphData;
if (typeof rsp.isError !== "undefined") {
......@@ -148,12 +151,12 @@ class App extends React.Component {
this.clearConsole()
this.getStatements()})
}}
onStepWaccClick={(e) => {
this.proccesLine()
}}
onExecuteClick={(e) => {
// this.readInputCallBack(e)
eval(this.state.js.code)
eval("waccPrintFinished()")
}}
onStepWaccClick={(e) => {
this.readInputCallBack(e)
}}
/>
</CardBody>
......
......@@ -9,23 +9,31 @@ export function astMetaToGraphData(astMeta) {
return graphData
}
function generateMarkerObject(start, end, off = 0) {
function generateMarkerObject(start, end, off = 0, style="ast-node-highlight") {
return {
startRow: start.lineNum - 1,
startCol: start.charNum + off,
endRow: end.lineNum - 1,
endCol: end.charNum,
className: "ast-node-highlight",
className: style,
type: "text"
}
}
function generateArmMarkers(lineNums) {
return lineNums.map(ln => ({startRow: ln - 1, className: "ast-node-highlight", type: "background"}))
function generateArmMarkers(lineNums, style = "ast-node-highlight") {
return lineNums.map(ln => ({startRow: ln - 1, className: style, type: "background"}))
}
function highlightNode(node, style = "ast-node-highlight") {
return {
wacc: [generateMarkerObject(node.waccStart, node.waccEnd, style)],
js: typeof node.jsStart === "undefined" ? [{}] : [generateMarkerObject(node.jsStart, node.jsEnd, -1, style)],
arm: generateArmMarkers(node.armLineNums, style)
}
}
function createGraphNode(node, astMeta){
let name = node.name;
let name = node.name.replace("AST", "");
let value = node.value;
let childrenIDs = node.children;
let children = [];
......@@ -41,11 +49,7 @@ function createGraphNode(node, astMeta){
return {
name: name,
attributes: {value: value},
highlighting: {
wacc: [generateMarkerObject(node.waccStart, node.waccEnd)],
js: typeof node.jsStart === "undefined" ? [{}] : [generateMarkerObject(node.jsStart, node.jsEnd, -1)],
arm: generateArmMarkers(node.armLineNums)
},
highlighting: highlightNode(node),
children: children
}
......
......@@ -3,7 +3,9 @@ import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
export var test = ""
ReactDOM.render(<App />, document.getElementById('root'));
// If you want your app to work offline and load faster, you can change
......