-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Richard Russo
committed
Jan 27, 2019
0 parents
commit 2d385ac
Showing
603 changed files
with
56,879 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 rtrusso | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Quick Start | ||
|
||
## Windows | ||
|
||
- Ensure GCC, GNU make, NASM, diff in path | ||
- run src\go.cmd | ||
|
||
## Linux | ||
|
||
*work in progress* | ||
|
||
# Sunnyvale Compiler Platform | ||
|
||
This codebase aspires to facilitate the rapid or experimental | ||
development of traditional ("ahead-of-time") compilers for a wide | ||
range of programming languages. | ||
|
||
The codebase consists of these major components: | ||
|
||
- Frontends for a subset of the Scheme and Java programming languages | ||
- Lexer and parser generator tools | ||
- an intermediate language: Symbolic Assembly or SASM | ||
- A backend with code analysis and improvement phases (optimizer) | ||
- Translation of SASM to practical assembly languages (x86, MIPS) | ||
- A runtime library with basic memory management and a garbage collector | ||
|
||
The idea is that to build a compiler for some programming language, | ||
one has to mainly write just a frontend that emits SASM, and runtime | ||
library, and take advantage of as many of the existing components as | ||
possible to get that working as quickly and/or easily as | ||
possible. Ideally, there should also be reuse of the runtime | ||
components to the extent possible. | ||
|
||
In this way it has similar goals to something like .NET or the JVM | ||
without all that mucking about in virtual machines. | ||
|
||
- [Status](readme/Status.md) | ||
- [Dependencies](readme/Depend.md) | ||
- [SASM Introduction](readme/SASM.md) | ||
- [Tools](readme/Tools.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
tinyscheme-1.41/dynload.o | ||
tinyscheme-1.41/scheme | ||
tinyscheme-1.41/scheme.o | ||
tinyscheme-1.41/libtinyscheme.a | ||
tinyscheme-1.41/libtinyscheme.so | ||
tinyscheme-1.41/scheme.exe | ||
tinyscheme-1.41/libtinyscheme.dll |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
|
||
/* ========== other i/o part ========== */ | ||
case OP_GETENV: { | ||
char *env = getenv(strvalue(car(sc->args))); | ||
if (env) { | ||
x=mk_string(sc,env); | ||
s_return(sc,x); | ||
} else { | ||
s_retbool(0); | ||
} | ||
} | ||
|
||
case OP_SETENV: { | ||
char *name = strvalue(car(sc->args)); | ||
char *val = strvalue(cadr(sc->args)); | ||
#ifdef TS_BOOTSTRAP_MINGW32 | ||
BOOL b = SetEnvironmentVariableA(name, val); | ||
s_retbool(b); | ||
#else | ||
int s = (0==setenv(name,val,1)); | ||
s_retbool(s); | ||
#endif | ||
} | ||
|
||
case OP_UNLINK: { | ||
int s = (0==unlink(strvalue(car(sc->args)))); | ||
s_retbool(s); | ||
} | ||
|
||
case OP_MKDIR: { | ||
#ifdef TS_BOOTSTRAP_MINGW32 | ||
int s = (0==mkdir(strvalue(car(sc->args)))); | ||
#else | ||
int s = (0==mkdir(strvalue(car(sc->args)), 0777)); | ||
#endif | ||
s_retbool(s); | ||
} | ||
|
||
case OP_ELAPSED_S: { | ||
static time_t t_base = 0; | ||
time_t t_now; | ||
if (t_base == 0) { time(&t_base); } | ||
time(&t_now); | ||
s_return(sc,mk_integer(sc,(t_now - t_base))); | ||
} | ||
|
||
case OP_ELAPSED_MS: { | ||
static struct timeval tv_base = {0,0}; | ||
struct timeval tv_now; | ||
int ms; | ||
if (tv_base.tv_sec==0) { gettimeofday(&tv_base, NULL); } | ||
gettimeofday(&tv_now, NULL); | ||
ms = (tv_now.tv_sec - tv_base.tv_sec) * 1000; | ||
ms += (tv_now.tv_usec - tv_base.tv_usec) / 1000; | ||
s_return(sc,mk_integer(sc,ms)); | ||
} | ||
|
||
case OP_STAT: { | ||
struct stat buf; | ||
int s = (0==stat(strvalue(car(sc->args)),&buf)); | ||
if (s) { | ||
pointer vec; | ||
vec = mk_vector(sc,10); | ||
set_vector_elem(vec,7,mk_integer(sc,buf.st_size)); | ||
set_vector_elem(vec,9,mk_integer(sc,buf.st_mtime)); | ||
s_return(sc,vec); | ||
} else { | ||
s_retbool(0); | ||
} | ||
} | ||
|
||
case OP_RENAME_FILE: { | ||
char *old = strvalue(car(sc->args)); | ||
char *new = strvalue(cadr(sc->args)); | ||
int s = (0==rename(old,new)); | ||
s_retbool(s); | ||
} | ||
|
||
case OP_EVALCTR: { | ||
s_return(sc,mk_integer(sc,Eval_Cycle_Count)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
_OP_DEF(opexe_5, "getenv", 1, 1, TST_STRING, OP_GETENV ) | ||
_OP_DEF(opexe_5, "setenv", 2, 2, TST_STRING TST_STRING, OP_SETENV ) | ||
_OP_DEF(opexe_5, "delete-file", 1, 1, TST_STRING, OP_UNLINK ) | ||
_OP_DEF(opexe_5, "create-directory", 1, 1, TST_STRING, OP_MKDIR ) | ||
_OP_DEF(opexe_5, "current-seconds", 0, 0, 0, OP_ELAPSED_S ) | ||
_OP_DEF(opexe_5, "current-milliseconds", 0, 0, 0, OP_ELAPSED_MS ) | ||
_OP_DEF(opexe_5, "stat", 1, 1, TST_STRING, OP_STAT ) | ||
_OP_DEF(opexe_5, "rename-file", 2, 2, TST_STRING TST_STRING, OP_RENAME_FILE ) | ||
_OP_DEF(opexe_5, "current-evaluation-counter", 0, 0, 0, OP_EVALCTR ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#ifdef TS_BOOTSTRAP_MINGW32 | ||
#include <windows.h> | ||
#include <sys/time.h> | ||
#include <io.h> | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
Building TinyScheme | ||
------------------- | ||
|
||
The included makefile includes logic for Linux, Solaris and Win32, and can | ||
readily serve as an example for other OSes, especially Unixes. There are | ||
a lot of compile-time flags in TinyScheme (preprocessor defines) that can trim | ||
unwanted features. See next section. 'make all' and 'make clean' function as | ||
expected. | ||
|
||
Autoconfing TinyScheme was once proposed, but the distribution would not be | ||
so small anymore. There are few platform dependencies in TinyScheme, and in | ||
general compiles out of the box. | ||
|
||
Customizing | ||
----------- | ||
|
||
The following symbols are defined to default values in scheme.h. | ||
Use the -D flag of cc to set to either 1 or 0. | ||
|
||
STANDALONE | ||
Define this to produce a standalone interpreter. | ||
|
||
USE_MATH | ||
Includes math routines. | ||
|
||
USE_CHAR_CLASSIFIERS | ||
Includes character classifier procedures. | ||
|
||
USE_ASCII_NAMES | ||
Enable extended character notation based on ASCII names. | ||
|
||
USE_STRING_PORTS | ||
Enables string ports. | ||
|
||
USE_ERROR_HOOK | ||
To force system errors through user-defined error handling. | ||
(see "Error handling") | ||
|
||
USE_TRACING | ||
To enable use of TRACING. | ||
|
||
USE_COLON_HOOK | ||
Enable use of qualified identifiers. (see "Colon Qualifiers - Packages") | ||
Defining this as 0 has the rather drastic consequence that any code using | ||
packages will stop working, and will have to be modified. It should only | ||
be used if you *absolutely* need to use '::' in identifiers. | ||
|
||
USE_STRCASECMP | ||
Defines stricmp as strcasecmp, for Unix. | ||
|
||
STDIO_ADDS_CR | ||
Informs TinyScheme that stdio translates "\n" to "\r\n". For DOS/Windows. | ||
|
||
USE_DL | ||
Enables dynamically loaded routines. If you define this symbol, you | ||
should also include dynload.c in your compile. | ||
|
||
USE_PLIST | ||
Enables property lists (not Standard Scheme stuff). Off by default. | ||
|
||
USE_NO_FEATURES | ||
Shortcut to disable USE_MATH, USE_CHAR_CLASSIFIERS, USE_ASCII_NAMES, | ||
USE_STRING_PORTS, USE_ERROR_HOOK, USE_TRACING, USE_COLON_HOOK, | ||
USE_DL. | ||
|
||
USE_SCHEME_STACK | ||
Enables 'cons' stack (the alternative is a faster calling scheme, which | ||
breaks continuations). Undefine it if you don't care about strict compatibility | ||
but you do care about faster execution. | ||
|
||
|
||
OS-X tip | ||
-------- | ||
I don't have access to OS-X, but Brian Maher submitted the following tip: | ||
|
||
[1] Download and install fink (I installed fink in | ||
/usr/local/fink) | ||
[2] Install the 'dlcompat' package using fink as such: | ||
> fink install dlcompat | ||
[3] Make the following changes to the | ||
tinyscheme-1.32.tar.gz | ||
|
||
diff -r tinyscheme-1.32/dynload.c | ||
tinyscheme-1.32-new/dynload.c | ||
24c24 | ||
< #define SUN_DL | ||
--- | ||
> | ||
Only in tinyscheme-1.32-new/: dynload.o | ||
Only in tinyscheme-1.32-new/: libtinyscheme.a Only in tinyscheme-1.32-new/: libtinyscheme.so diff -r tinyscheme-1.32/makefile tinyscheme-1.32-new/makefile | ||
33,34c33,43 | ||
< LD = gcc | ||
< LDFLAGS = -shared | ||
--- | ||
> #LD = gcc | ||
> #LDFLAGS = -shared | ||
> #DEBUG=-g -Wno-char-subscripts -O | ||
> #SYS_LIBS= -ldl | ||
> #PLATFORM_FEATURES= -DSUN_DL=1 | ||
> | ||
> # Mac OS X | ||
> CC = gcc | ||
> CFLAGS = -I/usr/local/fink/include | ||
> LD = gcc | ||
> LDFLAGS = -L/usr/local/fink/lib | ||
37c46 | ||
< PLATFORM_FEATURES= -DSUN_DL=1 | ||
--- | ||
> PLATFORM_FEATURES= -DSUN_DL=1 -DOSX | ||
60c69 | ||
< $(CC) -I. -c $(DEBUG) $(FEATURES) | ||
$(DL_FLAGS) $< | ||
--- | ||
> $(CC) $(CFLAGS) -I. -c $(DEBUG) | ||
$(FEATURES) $(DL_FLAGS) $< | ||
66c75 | ||
< $(CC) -o $@ $(DEBUG) $(OBJS) $(SYS_LIBS) | ||
--- | ||
> $(CC) $(LDFLAGS) -o $@ $(DEBUG) $(OBJS) | ||
$(SYS_LIBS) | ||
Only in tinyscheme-1.32-new/: scheme | ||
diff -r tinyscheme-1.32/scheme.c | ||
tinyscheme-1.32-new/scheme.c | ||
60,61c60,61 | ||
< #ifndef macintosh | ||
< # include <malloc.h> | ||
--- | ||
> #ifdef OSX | ||
> /* Do nothing */ | ||
62a63,65 | ||
> # ifndef macintosh | ||
> # include <malloc.h> | ||
> # else | ||
77c80,81 | ||
< #endif /* macintosh */ | ||
--- | ||
> # endif /* macintosh */ | ||
> #endif /* !OSX */ | ||
Only in tinyscheme-1.32-new/: scheme.o |
Oops, something went wrong.