diff --git a/legacy/embryo/Makefile.am b/legacy/embryo/Makefile.am index 5d1b062c46..d5970badb3 100644 --- a/legacy/embryo/Makefile.am +++ b/legacy/embryo/Makefile.am @@ -1,6 +1,6 @@ ## Process this file with automake to produce Makefile.in -SUBDIRS = src +SUBDIRS = src include examples MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess \ config.h.in config.sub configure install-sh \ diff --git a/legacy/embryo/configure.in b/legacy/embryo/configure.in index b7559471c4..a309e7e39b 100644 --- a/legacy/embryo/configure.in +++ b/legacy/embryo/configure.in @@ -46,6 +46,17 @@ else fi fi +dnl Set PACKAGE_DATA_DIR in config.h. +if test "x${datadir}" = 'x${prefix}/share'; then + if test "x${prefix}" = "xNONE"; then + AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${ac_default_prefix}/share/${PACKAGE}", [Shared Data Directory] ) + else + AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${prefix}/share/${PACKAGE}", [Shared Data Directory]) + fi +else + AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${datadir}/${PACKAGE}", [Shared Data Directory]) +fi + dnl Set PACKAGE_BIN_DIR in config.h. if test "x${bindir}" = 'xNONE'; then if test "x${prefix}" = "xNONE"; then @@ -75,6 +86,8 @@ AC_DEFINE_UNQUOTED(PACKAGE_SOURCE_DIR, "${packagesrcdir}", [Source code director AC_OUTPUT([ Makefile embryo.pc +include/Makefile +examples/Makefile src/Makefile src/lib/Makefile src/bin/Makefile diff --git a/legacy/embryo/examples/Makefile.am b/legacy/embryo/examples/Makefile.am new file mode 100644 index 0000000000..db62cdeabd --- /dev/null +++ b/legacy/embryo/examples/Makefile.am @@ -0,0 +1,7 @@ +filesdir = $(datadir)/embryo/examples +files_DATA = \ +test.inc \ +test.sma + +EXTRA_DIST = $(files_DATA) + diff --git a/legacy/embryo/examples/test.inc b/legacy/embryo/examples/test.inc new file mode 100644 index 0000000000..c7a259ceab --- /dev/null +++ b/legacy/embryo/examples/test.inc @@ -0,0 +1,7 @@ +#if defined EMBRYO_INC +#endinput +#endif +#define EMBRYO_INC + +native printf(format[], ...); +native call(string[], string2[], val); diff --git a/legacy/embryo/examples/test.sma b/legacy/embryo/examples/test.sma new file mode 100644 index 0000000000..3c011a3392 --- /dev/null +++ b/legacy/embryo/examples/test.sma @@ -0,0 +1,54 @@ +#include +#include "test.inc" + +/* This is ugly - please ignore this code! */ + +/* To compile: + * embryo_cc ./test.sma -otest.amx + * + * To test run: + * embryo ./test.amx + */ + +public global1 = 99; +public global2 = 77; + +main() +{ + call("Main Test 1", "meh", 1); + call("Main Test 2", "fkhwefkjwe", 7); + call("Main Test 3", "ikkie", 88); + call("Main Test 4", "MAH", 123); + + testfn(12345, "Panties!!!!", 7); + + return 77; +} + +tester(arg1=0, str[]="", arg2=0) +{ + if (arg1 == 7) printf("arg1 == 7!!!\n"); + printf(" TESTER: arg1=%i str='%s' arg2=%i\n", arg1, str, arg2); +} + +public testfn(arg1, str[], arg2) +{ + new a = 10; + new Float:b = 20.0; + + printf("float test %i %f\n", a, b); + + new val; + + tester(77, "blahdieblah", 1024); + if (arg1 == 7) printf("arg1 == 7!!!\n"); + printf("arg1=%i str='%s' arg2=%i\n", arg1, str, arg2); + + val = call("Test Test 1", "bim", 77); + if (val == 10) + call("Val is 10", "pfft", 111); + else + call("Val is NOT 10", "meh", 101010); + return 5; +} + diff --git a/legacy/embryo/include/Makefile.am b/legacy/embryo/include/Makefile.am new file mode 100644 index 0000000000..d4f318020b --- /dev/null +++ b/legacy/embryo/include/Makefile.am @@ -0,0 +1,5 @@ +filesdir = $(datadir)/embryo/include +files_DATA = \ +float.inc + +EXTRA_DIST = $(files_DATA) diff --git a/legacy/embryo/include/float.inc b/legacy/embryo/include/float.inc new file mode 100644 index 0000000000..d0af4022b4 --- /dev/null +++ b/legacy/embryo/include/float.inc @@ -0,0 +1,135 @@ +/* Float arithmetic + * + * (c) Copyright 1999, Artran, Inc. + * Written by Greg Garner (gmg@artran.com) + * Modified in March 2001 to include user defined + * operators for the floating point functions. + * Modified March 2004 by Carsten Haitzler to conform + * to E coding style + * + * This file is provided as is (no warranties). + */ +#if defined FLOAT_INC +#endinput +#endif +#define FLOAT_INC + +#pragma rational Float + +/* Different methods of rounding */ +enum Float_Round_Method +{ + ROUND, FLOOR, CEIL, TOZERO +}; +/* different angle addressing modes (default is radians) */ +enum Float_Angle_Mode +{ + RADIAN, DEGREES, GRADES +}; + +/* Convert a string into a floating point value */ +native Float:atof(const string[]); +/* Return the fractional part of a float */ +native Float:fract(Float:value); +/* Round a float into a integer value */ +native round(Float:value, Float_Round_Method:method=ROUND); +/* Return the square root of the input value, same as float_power(value, 0.5) */ +native Float:sqrt(Float:value); +/* Return the value raised to the power of the exponent */ +native Float:pow(Float:value, Float:exponent); +/* Return the logarithm */ +native Float:log(Float:value, Float:base=10.0); +/* Return the sine, cosine or tangent. The input angle may be in radian, degrees or grades. */ +native Float:sin(Float:value, Float_Angle_Mode:mode=RADIAN); +native Float:cos(Float:value, Float_Angle_Mode:mode=RADIAN); +native Float:tan(Float:value, Float_Angle_Mode:mode=RADIAN); +/* Return the absolute value */ +native Float:abs(Float:value); + + + + + + + + +/**************************************************/ +/* Hidden calls - all are overloaded on operators */ +/**************************************************/ + +/* Convert an integer into a floating point value */ +native Float:float(value); +/* Multiple two floats together */ +native Float:float_mul(Float:oper1, Float:oper2); +/* Divide the dividend float by the divisor float */ +native Float:float_div(Float:dividend, Float:divisor); +/* Add two floats together */ +native Float:float_add(Float:oper1, Float:oper2); +/* Subtract oper2 float from oper1 float */ +native Float:float_sub(Float:oper1, Float:oper2); +/* Compare two integers. If the two elements are equal, return 0. */ +/* If the first argument is greater than the second argument, return 1, */ +/* If the first argument is less than the second argument, return -1. */ +native float_cmp(Float:oper1, Float:oper2); +/* user defined operators */ +native Float:operator*(Float:oper1, Float:oper2) = float_mul; +native Float:operator/(Float:oper1, Float:oper2) = float_div; +native Float:operator+(Float:oper1, Float:oper2) = float_add; +native Float:operator-(Float:oper1, Float:oper2) = float_sub; +native Float:operator=(oper) = float; +stock Float:operator++(Float:oper) + return oper+1.0; +stock Float:operator--(Float:oper) + return oper-1.0; +stock Float:operator-(Float:oper) + return oper^Float:0x80000000; /* IEEE values are sign/magnitude */ +stock Float:operator*(Float:oper1, oper2) + return float_mul(oper1, float(oper2)); /* "*" is commutative */ +stock Float:operator/(Float:oper1, oper2) + return float_div(oper1, float(oper2)); +stock Float:operator/(oper1, Float:oper2) + return float_div(float(oper1), oper2); +stock Float:operator+(Float:oper1, oper2) + return float_add(oper1, float(oper2)); /* "+" is commutative */ +stock Float:operator-(Float:oper1, oper2) + return float_sub(oper1, float(oper2)); +stock Float:operator-(oper1, Float:oper2) + return float_sub(float(oper1), oper2); +stock bool:operator==(Float:oper1, Float:oper2) + return float_cmp(oper1, oper2) == 0; +stock bool:operator==(Float:oper1, oper2) + return float_cmp(oper1, float(oper2)) == 0; /* "==" is commutative */ +stock bool:operator!=(Float:oper1, Float:oper2) + return float_cmp(oper1, oper2) != 0; +stock bool:operator!=(Float:oper1, oper2) + return float_cmp(oper1, float(oper2)) != 0; /* "!=" is commutative */ +stock bool:operator>(Float:oper1, Float:oper2) + return float_cmp(oper1, oper2) > 0; +stock bool:operator>(Float:oper1, oper2) + return float_cmp(oper1, float(oper2)) > 0; +stock bool:operator>(oper1, Float:oper2) + return float_cmp(float(oper1), oper2) > 0; +stock bool:operator>=(Float:oper1, Float:oper2) + return float_cmp(oper1, oper2) >= 0; +stock bool:operator>=(Float:oper1, oper2) + return float_cmp(oper1, float(oper2)) >= 0; +stock bool:operator>=(oper1, Float:oper2) + return float_cmp(float(oper1), oper2) >= 0; +stock bool:operator<(Float:oper1, Float:oper2) + return float_cmp(oper1, oper2) < 0; +stock bool:operator<(Float:oper1, oper2) + return float_cmp(oper1, float_(oper2)) < 0; +stock bool:operator<(oper1, Float:oper2) + return float_cmp(float(oper1), oper2) < 0; +stock bool:operator<=(Float:oper1, Float:oper2) + return float_cmp(oper1, oper2) <= 0; +stock bool:operator<=(Float:oper1, oper2) + return float_cmp(oper1, float(oper2)) <= 0; +stock bool:operator<=(oper1, Float:oper2) + return float_cmp(float(oper1), oper2) <= 0; +stock bool:operator!(Float:oper) + return (_:oper & 0x7fffffff) == 0; +/* forbidden operations */ +forward operator%(Float:oper1, Float:oper2); +forward operator%(Float:oper1, oper2); +forward operator%(oper1, Float:oper2); diff --git a/legacy/embryo/src/bin/embryo_cc_sc1.c b/legacy/embryo/src/bin/embryo_cc_sc1.c index a1838f1048..1bb7541ee1 100644 --- a/legacy/embryo/src/bin/embryo_cc_sc1.c +++ b/legacy/embryo/src/bin/embryo_cc_sc1.c @@ -38,6 +38,9 @@ #if defined LINUX #include #include +// + #include "config.h" +// #endif #if defined FORTIFY @@ -588,12 +591,14 @@ static void initglobals(void) litmax=sDEF_LITMAX; /* current size of the literal table */ errnum=0; /* number of errors */ warnnum=0; /* number of warnings */ - sc_debug=sCHKBOUNDS; /* by default: bounds checking+assertions */ +// sc_debug=sCHKBOUNDS; /* by default: bounds checking+assertions */ + sc_debug=0; /* by default: no debug */ charbits=8; /* a "char" is 8 bits */ sc_packstr=FALSE; /* strings are unpacked by default */ - sc_compress=TRUE; /* compress output bytecodes */ +// sc_compress=TRUE; /* compress output bytecodes */ + sc_compress=FALSE; /* compress output bytecodes */ sc_needsemicolon=FALSE;/* semicolon required to terminate expressions? */ - sc_dataalign=sizeof(cell); + sc_dataalign=4; sc_stksize=sDEF_AMXSTACK;/* default stack size */ sc_tabsize=8; /* assume a TAB is 8 spaces */ sc_rationaltag=0; /* assume no support for rational numbers */ @@ -676,6 +681,11 @@ static void parseoptions(int argc,char **argv,char *iname,char *oname, char str[_MAX_PATH],*ptr; int arg,i,isoption; +// + /* use embryo include dir always */ + insert_path(PACKAGE_DATA_DIR"/include/"); + insert_path(PACKAGE_DATA_DIR"./"); +// for (arg=1; arg64) @@ -793,6 +809,7 @@ static void parseoptions(int argc,char **argv,char *iname,char *oname, else about(); break; +#if 0 case 's': skipinput=atoi(ptr+1); break; @@ -808,6 +825,7 @@ static void parseoptions(int argc,char **argv,char *iname,char *oname, case ';': sc_needsemicolon=toggle_option(ptr,sc_needsemicolon); break; +#endif default: /* wrong option */ about(); } /* switch */ @@ -996,15 +1014,19 @@ static int waitkey(void) static void setcaption(void) { +// shh be quiet! +#if 0 sc_printf("Small compiler " VERSION_STR "\t\tCopyright (c) 1997-2003, ITB CompuPhase\n\n"); +#endif } static void about(void) { if (strlen(errfname)==0) { setcaption(); - sc_printf("Usage: sc [options]\n\n"); + sc_printf("Usage: embryo_cc [options]\n\n"); sc_printf("Options:\n"); +#if 0 sc_printf(" -A alignment in bytes of the data segment and the stack\n"); sc_printf(" -a output assembler code (skip code generation pass)\n"); sc_printf(" -C[+/-] compact encoding for output file (default=%c)\n", sc_compress ? '+' : '-'); @@ -1021,9 +1043,13 @@ static void about(void) #if defined __WIN32__ || defined _WIN32 || defined _Windows sc_printf(" -H window handle to send a notification message on finish\n"); #endif +#endif sc_printf(" -i path for include files\n"); +#if 0 sc_printf(" -l create list file (preprocess only)\n"); +#endif sc_printf(" -o set base name of output file\n"); +#if 0 sc_printf(" -P[+/-] strings are \"packed\" by default (default=%c)\n", sc_packstr ? '+' : '-'); sc_printf(" -p set name of \"prefix\" file\n"); if (!waitkey()) @@ -1031,7 +1057,9 @@ static void about(void) #if !defined SC_LIGHT sc_printf(" -r[name] write cross reference report to console or to specified file\n"); #endif +#endif sc_printf(" -S stack/heap size in cells (default=%d)\n",(int)sc_stksize); +#if 0 sc_printf(" -s skip lines from the input file\n"); sc_printf(" -t TAB indent size (in character positions)\n"); sc_printf(" -\\ use '\\' for escape characters\n"); @@ -1039,6 +1067,7 @@ static void about(void) sc_printf(" -;[+/-] require a semicolon to end each statement (default=%c)\n", sc_needsemicolon ? '+' : '-'); sc_printf(" sym=val define constant \"sym\" with value \"val\"\n"); sc_printf(" sym= define constant \"sym\" with value 0\n"); +#endif } /* if */ longjmp(errbuf,3); /* user abort */ } diff --git a/legacy/embryo/src/bin/embryo_main.c b/legacy/embryo/src/bin/embryo_main.c index 190333be65..d701e54115 100644 --- a/legacy/embryo/src/bin/embryo_main.c +++ b/legacy/embryo/src/bin/embryo_main.c @@ -1,5 +1,8 @@ #include "Embryo.h" +/* This is ugly code! don't look at it please! i am embarrassed! i need to */ +/* cleanit up! */ + #include #include #include diff --git a/legacy/embryo/src/lib/Makefile.am b/legacy/embryo/src/lib/Makefile.am index cc0140f1ff..40aef0e4d9 100644 --- a/legacy/embryo/src/lib/Makefile.am +++ b/legacy/embryo/src/lib/Makefile.am @@ -21,4 +21,4 @@ embryo_private.h libembryo_la_LIBADD = $(LDFLAGS) -lm libembryo_la_DEPENDENCIES = $(top_builddir)/config.h -libembryo_la_LDFLAGS = -version-info 1:0:0 +libembryo_la_LDFLAGS = -version-info 0:1:0