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
abc-interpreter
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
8
Issues
8
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
clean-and-itasks
abc-interpreter
Commits
9aaf8026
Verified
Commit
9aaf8026
authored
Apr 03, 2019
by
Camil Staps
🚀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename bcunreloc to bcprelink
parent
05a6350b
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
51 additions
and
50 deletions
+51
-50
doc/wasm.md
doc/wasm.md
+2
-2
lib/ABC/Interpreter.dcl
lib/ABC/Interpreter.dcl
+3
-2
lib/ABC/Interpreter.icl
lib/ABC/Interpreter.icl
+3
-3
src/.gitignore
src/.gitignore
+1
-1
src/Makefile
src/Makefile
+14
-14
src/bcprelink.c
src/bcprelink.c
+6
-6
src/bcprelink.h
src/bcprelink.h
+3
-0
src/bcunreloc.h
src/bcunreloc.h
+0
-3
src/parse.c
src/parse.c
+17
-17
test/run_tests.sh
test/run_tests.sh
+2
-2
No files found.
doc/wasm.md
View file @
9aaf8026
...
@@ -8,12 +8,12 @@ tasks between a server and a browser client.
...
@@ -8,12 +8,12 @@ tasks between a server and a browser client.
## Tools
## Tools
Because there is no WebAssembly parser one needs to use
`bc
unreloc
`
to produce
Because there is no WebAssembly parser one needs to use
`bc
prelink
`
to produce
a version of the bytecode which can readily be copied into WebAssembly's linear
a version of the bytecode which can readily be copied into WebAssembly's linear
memory. This is done with:
memory. This is done with:
```
bash
```
bash
bc
unreloc
MODULE.bc
-o
MODULE.ubc
bc
prelink
MODULE.bc
-o
MODULE.ubc
```
```
**TODO**
: add support to
`cpm`
/the IDE for this.
**TODO**
: add support to
`cpm`
/the IDE for this.
lib/ABC/Interpreter.dcl
View file @
9aaf8026
...
@@ -64,15 +64,16 @@ defaultDeserializationSettings :: DeserializationSettings
...
@@ -64,15 +64,16 @@ defaultDeserializationSettings :: DeserializationSettings
serialize
::
a
!
String
!*
World
->
*(!
Maybe
SerializedGraph
,
!*
World
)
serialize
::
a
!
String
!*
World
->
*(!
Maybe
SerializedGraph
,
!*
World
)
/**
/**
* Serialize an expression for
unrelocat
ed interpretation. This is a mode of
* Serialize an expression for
prelink
ed interpretation. This is a mode of
* interpretation where the code and data addresses are fixed. It is useful for
* interpretation where the code and data addresses are fixed. It is useful for
* the WebAssembly interpreter where memory always starts at index 0.
* the WebAssembly interpreter where memory always starts at index 0.
*
*
* @param The value to serialize.
* @param The value to serialize.
* @param The path to the executable's bytecode (set by the `ByteCode` option in the project file).
* @param The path to the executable's bytecode (set by the `ByteCode` option in the project file).
* @param The path to the executable itself.
* @result The result may be `Nothing` if the bytecode could not be parsed.
* @result The result may be `Nothing` if the bytecode could not be parsed.
*/
*/
serialize_for_
unrelocat
ed_interpretation
::
a
!
String
!
String
!*
World
->
*(!
Maybe
String
,
!*
World
)
serialize_for_
prelink
ed_interpretation
::
a
!
String
!
String
!*
World
->
*(!
Maybe
String
,
!*
World
)
/**
/**
* Deserialize an expression using the ABC interpreter.
* Deserialize an expression using the ABC interpreter.
...
...
lib/ABC/Interpreter.icl
View file @
9aaf8026
...
@@ -75,8 +75,8 @@ where
...
@@ -75,8 +75,8 @@ where
ccall
strip_bytecode
"sA:VIp"
ccall
strip_bytecode
"sA:VIp"
}
}
serialize_for_
unrelocat
ed_interpretation
::
a
!
String
!
String
!*
World
->
*(!
Maybe
String
,
!*
World
)
serialize_for_
prelink
ed_interpretation
::
a
!
String
!
String
!*
World
->
*(!
Maybe
String
,
!*
World
)
serialize_for_
unrelocat
ed_interpretation
graph
bcfile
thisexe
w
serialize_for_
prelink
ed_interpretation
graph
bcfile
thisexe
w
#
(
host_syms
,
w
)
=
accFiles
(
read_symbols
thisexe
)
w
#
(
host_syms
,
w
)
=
accFiles
(
read_symbols
thisexe
)
w
#
(
graph
,
descinfo
,
modules
)
=
copy_to_string_with_names
graph
#
(
graph
,
descinfo
,
modules
)
=
copy_to_string_with_names
graph
...
@@ -196,7 +196,7 @@ where
...
@@ -196,7 +196,7 @@ where
|
d
==
array_desc
-4
*
8+2
=
(
1
,
True
)
// CHAR
|
d
==
array_desc
-4
*
8+2
=
(
1
,
True
)
// CHAR
|
d
==
array_desc
-5
*
8+2
=
(
IF_INT_64_OR_32
1
2
,
True
)
// REAL
|
d
==
array_desc
-5
*
8+2
=
(
IF_INT_64_OR_32
1
2
,
True
)
// REAL
|
d
==
array_desc
-6
*
8+2
=
(
1
,
True
)
// INT/dINT
|
d
==
array_desc
-6
*
8+2
=
(
1
,
True
)
// INT/dINT
|
otherwise
=
abort
"internal error in serialize_for_
unrelocat
ed_interpretation
\n
"
|
otherwise
=
abort
"internal error in serialize_for_
prelink
ed_interpretation
\n
"
#
arity
=
get_D_node_arity
d
#
arity
=
get_D_node_arity
d
|
arity
<
256
=
(
0
,
True
)
|
arity
<
256
=
(
0
,
True
)
#
record_a_arity
=
get_D_record_a_arity
d
#
record_a_arity
=
get_D_record_a_arity
d
...
...
src/.gitignore
View file @
9aaf8026
abcopt
abcopt
bcgen
bcgen
bclink
bclink
bcprelink
bcstrip
bcstrip
bcunreloc
debug
debug
interpret
interpret
...
...
src/Makefile
View file @
9aaf8026
...
@@ -49,19 +49,19 @@ ifeq ($(OS),Windows_NT)
...
@@ -49,19 +49,19 @@ ifeq ($(OS),Windows_NT)
ABCOPT
:=
ABCOptimiser.exe
ABCOPT
:=
ABCOptimiser.exe
BCGEN
:=
ByteCodeGenerator.exe
BCGEN
:=
ByteCodeGenerator.exe
BCLINK
:=
ByteCodeLinker.exe
BCLINK
:=
ByteCodeLinker.exe
BCPRELINK
:=
ByteCodePrelinker.exe
BCSTRIP
:=
ByteCodeStripper.exe
BCSTRIP
:=
ByteCodeStripper.exe
BCUNRELOC
:=
ByteCodeUnrelocator.exe
INTERP
:=
interpret.exe
INTERP
:=
interpret.exe
else
else
ABCOPT
:=
abcopt
ABCOPT
:=
abcopt
BCGEN
:=
bcgen
BCGEN
:=
bcgen
BCLINK
:=
bclink
BCLINK
:=
bclink
BCPRELINK
:=
bcprelink
BCSTRIP
:=
bcstrip
BCSTRIP
:=
bcstrip
BCUNRELOC
:=
bcunreloc
INTERP
:=
interpret
INTERP
:=
interpret
endif
endif
BINARIES
:=
$(ABCOPT)
$(BCGEN)
$(BCLINK)
$(BC
STRIP)
$(BCUNRELOC
)
$(INTERP)
BINARIES
:=
$(ABCOPT)
$(BCGEN)
$(BCLINK)
$(BC
PRELINK)
$(BCSTRIP
)
$(INTERP)
SRC_BCGEN
:=
\
SRC_BCGEN
:=
\
abc_instructions.c
\
abc_instructions.c
\
...
@@ -82,23 +82,23 @@ SRC_BCLINK:=\
...
@@ -82,23 +82,23 @@ SRC_BCLINK:=\
util.c
util.c
DEP_BCLINK
:=
$(
subst
.c,.h,
$(SRC_BCLINK)
)
settings.h
DEP_BCLINK
:=
$(
subst
.c,.h,
$(SRC_BCLINK)
)
settings.h
SRC_BC
STRIP
:=
\
SRC_BC
PRELINK
:=
\
abc_instructions.c
\
abc_instructions.c
\
bcgen_instructions.c
\
bcprelink.c
\
bcstrip.c
\
bytecode.c
\
bytecode.c
\
parse.c
\
parse.c
\
strip.c
\
util.c
util.c
DEP_BC
STRIP
:=
$(
subst
.c,.h,
$(SRC_BCSTRIP
)
)
settings.h
DEP_BC
PRELINK
:=
$(
subst
.c,.h,
$(SRC_BCPRELINK
)
)
settings.h
SRC_BC
UNRELOC
:=
\
SRC_BC
STRIP
:=
\
abc_instructions.c
\
abc_instructions.c
\
bcunreloc.c
\
bcgen_instructions.c
\
bcstrip.c
\
bytecode.c
\
bytecode.c
\
parse.c
\
parse.c
\
strip.c
\
util.c
util.c
DEP_BC
UNRELOC
:=
$(
subst
.c,.h,
$(SRC_BCUNRELOC
)
)
settings.h
DEP_BC
STRIP
:=
$(
subst
.c,.h,
$(SRC_BCSTRIP
)
)
settings.h
SRC_INTERPRET
:=
\
SRC_INTERPRET
:=
\
abc_instructions.c
\
abc_instructions.c
\
...
@@ -148,12 +148,12 @@ $(BCGEN): $(SRC_BCGEN) $(DEP_BCGEN)
...
@@ -148,12 +148,12 @@ $(BCGEN): $(SRC_BCGEN) $(DEP_BCGEN)
$(BCLINK)
:
$(SRC_BCLINK) $(DEP_BCLINK)
$(BCLINK)
:
$(SRC_BCLINK) $(DEP_BCLINK)
$(CC)
$(CFLAGS)
$(CLIBS)
-UCOMPUTED_GOTOS
$(SRC_BCLINK)
-DLINKER
-o
$@
$(CC)
$(CFLAGS)
$(CLIBS)
-UCOMPUTED_GOTOS
$(SRC_BCLINK)
-DLINKER
-o
$@
$(BCPRELINK)
:
$(SRC_BCPRELINK) $(DEP_BCPRELINK)
$(CC)
$(CFLAGS)
$(CLIBS)
-UCOMPUTED_GOTOS
-DPRELINKER
-UWORD_WIDTH
-DWORD_WIDTH
=
64
$(SRC_BCPRELINK)
-o
$@
$(BCSTRIP)
:
$(SRC_BCSTRIP) $(DEP_BCSTRIP)
$(BCSTRIP)
:
$(SRC_BCSTRIP) $(DEP_BCSTRIP)
$(CC)
$(CFLAGS)
$(CLIBS)
-UCOMPUTED_GOTOS
$(SRC_BCSTRIP)
-o
$@
$(CC)
$(CFLAGS)
$(CLIBS)
-UCOMPUTED_GOTOS
$(SRC_BCSTRIP)
-o
$@
$(BCUNRELOC)
:
$(SRC_BCUNRELOC) $(DEP_BCUNRELOC)
$(CC)
$(CFLAGS)
$(CLIBS)
-UCOMPUTED_GOTOS
-DUNRELOCATOR
-UWORD_WIDTH
-DWORD_WIDTH
=
64
$(SRC_BCUNRELOC)
-o
$@
$(INTERP)
:
$(SRC_INTERPRET) $(DEP_INTERPRET)
$(INTERP)
:
$(SRC_INTERPRET) $(DEP_INTERPRET)
$(CC)
$(CFLAGS)
$(CLIBS)
-DINTERPRETER
$(SRC_INTERPRET)
-o
$@
$(CC)
$(CFLAGS)
$(CLIBS)
-DINTERPRETER
$(SRC_INTERPRET)
-o
$@
...
...
src/bc
unreloc
.c
→
src/bc
prelink
.c
View file @
9aaf8026
...
@@ -19,7 +19,7 @@ enum section_type {
...
@@ -19,7 +19,7 @@ enum section_type {
#define _4chars2int(a,b,c,d) ((uint64_t) (a+(b<<8)+(c<<16)+(d<<24)))
#define _4chars2int(a,b,c,d) ((uint64_t) (a+(b<<8)+(c<<16)+(d<<24)))
#define _7chars2int(a,b,c,d,e,f,g) ((uint64_t) (a+(b<<8)+(c<<16)+(d<<24)+((uint64_t)e<<32)+((uint64_t)f<<40)+((uint64_t)g<<48)))
#define _7chars2int(a,b,c,d,e,f,g) ((uint64_t) (a+(b<<8)+(c<<16)+(d<<24)+((uint64_t)e<<32)+((uint64_t)f<<40)+((uint64_t)g<<48)))
#define _8chars2int(a,b,c,d,e,f,g,h) ((uint64_t) (a+(b<<8)+(c<<16)+(d<<24)+((uint64_t)e<<32)+((uint64_t)f<<40)+((uint64_t)g<<48)+((uint64_t)h<<56)))
#define _8chars2int(a,b,c,d,e,f,g,h) ((uint64_t) (a+(b<<8)+(c<<16)+(d<<24)+((uint64_t)e<<32)+((uint64_t)f<<40)+((uint64_t)g<<48)+((uint64_t)h<<56)))
uint64_t
unrelocato
r_preamble
[
658
]
=
{
uint64_t
prelinke
r_preamble
[
658
]
=
{
/* 0 */
0
,
0
,
0
,
7
,
_7chars2int
(
'_'
,
'A'
,
'R'
,
'R'
,
'A'
,
'Y'
,
'_'
),
/* 0 */
0
,
0
,
0
,
7
,
_7chars2int
(
'_'
,
'A'
,
'R'
,
'R'
,
'A'
,
'Y'
,
'_'
),
/* 5 */
0
,
0
,
0
,
8
,
_8chars2int
(
'_'
,
'S'
,
'T'
,
'R'
,
'I'
,
'N'
,
'G'
,
'_'
),
/* 5 */
0
,
0
,
0
,
8
,
_8chars2int
(
'_'
,
'S'
,
'T'
,
'R'
,
'I'
,
'N'
,
'G'
,
'_'
),
/* 10 */
0
,
0
,
0
,
4
,
_4chars2int
(
'B'
,
'O'
,
'O'
,
'L'
),
/* 10 */
0
,
0
,
0
,
4
,
_4chars2int
(
'B'
,
'O'
,
'O'
,
'L'
),
...
@@ -66,13 +66,13 @@ uint64_t unrelocator_preamble[658] = {
...
@@ -66,13 +66,13 @@ uint64_t unrelocator_preamble[658] = {
void
prepare_preamble
(
void
)
{
void
prepare_preamble
(
void
)
{
for
(
int
i
=
0
;
i
<=
32
;
i
++
)
{
for
(
int
i
=
0
;
i
<=
32
;
i
++
)
{
unrelocato
r_preamble
[
30
+
i
*
2
]
=
26
*
8
+
2
;
/* INT+2 */
prelinke
r_preamble
[
30
+
i
*
2
]
=
26
*
8
+
2
;
/* INT+2 */
unrelocato
r_preamble
[
30
+
i
*
2
+
1
]
=
i
;
prelinke
r_preamble
[
30
+
i
*
2
+
1
]
=
i
;
}
}
for
(
int
i
=
0
;
i
<
256
;
i
++
)
{
for
(
int
i
=
0
;
i
<
256
;
i
++
)
{
unrelocato
r_preamble
[
146
+
i
*
2
]
=
16
*
8
+
2
;
/* CHAR+2 */
prelinke
r_preamble
[
146
+
i
*
2
]
=
16
*
8
+
2
;
/* CHAR+2 */
unrelocato
r_preamble
[
146
+
i
*
2
+
1
]
=
i
;
prelinke
r_preamble
[
146
+
i
*
2
+
1
]
=
i
;
}
}
}
}
...
@@ -129,7 +129,7 @@ int main(int argc, char **argv) {
...
@@ -129,7 +129,7 @@ int main(int argc, char **argv) {
struct
program
*
program
=
state
.
program
;
struct
program
*
program
=
state
.
program
;
prepare_preamble
();
prepare_preamble
();
write_section
(
output_file
,
ST_Preamble
,
sizeof
(
unrelocator_preamble
)
/
sizeof
(
uint64_t
),
unrelocato
r_preamble
);
write_section
(
output_file
,
ST_Preamble
,
sizeof
(
prelinker_preamble
)
/
sizeof
(
uint64_t
),
prelinke
r_preamble
);
write_section
(
output_file
,
ST_Code
,
program
->
code_size
,
program
->
code
);
write_section
(
output_file
,
ST_Code
,
program
->
code_size
,
program
->
code
);
write_section
(
output_file
,
ST_Data
,
program
->
data_size
,
program
->
data
);
write_section
(
output_file
,
ST_Data
,
program
->
data_size
,
program
->
data
);
write_section
(
output_file
,
ST_Start
,
1
,
&
program
->
symbol_table
[
program
->
start_symbol_id
].
offset
);
write_section
(
output_file
,
ST_Start
,
1
,
&
program
->
symbol_table
[
program
->
start_symbol_id
].
offset
);
...
...
src/bcprelink.h
0 → 100644
View file @
9aaf8026
#pragma once
extern
uint64_t
prelinker_preamble
[
658
];
src/bcunreloc.h
deleted
100644 → 0
View file @
05a6350b
#pragma once
extern
uint64_t
unrelocator_preamble
[
658
];
src/parse.c
View file @
9aaf8026
...
@@ -13,8 +13,8 @@
...
@@ -13,8 +13,8 @@
# include "bcgen_instructions.h"
# include "bcgen_instructions.h"
#endif
#endif
#ifdef
UNRELOCATO
R
#ifdef
PRELINKE
R
# include "bc
unreloc
.h"
# include "bc
prelink
.h"
#endif
#endif
#ifdef LINK_CLEAN_RUNTIME
#ifdef LINK_CLEAN_RUNTIME
...
@@ -272,8 +272,8 @@ int parse_program(struct parser *state, struct char_provider *cp) {
...
@@ -272,8 +272,8 @@ int parse_program(struct parser *state, struct char_provider *cp) {
# else
# else
state
->
program
->
data_size
=
elem32
;
state
->
program
->
data_size
=
elem32
;
# endif
# endif
/* The
unrelocato
r writes data size between code and data segment, so reserve this space.
/* The
prelinke
r writes data size between code and data segment, so reserve this space.
* TODO: better would be to use a different file format in the
unrelocato
r. */
* TODO: better would be to use a different file format in the
prelinke
r. */
state
->
program
->
code
=
safe_malloc
(
sizeof
(
BC_WORD
)
*
(
code_size
+
state
->
program
->
data_size
+
1
));
state
->
program
->
code
=
safe_malloc
(
sizeof
(
BC_WORD
)
*
(
code_size
+
state
->
program
->
data_size
+
1
));
state
->
program
->
data
=
state
->
program
->
code
+
code_size
+
1
;
state
->
program
->
data
=
state
->
program
->
code
+
code_size
+
1
;
#endif
#endif
...
@@ -512,25 +512,25 @@ int parse_program(struct parser *state, struct char_provider *cp) {
...
@@ -512,25 +512,25 @@ int parse_program(struct parser *state, struct char_provider *cp) {
return
1
;
return
1
;
state
->
program
->
symbols
[
state
->
symbols_ptr
++
]
=
elem8
;
state
->
program
->
symbols
[
state
->
symbols_ptr
++
]
=
elem8
;
}
while
(
elem8
);
}
while
(
elem8
);
#if defined(INTERPRETER) || defined(
UNRELOCATO
R)
#if defined(INTERPRETER) || defined(
PRELINKE
R)
# ifdef INTERPRETER
# ifdef INTERPRETER
# define INTERPRETER_OR_
UNRELOCATO
R(i,u) i
# define INTERPRETER_OR_
PRELINKE
R(i,u) i
# else
# else
# define INTERPRETER_OR_
UNRELOCATO
R(i,u) (u*8)
# define INTERPRETER_OR_
PRELINKE
R(i,u) (u*8)
# endif
# endif
if
(
!
strcmp
(
state
->
program
->
symbol_table
[
state
->
ptr
].
name
,
"__ARRAY__"
))
{
if
(
!
strcmp
(
state
->
program
->
symbol_table
[
state
->
ptr
].
name
,
"__ARRAY__"
))
{
state
->
program
->
symbol_table
[
state
->
ptr
].
offset
=
(
BC_WORD
)
INTERPRETER_OR_
UNRELOCATO
R
(
&
__ARRAY__
,
1
);
state
->
program
->
symbol_table
[
state
->
ptr
].
offset
=
(
BC_WORD
)
INTERPRETER_OR_
PRELINKE
R
(
&
__ARRAY__
,
1
);
}
else
if
(
!
strcmp
(
state
->
program
->
symbol_table
[
state
->
ptr
].
name
,
"__STRING__"
))
{
}
else
if
(
!
strcmp
(
state
->
program
->
symbol_table
[
state
->
ptr
].
name
,
"__STRING__"
))
{
state
->
program
->
symbol_table
[
state
->
ptr
].
offset
=
(
BC_WORD
)
INTERPRETER_OR_
UNRELOCATO
R
(
&
__STRING__
,
6
);
state
->
program
->
symbol_table
[
state
->
ptr
].
offset
=
(
BC_WORD
)
INTERPRETER_OR_
PRELINKE
R
(
&
__STRING__
,
6
);
}
else
if
(
!
strcmp
(
state
->
program
->
symbol_table
[
state
->
ptr
].
name
,
"INT"
)
||
}
else
if
(
!
strcmp
(
state
->
program
->
symbol_table
[
state
->
ptr
].
name
,
"INT"
)
||
!
strcmp
(
state
->
program
->
symbol_table
[
state
->
ptr
].
name
,
"dINT"
))
{
!
strcmp
(
state
->
program
->
symbol_table
[
state
->
ptr
].
name
,
"dINT"
))
{
state
->
program
->
symbol_table
[
state
->
ptr
].
offset
=
(
BC_WORD
)
INTERPRETER_OR_
UNRELOCATO
R
(
&
INT
,
26
);
state
->
program
->
symbol_table
[
state
->
ptr
].
offset
=
(
BC_WORD
)
INTERPRETER_OR_
PRELINKE
R
(
&
INT
,
26
);
}
else
if
(
!
strcmp
(
state
->
program
->
symbol_table
[
state
->
ptr
].
name
,
"BOOL"
))
{
}
else
if
(
!
strcmp
(
state
->
program
->
symbol_table
[
state
->
ptr
].
name
,
"BOOL"
))
{
state
->
program
->
symbol_table
[
state
->
ptr
].
offset
=
(
BC_WORD
)
INTERPRETER_OR_
UNRELOCATO
R
(
&
BOOL
,
11
);
state
->
program
->
symbol_table
[
state
->
ptr
].
offset
=
(
BC_WORD
)
INTERPRETER_OR_
PRELINKE
R
(
&
BOOL
,
11
);
}
else
if
(
!
strcmp
(
state
->
program
->
symbol_table
[
state
->
ptr
].
name
,
"CHAR"
))
{
}
else
if
(
!
strcmp
(
state
->
program
->
symbol_table
[
state
->
ptr
].
name
,
"CHAR"
))
{
state
->
program
->
symbol_table
[
state
->
ptr
].
offset
=
(
BC_WORD
)
INTERPRETER_OR_
UNRELOCATO
R
(
&
CHAR
,
16
);
state
->
program
->
symbol_table
[
state
->
ptr
].
offset
=
(
BC_WORD
)
INTERPRETER_OR_
PRELINKE
R
(
&
CHAR
,
16
);
}
else
if
(
!
strcmp
(
state
->
program
->
symbol_table
[
state
->
ptr
].
name
,
"REAL"
))
{
}
else
if
(
!
strcmp
(
state
->
program
->
symbol_table
[
state
->
ptr
].
name
,
"REAL"
))
{
state
->
program
->
symbol_table
[
state
->
ptr
].
offset
=
(
BC_WORD
)
INTERPRETER_OR_
UNRELOCATO
R
(
&
REAL
,
21
);
state
->
program
->
symbol_table
[
state
->
ptr
].
offset
=
(
BC_WORD
)
INTERPRETER_OR_
PRELINKE
R
(
&
REAL
,
21
);
}
else
if
(
state
->
program
->
symbol_table
[
state
->
ptr
].
offset
==
-
1
)
{
}
else
if
(
state
->
program
->
symbol_table
[
state
->
ptr
].
offset
==
-
1
)
{
# ifdef DEBUG_CLEAN_LINKS
# ifdef DEBUG_CLEAN_LINKS
EPRINTF
(
"Warning: symbol '%s' is not defined.
\n
"
,
state
->
program
->
symbol_table
[
state
->
ptr
].
name
);
EPRINTF
(
"Warning: symbol '%s' is not defined.
\n
"
,
state
->
program
->
symbol_table
[
state
->
ptr
].
name
);
...
@@ -554,8 +554,8 @@ int parse_program(struct parser *state, struct char_provider *cp) {
...
@@ -554,8 +554,8 @@ int parse_program(struct parser *state, struct char_provider *cp) {
# endif
# endif
# ifdef INTERPRETER
# ifdef INTERPRETER
state
->
program
->
symbol_table
[
state
->
ptr
].
offset
+=
(
BC_WORD
)
state
->
program
->
data
;
state
->
program
->
symbol_table
[
state
->
ptr
].
offset
+=
(
BC_WORD
)
state
->
program
->
data
;
# elif defined(
UNRELOCATO
R)
# elif defined(
PRELINKE
R)
state
->
program
->
symbol_table
[
state
->
ptr
].
offset
+=
((
BC_WORD
)
state
->
program
->
code_size
+
3
)
*
8
+
sizeof
(
unrelocato
r_preamble
);
state
->
program
->
symbol_table
[
state
->
ptr
].
offset
+=
((
BC_WORD
)
state
->
program
->
code_size
+
3
)
*
8
+
sizeof
(
prelinke
r_preamble
);
# endif
# endif
# ifdef LINK_CLEAN_RUNTIME
# ifdef LINK_CLEAN_RUNTIME
if
(
state
->
program
->
symbol_table
[
state
->
ptr
].
name
[
0
])
{
if
(
state
->
program
->
symbol_table
[
state
->
ptr
].
name
[
0
])
{
...
@@ -591,8 +591,8 @@ int parse_program(struct parser *state, struct char_provider *cp) {
...
@@ -591,8 +591,8 @@ int parse_program(struct parser *state, struct char_provider *cp) {
# endif
# endif
# ifdef INTERPRETER
# ifdef INTERPRETER
state
->
program
->
symbol_table
[
state
->
ptr
].
offset
+=
(
BC_WORD
)
state
->
program
->
code
;
state
->
program
->
symbol_table
[
state
->
ptr
].
offset
+=
(
BC_WORD
)
state
->
program
->
code
;
# elif defined(
UNRELOCATO
R)
# elif defined(
PRELINKE
R)
state
->
program
->
symbol_table
[
state
->
ptr
].
offset
+=
2
*
8
+
sizeof
(
unrelocato
r_preamble
);
state
->
program
->
symbol_table
[
state
->
ptr
].
offset
+=
2
*
8
+
sizeof
(
prelinke
r_preamble
);
# endif
# endif
# ifdef LINK_CLEAN_RUNTIME
# ifdef LINK_CLEAN_RUNTIME
if
(
state
->
program
->
symbol_table
[
state
->
ptr
].
name
[
0
])
{
if
(
state
->
program
->
symbol_table
[
state
->
ptr
].
name
[
0
])
{
...
...
test/run_tests.sh
View file @
9aaf8026
...
@@ -101,7 +101,7 @@ while true; do
...
@@ -101,7 +101,7 @@ while true; do
-w
)
-w
)
WASM
=
1
WASM
=
1
IP
=
"js ../src-js/interpret.js"
IP
=
"js ../src-js/interpret.js"
SRCMAKETARGETS
=
"abcopt bcgen bclink bc
strip bcunreloc
"
SRCMAKETARGETS
=
"abcopt bcgen bclink bc
prelink bcstrip
"
BC_EXTENSION
=
"ubc"
BC_EXTENSION
=
"ubc"
shift
;;
shift
;;
...
@@ -223,7 +223,7 @@ do
...
@@ -223,7 +223,7 @@ do
[
$BENCHMARK
-gt
0
]
&&
mv
"
$MODULE
.icl.nobm"
"
$MODULE
.icl"
[
$BENCHMARK
-gt
0
]
&&
mv
"
$MODULE
.icl.nobm"
"
$MODULE
.icl"
[
$WASM
-gt
0
]
&&
../src/bc
unreloc
"
$MODULE
.bc"
-o
"
$MODULE
.ubc"
[
$WASM
-gt
0
]
&&
../src/bc
prelink
"
$MODULE
.bc"
-o
"
$MODULE
.ubc"
if
[
$BENCHMARK
-gt
0
]
;
then
if
[
$BENCHMARK
-gt
0
]
;
then
/usr/bin/time
-p
$IP
$MODULE_RUNFLAGS
$RUNFLAGS
$MODULE
.
$BC_EXTENSION
2>bm-tmp
>
$MODULE
.result
/usr/bin/time
-p
$IP
$MODULE_RUNFLAGS
$RUNFLAGS
$MODULE
.
$BC_EXTENSION
2>bm-tmp
>
$MODULE
.result
...
...
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