diff --git a/.builds/.freebsd.yaml b/.builds/.freebsd.yaml index 47abf3ac..9034cbaf 100644 --- a/.builds/.freebsd.yaml +++ b/.builds/.freebsd.yaml @@ -9,3 +9,4 @@ tasks: gmake test CC=gcc sudo gmake install CC=gcc gmake test-install CC=gcc + gmake test-amalg CC=gcc diff --git a/.builds/.openbsd.yaml b/.builds/.openbsd.yaml index bc989290..005b8b58 100644 --- a/.builds/.openbsd.yaml +++ b/.builds/.openbsd.yaml @@ -8,3 +8,4 @@ tasks: gmake test doas gmake install gmake test-install + gmake test-amalg diff --git a/.travis.yml b/.travis.yml index 67c71a42..64bb8b5f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ script: - make test - sudo make install - make test-install +- make test-amalg - make build/janet-${TRAVIS_TAG}-${TRAVIS_OS_NAME}.tar.gz compiler: - clang diff --git a/Makefile b/Makefile index d16b7ef9..22b8731b 100644 --- a/Makefile +++ b/Makefile @@ -304,6 +304,16 @@ install: $(JANET_TARGET) build/version.txt test-install: cd test/install && rm -rf build && janet build && janet build +build/embed_janet.o: build/janet.c $(JANET_HEADERS) + $(CC) $(CFLAGS) -c $< -o $@ +build/embed_main.o: test/amalg/main.c $(JANET_HEADERS) + $(CC) $(CFLAGS) -c $< -o $@ +build/embed_test: build/embed_janet.o build/embed_main.o + $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(CLIBS) + +test-amalg: build/embed_test + ./build/embed_test + uninstall: -rm $(BINDIR)/../$(JANET_TARGET) -rm -rf $(INCLUDEDIR) diff --git a/src/core/emit.c b/src/core/emit.c index 016039c7..49feb256 100644 --- a/src/core/emit.c +++ b/src/core/emit.c @@ -239,11 +239,11 @@ void janetc_copy( return; } /* Process: src -> near -> dest */ - int32_t near = janetc_allocnear(c, JANETC_REGTEMP_3); - janetc_movenear(c, near, src); - janetc_moveback(c, dest, near); + int32_t nearreg = janetc_allocnear(c, JANETC_REGTEMP_3); + janetc_movenear(c, nearreg, src); + janetc_moveback(c, dest, nearreg); /* Cleanup */ - janetc_regalloc_freetemp(&c->scope->ra, near, JANETC_REGTEMP_3); + janetc_regalloc_freetemp(&c->scope->ra, nearreg, JANETC_REGTEMP_3); } /* Instruction templated emitters */ diff --git a/test/amalg/main.c b/test/amalg/main.c new file mode 100644 index 00000000..59746b92 --- /dev/null +++ b/test/amalg/main.c @@ -0,0 +1,36 @@ +/* +* Copyright (c) 2019 Calvin Rose +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to +* deal in the Software without restriction, including without limitation the +* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +* sell copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +*/ + +/* A simple client for checking if the amalgamated Janet source compiles + * correctly. */ + +#include + +int main(int argc, const char *argv[]) { + (void) argc; + (void) argv; + janet_init(); + JanetTable *env = janet_core_env(NULL); + janet_dostring(env, "(print `hello, world!`)", "main", NULL); + janet_deinit(); + return 0; +}