Commit c7a5d217 authored by Raghav Khanna's avatar Raghav Khanna

Check for error before proccessing graph

parent c8a32334
......@@ -37,21 +37,24 @@ class App extends React.Component {
endRow: 0,
endCol: 0,
className: "",
type: ""}],
type: ""
}],
js: [{
startRow: 0,
startCol: 0,
endRow: 0,
endCol: 0,
className: "",
type: ""}],
type: ""
}],
arm: [{
startRow: 0,
startCol: 0,
endRow: 0,
endCol: 0,
className: "",
type: ""}]
type: ""
}]
},
children: [{}]
}
......@@ -84,7 +87,9 @@ class App extends React.Component {
readInputCallBack = (codeToEval) => {
eval(codeToEval);
window.EMULATOR_CONSOLE_READ = () => { return window.prompt()};
window.EMULATOR_CONSOLE_READ = () => {
return window.prompt()
};
};
clearConsole = () => {
......@@ -110,31 +115,37 @@ class App extends React.Component {
};
proccesLine = () => {
if(this.state.statementIndex < this.state.mainStatements.length){
if (this.state.statementIndex < this.state.mainStatements.length) {
let current = this.state.currentNode;
let jsLines = this.state.js.code.split(/;\n(?!})/);
// console.log(jsLines)
// console.log(current)
let codeLine = jsLines[current.highlighting.js[0].startRow];
codeLine = codeLine.replace("var ", "window.");
eval(codeLine);;
eval(codeLine);
;
let newIndex = this.state.statementIndex + 1;
this.setState({
currentNode: this.state.mainStatements[newIndex],
statementIndex: newIndex})
statementIndex: newIndex
})
} else {
console.log("Finished executing code")
}
};
getStatements = () => {
if (typeof this.state.graphData.children !== "undefined") {
let rootChildren = this.state.graphData.children;
let funcMain = rootChildren[rootChildren.length - 1];
let mainFuncStatementsNode = funcMain.children[0];
let mainFuncStatements = mainFuncStatementsNode.children;
this.setState({mainStatements: mainFuncStatements,
this.setState({
mainStatements: mainFuncStatements,
currentNode: mainFuncStatements[0],
statementIndex: 0})
statementIndex: 0
})
}
};
render() {
......@@ -148,16 +159,21 @@ class App extends React.Component {
<ButtonStrip
onCompileClick={(e) => {
this.processWaccCode(this.state.wacc.code).then(() => {
if (typeof this.state.graphData.children !== "undefined") {
this.clearConsole()
this.getStatements()})
this.getStatements()
}
}
)
}}
onExecuteClick={(e) => {
eval(this.state.js.code)
eval("waccPrintFinished()")
}}
onStepWaccClick={(e) => {
this.readInputCallBack(e)
this.proccesLine()
}}
/>
</CardBody>
</Card>
......@@ -235,6 +251,6 @@ class App extends React.Component {
</div>
)
}
}
}
export default App;
export default App;
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