disable lots of compiler options - embryo handles a subset of small
make compiler quieter. change default options for compiler and include default include for the user as well as current dir. SVN revision: 9446
This commit is contained in:
parent
7b4b36e5d2
commit
2766840f17
|
@ -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 \
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
filesdir = $(datadir)/embryo/examples
|
||||
files_DATA = \
|
||||
test.inc \
|
||||
test.sma
|
||||
|
||||
EXTRA_DIST = $(files_DATA)
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
#if defined EMBRYO_INC
|
||||
#endinput
|
||||
#endif
|
||||
#define EMBRYO_INC
|
||||
|
||||
native printf(format[], ...);
|
||||
native call(string[], string2[], val);
|
|
@ -0,0 +1,54 @@
|
|||
#include <float>
|
||||
#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;
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
filesdir = $(datadir)/embryo/include
|
||||
files_DATA = \
|
||||
float.inc
|
||||
|
||||
EXTRA_DIST = $(files_DATA)
|
|
@ -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 <raster@rasterman.com> 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);
|
|
@ -38,6 +38,9 @@
|
|||
#if defined LINUX
|
||||
#include <unistd.h>
|
||||
#include <embryo_cc_sclinux.h>
|
||||
//
|
||||
#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; arg<argc; arg++) {
|
||||
#if DIRSEP_CHAR=='/'
|
||||
isoption= argv[arg][0]=='-';
|
||||
|
@ -685,6 +695,7 @@ static void parseoptions(int argc,char **argv,char *iname,char *oname,
|
|||
if (isoption) {
|
||||
ptr=&argv[arg][1];
|
||||
switch (*ptr) {
|
||||
#if 0
|
||||
case 'A':
|
||||
i=atoi(ptr+1);
|
||||
if ((i % sizeof(cell))==0)
|
||||
|
@ -734,6 +745,7 @@ static void parseoptions(int argc,char **argv,char *iname,char *oname,
|
|||
about();
|
||||
} /* switch */
|
||||
break;
|
||||
#endif
|
||||
case 'e':
|
||||
strcpy(ename,ptr+1); /* set name of error file */
|
||||
break;
|
||||
|
@ -755,14 +767,17 @@ static void parseoptions(int argc,char **argv,char *iname,char *oname,
|
|||
insert_path(str);
|
||||
} /* if */
|
||||
break;
|
||||
#if 0
|
||||
case 'l':
|
||||
if (*(ptr+1)!='\0')
|
||||
about();
|
||||
sc_listing=TRUE; /* skip second pass & code generation */
|
||||
break;
|
||||
#endif
|
||||
case 'o':
|
||||
strcpy(oname,ptr+1); /* set name of (binary) output file */
|
||||
break;
|
||||
#if 0
|
||||
case 'P':
|
||||
sc_packstr=toggle_option(ptr,sc_packstr);
|
||||
break;
|
||||
|
@ -785,6 +800,7 @@ static void parseoptions(int argc,char **argv,char *iname,char *oname,
|
|||
set_extension(rname,".xml",TRUE);
|
||||
} /* if */
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
case 'S':
|
||||
i=atoi(ptr+1);
|
||||
|
@ -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 <filename> [options]\n\n");
|
||||
sc_printf("Usage: embryo_cc <filename> [options]\n\n");
|
||||
sc_printf("Options:\n");
|
||||
#if 0
|
||||
sc_printf(" -A<num> 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 ? '+' : '-');
|
||||
|
@ -1020,18 +1042,24 @@ static void about(void)
|
|||
sc_printf(" -e<name> set name of error file (quiet compile)\n");
|
||||
#if defined __WIN32__ || defined _WIN32 || defined _Windows
|
||||
sc_printf(" -H<hwnd> window handle to send a notification message on finish\n");
|
||||
#endif
|
||||
#endif
|
||||
sc_printf(" -i<name> path for include files\n");
|
||||
#if 0
|
||||
sc_printf(" -l create list file (preprocess only)\n");
|
||||
#endif
|
||||
sc_printf(" -o<name> 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<name> set name of \"prefix\" file\n");
|
||||
if (!waitkey())
|
||||
longjmp(errbuf,3);
|
||||
#if !defined SC_LIGHT
|
||||
sc_printf(" -r[name] write cross reference report to console or to specified file\n");
|
||||
#endif
|
||||
#endif
|
||||
sc_printf(" -S<num> stack/heap size in cells (default=%d)\n",(int)sc_stksize);
|
||||
#if 0
|
||||
sc_printf(" -s<num> skip lines from the input file\n");
|
||||
sc_printf(" -t<num> 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 */
|
||||
}
|
||||
|
|
|
@ -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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue