Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
wacc_26_web_client
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rk4718
wacc_26_web_client
Commits
ca9d20b7
Commit
ca9d20b7
authored
Mar 12, 2020
by
Matej Genci
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mock responses from server
parent
e4c720cb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
465 additions
and
11 deletions
+465
-11
src/App.js
src/App.js
+17
-11
src/Comm.js
src/Comm.js
+448
-0
No files found.
src/App.js
View file @
ca9d20b7
...
...
@@ -7,6 +7,8 @@ import ButtonStrip from './view/ButonStrip'
import
CodeEditor
from
'
./view/CodeEditor
'
import
UserIO
from
'
./view/UserIO
'
import
{
sendWaccCode
,
astMetaToGraphData
}
from
'
./Comm
'
import
'
./App.css
'
;
class
App
extends
React
.
Component
{
...
...
@@ -25,7 +27,8 @@ class App extends React.Component {
arm
:
{
code
:
""
,
markers
:
[],
}
},
graphData
:
[{}],
}
}
...
...
@@ -38,11 +41,22 @@ class App extends React.Component {
})
}
processWaccCode
=
(
code
)
=>
{
let
rsp
=
sendWaccCode
(
code
)
let
graph
=
astMetaToGraphData
(
rsp
.
astMeta
)
this
.
setState
({
arm
:
{
code
:
rsp
.
armCode
},
js
:
{
code
:
rsp
.
jsCode
},
graphData
:
graph
})
}
render
()
{
return
(
<
div
className
=
"
App
"
>
<
ButtonStrip
onCompileClick
=
{(
e
)
=>
{
alert
(
"
Compiling wacc
\n\"
"
+
this
.
state
.
wacc
.
code
+
"
\"
"
)
}}
onCompileClick
=
{(
e
)
=>
{
this
.
processWaccCode
(
this
.
state
.
wacc
.
code
)
}}
onStepJsClick
=
{(
e
)
=>
{
this
.
setState
({
js
:
{
code
:
"
Hello World!
"
}})
}}
/
>
<
div
className
=
"
App-code-editors
"
>
...
...
@@ -63,7 +77,7 @@ class App extends React.Component {
<
div
id
=
"
treeWrapper
"
style
=
{{
width
:
'
50em
'
,
height
:
'
20em
'
,
background
:
'
white
'
}}
>
<
Tree
data
=
{
t
estG
raphData
}
data
=
{
t
his
.
state
.
g
raphData
}
orientation
=
"
vertical
"
/>
<
/div
>
...
...
@@ -73,12 +87,4 @@ class App extends React.Component {
}
}
const
testGraphData
=
[{
name
:
"
WACC Program
"
,
children
:
[{
name
:
"
BinOP
"
,
attributes
:
{
operation
:
"
Add
"
},
children
:
[{
name
:
"
Const
"
,
attributes
:
{
value
:
"
1
"
}
},
{
name
:
"
VarIdent
"
,
attributes
:
{
ident
:
"
x
"
}
}]
}]
}];
export
default
App
;
src/Comm.js
0 → 100644
View file @
ca9d20b7
import
React
from
'
react
'
import
axios
from
'
axios
'
const
SERVER_ADDR
=
"
http://localhost:3000/
"
const
SERVER_ENDPOINT
=
"
compile/wacc
"
const
testGraphData
=
[{
name
:
"
WACC Program
"
,
children
:
[{
name
:
"
BinOP
"
,
attributes
:
{
operation
:
"
Add
"
},
children
:
[{
name
:
"
Const
"
,
attributes
:
{
value
:
"
1
"
}
},
{
name
:
"
VarIdent
"
,
attributes
:
{
ident
:
"
x
"
}
}]
}]
}];
export
function
astMetaToGraphData
(
astMeta
)
{
return
testGraphData
}
export
function
sendWaccCode
(
code
)
{
let
ADDR
=
SERVER_ADDR
+
SERVER_ENDPOINT
console
.
log
(
`Sending
${
code
}
to
${
ADDR
}
`
)
axios
.
get
(
ADDR
)
.
then
(
res
=>
{
console
.
log
(
res
)
})
.
catch
(
reason
=>
{
console
.
log
(
reason
)
return
})
return
{
"
armCode
"
:
"
.data
\n\n
msg_0:
\n\t\t
.word 50
\n\t\t
.ascii
\"
NullReferenceError: dereference a null reference
\\
n
\\
0
\"\n
msg_1:
\n\t\t
.word 5
\n\t\t
.ascii
\"
%.*s
\\
0
\"\n
msg_2:
\n\t\t
.word 3
\n\t\t
.ascii
\"
%d
\\
0
\"\n\n\t\t
.text
\n\t\t\n\t\t
.global main
\n\t\t
main:
\n\t\t
PUSH {lr}
\n\t\t
SUB sp, sp, #12
\n\t\t
LDR r0, =8
\n\t\t
BL malloc
\n\t\t
MOV r4, r0
\n\t\t
LDR r5, =2
\n\t\t
LDR r0, =4
\n\t\t
BL malloc
\n\t\t
STR r0, [r4]
\n\t\t
STR r5, [r0]
\n\t\t
LDR r5, =3
\n\t\t
LDR r0, =4
\n\t\t
BL malloc
\n\t\t
STR r0, [r4, #4]
\n\t\t
STR r5, [r0]
\n\t\t
STR r4, [sp, #8]
\n\t\t
LDR r0, =8
\n\t\t
BL malloc
\n\t\t
MOV r4, r0
\n\t\t
LDR r5, =1
\n\t\t
LDR r0, =4
\n\t\t
BL malloc
\n\t\t
STR r0, [r4]
\n\t\t
STR r5, [r0]
\n\t\t
LDR r5, [sp, #8]
\n\t\t
LDR r0, =4
\n\t\t
BL malloc
\n\t\t
STR r0, [r4, #4]
\n\t\t
STR r5, [r0]
\n\t\t
STR r4, [sp, #4]
\n\t\t
LDR r0, =16
\n\t\t
BL malloc
\n\t\t
MOV r4, r0
\n\t\t
LDR r5, =3
\n\t\t
STR r5, [r0]
\n\t\t
LDR r5, =1
\n\t\t
STR r5, [r4, #4]
\n\t\t
LDR r5, =2
\n\t\t
STR r5, [r4, #8]
\n\t\t
LDR r5, =3
\n\t\t
STR r5, [r4, #12]
\n\t\t
STR r4, [sp]
\n\t\t
LDR r4, [sp, #4]
\n\t\t
MOV r0, r4
\n\t\t
BL p_check_null_pointer
\n\t\t
LDR r4, [r4]
\n\t\t
MOV r0, r4
\n\t\t
BL p_read_int
\n\t\t
ADD sp, sp, #12
\n\t\t
LDR r0, =0
\n\t\t
POP {pc}
\n\t\t
.ltorg
\n\t\t
p_check_null_pointer:
\n\t\t
PUSH {lr}
\n\t\t
CMP r0, #0
\n\t\t
LDREQ r0, =msg_0
\n\t\t
BLEQ p_throw_runtime_error
\n\t\t
POP {pc}
\n\t\t
p_throw_runtime_error:
\n\t\t
BL p_print_string
\n\t\t
MOV r0, #-1
\n\t\t
BL exit
\n\t\t
p_print_string:
\n\t\t
PUSH {lr}
\n\t\t
LDR r1, [r0]
\n\t\t
ADD r2, r0, #4
\n\t\t
LDR r0, =msg_1
\n\t\t
ADD r0, r0, #4
\n\t\t
BL printf
\n\t\t
MOV r0, #0
\n\t\t
BL fflush
\n\t\t
POP {pc}
\n\t\t
p_read_int:
\n\t\t
PUSH {lr}
\n\t\t
MOV r1, r0
\n\t\t
LDR r0, =msg_2
\n\t\t
ADD r0, r0, #4
\n\t\t
BL scanf
\n\t\t
POP {pc}
\n
"
,
"
jsCode
"
:
"
var p = {
\"
fst
\"
: 2,
\"
snd
\"
: 3 };
\n
var q = {
\"
fst
\"
: 1,
\"
snd
\"
: p };
\n
var a = [1, 2, 3,
\
b
\
b];
\n
q[
\"
fst
\"
] = window.prompt(
\"\"
);
\n
"
,
"
astMeta
"
:
{
"
nodes
"
:
{
"
3
"
:
{
"
name
"
:
"
Variable: p
"
,
"
children
"
:
[],
"
waccStart
"
:
{
"
lineNum
"
:
2
,
"
charNum
"
:
17
},
"
waccEnd
"
:
{
"
lineNum
"
:
2
,
"
charNum
"
:
18
},
"
armLineNums
"
:
[]
},
"
4
"
:
{
"
name
"
:
"
INT constant: 2
"
,
"
children
"
:
[],
"
waccStart
"
:
{
"
lineNum
"
:
2
,
"
charNum
"
:
29
},
"
waccEnd
"
:
{
"
lineNum
"
:
2
,
"
charNum
"
:
30
},
"
armLineNums
"
:
[
22
]
},
"
5
"
:
{
"
name
"
:
"
INT constant: 3
"
,
"
children
"
:
[],
"
waccStart
"
:
{
"
lineNum
"
:
2
,
"
charNum
"
:
32
},
"
waccEnd
"
:
{
"
lineNum
"
:
2
,
"
charNum
"
:
33
},
"
armLineNums
"
:
[
27
]
},
"
6
"
:
{
"
name
"
:
"
New pair
"
,
"
children
"
:
[
4
,
5
],
"
waccStart
"
:
{
"
lineNum
"
:
2
,
"
charNum
"
:
21
},
"
waccEnd
"
:
{
"
lineNum
"
:
2
,
"
charNum
"
:
34
},
"
armLineNums
"
:
[
19
,
20
,
21
,
23
,
24
,
25
,
26
,
28
,
29
,
30
,
31
]
},
"
7
"
:
{
"
name
"
:
"
Declare pair(INT, INT)
"
,
"
children
"
:
[
3
,
6
],
"
waccStart
"
:
{
"
lineNum
"
:
2
,
"
charNum
"
:
2
},
"
waccEnd
"
:
{
"
lineNum
"
:
2
,
"
charNum
"
:
34
},
"
armLineNums
"
:
[
32
],
"
jsStart
"
:
{
"
lineNum
"
:
1
,
"
charNum
"
:
1
},
"
jsEnd
"
:
{
"
lineNum
"
:
1
,
"
charNum
"
:
33
}
},
"
9
"
:
{
"
name
"
:
"
Variable: q
"
,
"
children
"
:
[],
"
waccStart
"
:
{
"
lineNum
"
:
3
,
"
charNum
"
:
18
},
"
waccEnd
"
:
{
"
lineNum
"
:
3
,
"
charNum
"
:
19
},
"
armLineNums
"
:
[]
},
"
10
"
:
{
"
name
"
:
"
INT constant: 1
"
,
"
children
"
:
[],
"
waccStart
"
:
{
"
lineNum
"
:
3
,
"
charNum
"
:
30
},
"
waccEnd
"
:
{
"
lineNum
"
:
3
,
"
charNum
"
:
31
},
"
armLineNums
"
:
[
36
]
},
"
11
"
:
{
"
name
"
:
"
Variable: p
"
,
"
children
"
:
[],
"
waccStart
"
:
{
"
lineNum
"
:
3
,
"
charNum
"
:
33
},
"
waccEnd
"
:
{
"
lineNum
"
:
3
,
"
charNum
"
:
34
},
"
armLineNums
"
:
[
41
]
},
"
12
"
:
{
"
name
"
:
"
New pair
"
,
"
children
"
:
[
10
,
11
],
"
waccStart
"
:
{
"
lineNum
"
:
3
,
"
charNum
"
:
22
},
"
waccEnd
"
:
{
"
lineNum
"
:
3
,
"
charNum
"
:
35
},
"
armLineNums
"
:
[
33
,
34
,
35
,
37
,
38
,
39
,
40
,
42
,
43
,
44
,
45
]
},
"
13
"
:
{
"
name
"
:
"
Declare pair(INT, pair)
"
,
"
children
"
:
[
9
,
12
],
"
waccStart
"
:
{
"
lineNum
"
:
3
,
"
charNum
"
:
2
},
"
waccEnd
"
:
{
"
lineNum
"
:
3
,
"
charNum
"
:
35
},
"
armLineNums
"
:
[
46
],
"
jsStart
"
:
{
"
lineNum
"
:
2
,
"
charNum
"
:
1
},
"
jsEnd
"
:
{
"
lineNum
"
:
2
,
"
charNum
"
:
33
}
},
"
15
"
:
{
"
name
"
:
"
Variable: a
"
,
"
children
"
:
[],
"
waccStart
"
:
{
"
lineNum
"
:
4
,
"
charNum
"
:
8
},
"
waccEnd
"
:
{
"
lineNum
"
:
4
,
"
charNum
"
:
9
},
"
armLineNums
"
:
[]
},
"
16
"
:
{
"
name
"
:
"
INT constant: 1
"
,
"
children
"
:
[],
"
waccStart
"
:
{
"
lineNum
"
:
4
,
"
charNum
"
:
13
},
"
waccEnd
"
:
{
"
lineNum
"
:
4
,
"
charNum
"
:
14
},
"
armLineNums
"
:
[
52
]
},
"
17
"
:
{
"
name
"
:
"
INT constant: 2
"
,
"
children
"
:
[],
"
waccStart
"
:
{
"
lineNum
"
:
4
,
"
charNum
"
:
16
},
"
waccEnd
"
:
{
"
lineNum
"
:
4
,
"
charNum
"
:
17
},
"
armLineNums
"
:
[
54
]
},
"
18
"
:
{
"
name
"
:
"
INT constant: 3
"
,
"
children
"
:
[],
"
waccStart
"
:
{
"
lineNum
"
:
4
,
"
charNum
"
:
19
},
"
waccEnd
"
:
{
"
lineNum
"
:
4
,
"
charNum
"
:
20
},
"
armLineNums
"
:
[
56
]
},
"
19
"
:
{
"
name
"
:
"
Array
"
,
"
children
"
:
[
16
,
17
,
18
],
"
waccStart
"
:
{
"
lineNum
"
:
4
,
"
charNum
"
:
12
},
"
waccEnd
"
:
{
"
lineNum
"
:
4
,
"
charNum
"
:
21
},
"
armLineNums
"
:
[
47
,
48
,
49
,
50
,
51
,
53
,
55
,
57
]
},
"
20
"
:
{
"
name
"
:
"
Declare INT[0]
"
,
"
children
"
:
[
15
,
19
],
"
waccStart
"
:
{
"
lineNum
"
:
4
,
"
charNum
"
:
2
},
"
waccEnd
"
:
{
"
lineNum
"
:
4
,
"
charNum
"
:
21
},
"
armLineNums
"
:
[
58
],
"
jsStart
"
:
{
"
lineNum
"
:
3
,
"
charNum
"
:
1
},
"
jsEnd
"
:
{
"
lineNum
"
:
3
,
"
charNum
"
:
24
}
},
"
22
"
:
{
"
name
"
:
"
Variable: q
"
,
"
children
"
:
[],
"
waccStart
"
:
{
"
lineNum
"
:
5
,
"
charNum
"
:
11
},
"
waccEnd
"
:
{
"
lineNum
"
:
5
,
"
charNum
"
:
12
},
"
armLineNums
"
:
[
59
]
},
"
23
"
:
{
"
name
"
:
"
First pair elem
"
,
"
children
"
:
[
22
],
"
waccStart
"
:
{
"
lineNum
"
:
5
,
"
charNum
"
:
7
},
"
waccEnd
"
:
{
"
lineNum
"
:
5
,
"
charNum
"
:
12
},
"
armLineNums
"
:
[
60
,
61
,
62
]
},
"
24
"
:
{
"
name
"
:
"
Read INT
"
,
"
children
"
:
[
23
],
"
waccStart
"
:
{
"
lineNum
"
:
5
,
"
charNum
"
:
2
},
"
waccEnd
"
:
{
"
lineNum
"
:
5
,
"
charNum
"
:
12
},
"
armLineNums
"
:
[
63
,
64
],
"
jsStart
"
:
{
"
lineNum
"
:
4
,
"
charNum
"
:
1
},
"
jsEnd
"
:
{
"
lineNum
"
:
4
,
"
charNum
"
:
31
}
},
"
0
"
:
{
"
name
"
:
"
Block
"
,
"
children
"
:
[
7
,
13
,
20
,
24
],
"
waccStart
"
:
{
"
lineNum
"
:
2
,
"
charNum
"
:
2
},
"
waccEnd
"
:
{
"
lineNum
"
:
5
,
"
charNum
"
:
12
},
"
armLineNums
"
:
[]
},
"
26
"
:
{
"
name
"
:
"
Function: #main
"
,
"
children
"
:
[
0
],
"
waccStart
"
:
{
"
lineNum
"
:
2
,
"
charNum
"
:
2
},
"
waccEnd
"
:
{
"
lineNum
"
:
5
,
"
charNum
"
:
12
},
"
armLineNums
"
:
[
17
,
66
,
67
],
"
jsStart
"
:
{
"
lineNum
"
:
1
,
"
charNum
"
:
1
},
"
jsEnd
"
:
{
"
lineNum
"
:
5
,
"
charNum
"
:
1
}
}
}
}
}
}
\ No newline at end of file
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