mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-04-06 02:52:24 +00:00
Base expression casting on C int size, remove dependencies on form=LInt.
This commit is contained in:
parent
b3c71fb2f0
commit
0508097ffe
199 changed files with 6800 additions and 6540 deletions
|
|
@ -1,4 +1,4 @@
|
|||
/* voc 1.95 [2016/08/30] for gcc LP64 on cygwin xtspkaSfF */
|
||||
/* voc 1.95 [2016/08/31] for gcc LP64 on cygwin xtspkaSfF */
|
||||
#include "SYSTEM.h"
|
||||
|
||||
typedef
|
||||
|
|
@ -229,7 +229,7 @@ void Platform_Init (INTEGER argc, LONGINT argvadr)
|
|||
Platform_ArgVecPtr av = NIL;
|
||||
Platform_MainStackFrame = argvadr;
|
||||
Platform_ArgCount = argc;
|
||||
av = (Platform_ArgVecPtr)(SYSTEM_ADRINT)argvadr;
|
||||
av = __VAL(Platform_ArgVecPtr, argvadr);
|
||||
Platform_ArgVector = (*av)[0];
|
||||
Platform_HaltCode = -128;
|
||||
Platform_HeapInitHeap();
|
||||
|
|
@ -262,8 +262,8 @@ void Platform_GetArg (INTEGER n, CHAR *val, LONGINT val__len)
|
|||
{
|
||||
Platform_ArgVec av = NIL;
|
||||
if (n < Platform_ArgCount) {
|
||||
av = (Platform_ArgVec)(SYSTEM_ADRINT)Platform_ArgVector;
|
||||
__COPY(*(*av)[__X(n, ((LONGINT)(1024)))], val, val__len);
|
||||
av = __VAL(Platform_ArgVec, Platform_ArgVector);
|
||||
__COPY(*(*av)[__X(n, 1024)], val, val__len);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -272,17 +272,17 @@ void Platform_GetIntArg (INTEGER n, LONGINT *val)
|
|||
CHAR s[64];
|
||||
LONGINT k, d, i;
|
||||
s[0] = 0x00;
|
||||
Platform_GetArg(n, (void*)s, ((LONGINT)(64)));
|
||||
Platform_GetArg(n, (void*)s, 64);
|
||||
i = 0;
|
||||
if (s[0] == '-') {
|
||||
i = 1;
|
||||
}
|
||||
k = 0;
|
||||
d = (int)s[__X(i, ((LONGINT)(64)))] - 48;
|
||||
d = s[__X(i, 64)] - 48;
|
||||
while ((d >= 0 && d <= 9)) {
|
||||
k = k * 10 + d;
|
||||
i += 1;
|
||||
d = (int)s[__X(i, ((LONGINT)(64)))] - 48;
|
||||
d = s[__X(i, 64)] - 48;
|
||||
}
|
||||
if (s[0] == '-') {
|
||||
k = -k;
|
||||
|
|
@ -300,10 +300,10 @@ INTEGER Platform_ArgPos (CHAR *s, LONGINT s__len)
|
|||
CHAR arg[256];
|
||||
__DUP(s, s__len, CHAR);
|
||||
i = 0;
|
||||
Platform_GetArg(i, (void*)arg, ((LONGINT)(256)));
|
||||
Platform_GetArg(i, (void*)arg, 256);
|
||||
while ((i < Platform_ArgCount && __STRCMP(s, arg) != 0)) {
|
||||
i += 1;
|
||||
Platform_GetArg(i, (void*)arg, ((LONGINT)(256)));
|
||||
Platform_GetArg(i, (void*)arg, 256);
|
||||
}
|
||||
_o_result = i;
|
||||
__DEL(s);
|
||||
|
|
@ -327,7 +327,7 @@ void Platform_SetBadInstructionHandler (Platform_SignalHandler handler)
|
|||
|
||||
static void Platform_YMDHMStoClock (LONGINT ye, LONGINT mo, LONGINT da, LONGINT ho, LONGINT mi, LONGINT se, LONGINT *t, LONGINT *d)
|
||||
{
|
||||
*d = (__ASHL(__MOD(ye, 100), 9) + __ASHL(mo + 1, 5)) + da;
|
||||
*d = (__ASHL((int)__MOD(ye, 100), 9) + __ASHL(mo + 1, 5)) + da;
|
||||
*t = (__ASHL(ho, 12) + __ASHL(mi, 6)) + se;
|
||||
}
|
||||
|
||||
|
|
@ -350,8 +350,8 @@ LONGINT Platform_Time (void)
|
|||
LONGINT _o_result;
|
||||
LONGINT ms;
|
||||
Platform_gettimeval();
|
||||
ms = __DIVF(Platform_tvusec(), 1000) + Platform_tvsec() * 1000;
|
||||
_o_result = __MOD(ms - Platform_TimeStart, 2147483647);
|
||||
ms = (int)__DIVF(Platform_tvusec(), 1000) + Platform_tvsec() * 1000;
|
||||
_o_result = (int)__MOD(ms - Platform_TimeStart, 2147483647);
|
||||
return _o_result;
|
||||
}
|
||||
|
||||
|
|
@ -359,7 +359,7 @@ void Platform_Delay (LONGINT ms)
|
|||
{
|
||||
LONGINT s, ns;
|
||||
s = __DIV(ms, 1000);
|
||||
ns = __MOD(ms, 1000) * 1000000;
|
||||
ns = (int)__MOD(ms, 1000) * 1000000;
|
||||
Platform_nanosleep(s, ns);
|
||||
}
|
||||
|
||||
|
|
@ -529,7 +529,7 @@ INTEGER Platform_Read (LONGINT h, LONGINT p, LONGINT l, LONGINT *n)
|
|||
INTEGER Platform_ReadBuf (LONGINT h, SYSTEM_BYTE *b, LONGINT b__len, LONGINT *n)
|
||||
{
|
||||
INTEGER _o_result;
|
||||
*n = Platform_readfile(h, (LONGINT)(SYSTEM_ADRINT)b, b__len);
|
||||
*n = Platform_readfile(h, (SYSTEM_ADRINT)b, b__len);
|
||||
if (*n < 0) {
|
||||
*n = 0;
|
||||
_o_result = Platform_err();
|
||||
|
|
@ -613,7 +613,7 @@ INTEGER Platform_Chdir (CHAR *n, LONGINT n__len)
|
|||
INTEGER _o_result;
|
||||
INTEGER r;
|
||||
r = Platform_chdir(n, n__len);
|
||||
Platform_getcwd((void*)Platform_CWD, ((LONGINT)(256)));
|
||||
Platform_getcwd((void*)Platform_CWD, 256);
|
||||
if (r < 0) {
|
||||
_o_result = Platform_err();
|
||||
return _o_result;
|
||||
|
|
@ -658,7 +658,7 @@ static void Platform_errposint (LONGINT l)
|
|||
if (l > 10) {
|
||||
Platform_errposint(__DIV(l, 10));
|
||||
}
|
||||
Platform_errch((CHAR)(48 + __MOD(l, 10)));
|
||||
Platform_errch((CHAR)(48 + (int)__MOD(l, 10)));
|
||||
}
|
||||
|
||||
static void Platform_errint (LONGINT l)
|
||||
|
|
@ -674,52 +674,52 @@ static void Platform_DisplayHaltCode (LONGINT code)
|
|||
{
|
||||
switch (code) {
|
||||
case -1:
|
||||
Platform_errstring((CHAR*)"Assertion failure.", (LONGINT)19);
|
||||
Platform_errstring((CHAR*)"Assertion failure.", 19);
|
||||
break;
|
||||
case -2:
|
||||
Platform_errstring((CHAR*)"Index out of range.", (LONGINT)20);
|
||||
Platform_errstring((CHAR*)"Index out of range.", 20);
|
||||
break;
|
||||
case -3:
|
||||
Platform_errstring((CHAR*)"Reached end of function without reaching RETURN.", (LONGINT)49);
|
||||
Platform_errstring((CHAR*)"Reached end of function without reaching RETURN.", 49);
|
||||
break;
|
||||
case -4:
|
||||
Platform_errstring((CHAR*)"CASE statement: no matching label and no ELSE.", (LONGINT)47);
|
||||
Platform_errstring((CHAR*)"CASE statement: no matching label and no ELSE.", 47);
|
||||
break;
|
||||
case -5:
|
||||
Platform_errstring((CHAR*)"Type guard failed.", (LONGINT)19);
|
||||
Platform_errstring((CHAR*)"Type guard failed.", 19);
|
||||
break;
|
||||
case -6:
|
||||
Platform_errstring((CHAR*)"Implicit type guard in record assignment failed.", (LONGINT)49);
|
||||
Platform_errstring((CHAR*)"Implicit type guard in record assignment failed.", 49);
|
||||
break;
|
||||
case -7:
|
||||
Platform_errstring((CHAR*)"Invalid case in WITH statement.", (LONGINT)32);
|
||||
Platform_errstring((CHAR*)"Invalid case in WITH statement.", 32);
|
||||
break;
|
||||
case -8:
|
||||
Platform_errstring((CHAR*)"Value out of range.", (LONGINT)20);
|
||||
Platform_errstring((CHAR*)"Value out of range.", 20);
|
||||
break;
|
||||
case -9:
|
||||
Platform_errstring((CHAR*)"Heap interrupted while locked, but lockdepth = 0 at unlock.", (LONGINT)60);
|
||||
Platform_errstring((CHAR*)"Heap interrupted while locked, but lockdepth = 0 at unlock.", 60);
|
||||
break;
|
||||
case -10:
|
||||
Platform_errstring((CHAR*)"NIL access.", (LONGINT)12);
|
||||
Platform_errstring((CHAR*)"NIL access.", 12);
|
||||
break;
|
||||
case -11:
|
||||
Platform_errstring((CHAR*)"Alignment error.", (LONGINT)17);
|
||||
Platform_errstring((CHAR*)"Alignment error.", 17);
|
||||
break;
|
||||
case -12:
|
||||
Platform_errstring((CHAR*)"Divide by zero.", (LONGINT)16);
|
||||
Platform_errstring((CHAR*)"Divide by zero.", 16);
|
||||
break;
|
||||
case -13:
|
||||
Platform_errstring((CHAR*)"Arithmetic overflow/underflow.", (LONGINT)31);
|
||||
Platform_errstring((CHAR*)"Arithmetic overflow/underflow.", 31);
|
||||
break;
|
||||
case -14:
|
||||
Platform_errstring((CHAR*)"Invalid function argument.", (LONGINT)27);
|
||||
Platform_errstring((CHAR*)"Invalid function argument.", 27);
|
||||
break;
|
||||
case -15:
|
||||
Platform_errstring((CHAR*)"Internal error, e.g. Type descriptor size mismatch.", (LONGINT)52);
|
||||
Platform_errstring((CHAR*)"Internal error, e.g. Type descriptor size mismatch.", 52);
|
||||
break;
|
||||
case -20:
|
||||
Platform_errstring((CHAR*)"Too many, or negative number of, elements in dynamic array.", (LONGINT)60);
|
||||
Platform_errstring((CHAR*)"Too many, or negative number of, elements in dynamic array.", 60);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -733,9 +733,9 @@ void Platform_Halt (LONGINT code)
|
|||
if (Platform_HaltHandler != NIL) {
|
||||
(*Platform_HaltHandler)(code);
|
||||
}
|
||||
Platform_errstring((CHAR*)"Terminated by Halt(", (LONGINT)20);
|
||||
Platform_errstring((CHAR*)"Terminated by Halt(", 20);
|
||||
Platform_errint(code);
|
||||
Platform_errstring((CHAR*)"). ", (LONGINT)4);
|
||||
Platform_errstring((CHAR*)"). ", 4);
|
||||
if (code < 0) {
|
||||
Platform_DisplayHaltCode(code);
|
||||
}
|
||||
|
|
@ -746,11 +746,11 @@ void Platform_Halt (LONGINT code)
|
|||
void Platform_AssertFail (LONGINT code)
|
||||
{
|
||||
INTEGER e;
|
||||
Platform_errstring((CHAR*)"Assertion failure.", (LONGINT)19);
|
||||
Platform_errstring((CHAR*)"Assertion failure.", 19);
|
||||
if (code != 0) {
|
||||
Platform_errstring((CHAR*)" ASSERT code ", (LONGINT)14);
|
||||
Platform_errstring((CHAR*)" ASSERT code ", 14);
|
||||
Platform_errint(code);
|
||||
Platform_errstring((CHAR*)".", (LONGINT)2);
|
||||
Platform_errstring((CHAR*)".", 2);
|
||||
}
|
||||
Platform_errln();
|
||||
Platform_exit(__VAL(INTEGER, code));
|
||||
|
|
@ -765,7 +765,7 @@ static void Platform_TestLittleEndian (void)
|
|||
{
|
||||
INTEGER i;
|
||||
i = 1;
|
||||
__GET((LONGINT)(SYSTEM_ADRINT)&i, Platform_LittleEndian, BOOLEAN);
|
||||
__GET((SYSTEM_ADRINT)&i, Platform_LittleEndian, BOOLEAN);
|
||||
}
|
||||
|
||||
__TDESC(Platform_FileIdentity, 1, 0) = {__TDFLDS("FileIdentity", 12), {-4}};
|
||||
|
|
@ -782,7 +782,7 @@ export void *Platform__init(void)
|
|||
Platform_TimeStart = 0;
|
||||
Platform_TimeStart = Platform_Time();
|
||||
Platform_CWD[0] = 0x00;
|
||||
Platform_getcwd((void*)Platform_CWD, ((LONGINT)(256)));
|
||||
Platform_getcwd((void*)Platform_CWD, 256);
|
||||
Platform_PID = Platform_getpid();
|
||||
Platform_SeekSet = Platform_seekset();
|
||||
Platform_SeekCur = Platform_seekcur();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue