Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
rk4718
wacc_26_web_client
Commits
c7a5d217
Commit
c7a5d217
authored
Mar 13, 2020
by
Raghav Khanna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check for error before proccessing graph
parent
c8a32334
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
110 additions
and
94 deletions
+110
-94
src/App.js
src/App.js
+110
-94
No files found.
src/App.js
View file @
c7a5d217
...
...
@@ -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
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment