From 5fddefead0796ecce04c04ad8390601571d58231 Mon Sep 17 00:00:00 2001 From: mike lowis Date: Thu, 15 Apr 2021 20:09:26 -0400 Subject: [PATCH] removed unused builtins --- lib/obnc/OBNC.c | 35 ------------------ lib/obnc/OBNC.h | 47 ++++-------------------- lib/obnc/OBNCTest.c | 89 --------------------------------------------- src/Generate.c | 81 ----------------------------------------- src/Trees.c | 24 ------------ src/Trees.h | 8 ---- src/Types.c | 16 -------- 7 files changed, 7 insertions(+), 293 deletions(-) diff --git a/lib/obnc/OBNC.c b/lib/obnc/OBNC.c index 51c6704..9fa2b0c 100644 --- a/lib/obnc/OBNC.c +++ b/lib/obnc/OBNC.c @@ -177,11 +177,7 @@ void OBNC_WriteHex(unsigned OBNC_INTEGER n, FILE *f) void OBNC_Exit(int status) { -#if OBNC_CONFIG_TARGET_EMB - while (1); -#else exit(status); -#endif } @@ -201,34 +197,3 @@ OBNC_INTEGER OBNC_Mod(OBNC_INTEGER x, OBNC_INTEGER y) { return (x >= 0)? x % y: ((x % y) + y) % y; } - - -unsigned OBNC_INTEGER OBNC_Range(OBNC_INTEGER m, OBNC_INTEGER n) -{ - return (m <= n)? - (unsigned OBNC_INTEGER) ((((unsigned OBNC_INTEGER) -2) << n) ^ (((unsigned OBNC_INTEGER) -1) << m)): - (unsigned OBNC_INTEGER) 0x0u; -} - - -OBNC_INTEGER OBNC_Ror(OBNC_INTEGER x, OBNC_INTEGER n) -{ - return (OBNC_INTEGER) (((unsigned OBNC_INTEGER) x >> n) | ((unsigned OBNC_INTEGER) x << (((unsigned OBNC_INTEGER) sizeof (OBNC_INTEGER) << 3) - (size_t) n))); -} - - -void OBNC_Pack(OBNC_REAL *x, OBNC_INTEGER n) -{ - *x = OBNC_REAL_SUFFIX(ldexp)(*x, (int) n); -} - - -void OBNC_Unpk(OBNC_REAL *x, OBNC_INTEGER *n) -{ - int t; - - *x = OBNC_REAL_SUFFIX(frexp)(*x, &t); - *n = (OBNC_INTEGER) t; - *x += *x; - (*n)--; -} diff --git a/lib/obnc/OBNC.h b/lib/obnc/OBNC.h index c530c30..b4cf785 100644 --- a/lib/obnc/OBNC.h +++ b/lib/obnc/OBNC.h @@ -15,13 +15,8 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.*/ #include #include -#if OBNC_CONFIG_TARGET_EMB - #define OBNC_CFILE "" - #define OBNC_OBNFILE "" -#else - #define OBNC_CFILE __FILE__ - #define OBNC_OBNFILE OBERON_SOURCE_FILENAME -#endif +#define OBNC_CFILE __FILE__ +#define OBNC_OBNFILE OBERON_SOURCE_FILENAME /*Run-time exceptions*/ @@ -125,29 +120,22 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.*/ #define OBNC_ABS_INT(x) OBNC_INT_PREFIX(abs)(x) #define OBNC_ABS_FLT(x) OBNC_REAL_SUFFIX(fabs)(x) -#define OBNC_ODD(x) (((x) & 1) == 1) -#define OBNC_LSL(x, n) ((OBNC_INTEGER) (x) << (n)) -#define OBNC_ASR(x, n) ((OBNC_INTEGER) (x) >> (n)) -#define OBNC_ROR(x, n) ((OBNC_INTEGER) (((unsigned OBNC_INTEGER) (x) >> (n)) | ((unsigned OBNC_INTEGER) (x) << ((sizeof (OBNC_INTEGER) << 3) - (size_t) (n))))) /*Type conversions*/ #define OBNC_FLOOR(x) ((OBNC_INTEGER) OBNC_REAL_SUFFIX(floor)(x)) -#define OBNC_FLT(x) ((OBNC_REAL) (x)) -#define OBNC_ORD(x) ((OBNC_INTEGER) (x)) -#define OBNC_CHR(x) ((char) (x)) +#define OBNC_FLT(x) ((OBNC_REAL) (x)) +#define OBNC_ORD(x) ((OBNC_INTEGER) (x)) +#define OBNC_CHR(x) ((char) (x)) /*Predefined proper procedures*/ -#define OBNC_INC(v) (v)++ +#define OBNC_INC(v) (v)++ #define OBNC_INC_N(v, n) (v) += (n) -#define OBNC_DEC(v) (v)-- +#define OBNC_DEC(v) (v)-- #define OBNC_DEC_N(v, n) (v) -= (n) -#define OBNC_INCL(v, x) (v) |= (1 << (x)) -#define OBNC_EXCL(v, x) (v) &= ~((unsigned OBNC_INTEGER) 1 << (x)) - #define OBNC_NEW(v, vtd, vHeapType, allocKind) \ { \ vHeapType *p = OBNC_Allocate(sizeof *p, (allocKind)); \ @@ -177,14 +165,6 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.*/ OBNC_ExitTrap(); \ } -#define OBNC_PACK(x, n) (x) = OBNC_REAL_SUFFIX(ldexp)(x, n) - -#if OBNC_CONFIG_C_INT_TYPE != OBNC_CONFIG_INT - #define OBNC_UNPK(x, n) OBNC_Unpk(&(x), &(n)) -#else - #define OBNC_UNPK(x, n) (x) = OBNC_REAL_SUFFIX(frexp)(x, &(n)); (x) += (x); (n)-- -#endif - /*SYSTEM procedures*/ #ifndef OBNC_ADR @@ -235,11 +215,6 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.*/ #define OBNC_MOD(x, y) (((x) >= 0)? (x) % (y): (((x) % (y)) + (y)) % (y)) -#define OBNC_RANGE(m, n) \ - (((m) <= (n))? \ - (unsigned OBNC_INTEGER) ((((unsigned OBNC_INTEGER) -2) << (n)) ^ (((unsigned OBNC_INTEGER) -1)) << (m)): \ - (unsigned OBNC_INTEGER) 0x0u) - #define OBNC_IN(x, A) ((int) ((((unsigned OBNC_INTEGER) 1) << (x)) & (A))) /*Structured assignments*/ @@ -321,14 +296,6 @@ OBNC_INTEGER OBNC_It1(OBNC_INTEGER index, OBNC_INTEGER length, const char file[] OBNC_INTEGER OBNC_Mod(OBNC_INTEGER x, OBNC_INTEGER y); -unsigned OBNC_INTEGER OBNC_Range(OBNC_INTEGER m, OBNC_INTEGER n); - -OBNC_INTEGER OBNC_Ror(OBNC_INTEGER x, OBNC_INTEGER n); - -void OBNC_Pack(OBNC_REAL *x, OBNC_INTEGER n); - -void OBNC_Unpk(OBNC_REAL *x, OBNC_INTEGER *n); - /*On small systems fprintf takes up too much memory*/ void OBNC_WriteInt(OBNC_INTEGER x, OBNC_INTEGER n, FILE *f); diff --git a/lib/obnc/OBNCTest.c b/lib/obnc/OBNCTest.c index 49771a8..8e342d4 100644 --- a/lib/obnc/OBNCTest.c +++ b/lib/obnc/OBNCTest.c @@ -35,43 +35,6 @@ static void TestABS(void) } -static void TestODD(void) -{ - assert(! OBNC_ODD(-2)); - assert(OBNC_ODD(-1)); - assert(! OBNC_ODD(0)); - assert(OBNC_ODD(1)); - assert(! OBNC_ODD(2)); -} - - -static void TestLSL(void) -{ - assert(OBNC_LSL(0, 0) == 0); - assert(OBNC_LSL(0, 1) == 0); - assert(OBNC_LSL(1, 0) == 1); - assert(OBNC_LSL(1, 1) == 2); -} - - -static void TestASR(void) -{ - assert(OBNC_ASR(0, 0) == 0); - assert(OBNC_ASR(0, 1) == 0); - assert(OBNC_ASR(1, 0) == 1); - assert(OBNC_ASR(1, 1) == 0); - assert(OBNC_ASR(~0, 1) == ~0); -} - - -static void TestROR(void) -{ - assert(OBNC_ROR(0, 1) == 0); - assert(OBNC_ROR(2, 1) == 1); - assert(OBNC_ROR(1, 2) == (OBNC_INTEGER) 1 << (INTEGER_BITS - 2)); -} - - static void TestFLOOR(void) { assert(OBNC_FLOOR(-1.5) == -2); @@ -130,26 +93,6 @@ static void TestDEC(void) } -static void TestINCL(void) -{ - int A; - - A = 0; - OBNC_INCL(A, 0); - assert(A == 1); -} - - -static void TestEXCL(void) -{ - unsigned OBNC_INTEGER A; - - A = 1; - OBNC_EXCL(A, 0); - assert(A == 0); -} - - static void TestNEW(void) { struct { int *typeID; int x; } *v; @@ -168,30 +111,6 @@ static void TestASSERT(void) } -static void TestPACK(void) -{ - const double eps = 0.01; - OBNC_REAL x; - - x = 1.0; - OBNC_PACK(x, 2); - assert(OBNC_ABS_FLT(x - OBNC_REAL_SUFFIX(4.0)) < eps); -} - - -static void TestUNPK(void) -{ - OBNC_REAL x; - OBNC_INTEGER n; - - x = 4.0; - OBNC_UNPK(x, n); - assert(x >= 1.0); - assert(x < 2.0); - assert(n == 2); -} - - static void TestCMP(void) { char s[4], t[4]; @@ -214,22 +133,14 @@ int main(void) OBNC_Init(0, NULL); TestABS(); - TestODD(); - TestLSL(); - TestASR(); - TestROR(); TestFLOOR(); TestFLT(); TestORD(); TestCHR(); TestINC(); TestDEC(); - TestINCL(); - TestEXCL(); TestNEW(); TestASSERT(); - TestPACK(); - TestUNPK(); TestCMP(); return 0; diff --git a/src/Generate.c b/src/Generate.c index aabd28c..5b5a165 100644 --- a/src/Generate.c +++ b/src/Generate.c @@ -965,23 +965,15 @@ static int IsProcedureCall(int symbol) switch (symbol) { case TREES_ABS_PROC: - case TREES_ODD_PROC: case TREES_LEN_PROC: - case TREES_LSL_PROC: - case TREES_ASR_PROC: - case TREES_ROR_PROC: case TREES_FLOOR_PROC: case TREES_FLT_PROC: case TREES_ORD_PROC: case TREES_CHR_PROC: case TREES_INC_PROC: case TREES_DEC_PROC: - case TREES_INCL_PROC: - case TREES_EXCL_PROC: /*case TREES_NEW_PROC*/ case TREES_ASSERT_PROC: - case TREES_PACK_PROC: - case TREES_UNPK_PROC: case TREES_ADR_PROC: case TREES_SIZE_PROC: case TREES_BIT_PROC: @@ -2724,12 +2716,6 @@ static void Generate(Trees_Node node, FILE *file, int indent) fprintf(file, ")"); addressOperationUsed = 1; break; - case TREES_ASR_PROC: - Indent(file, indent); - fprintf(file, "OBNC_ASR("); - Generate(Trees_Left(node), file, 0); - fprintf(file, ")"); - break; case TREES_ASSERT_PROC: GenerateAssert(node, file, indent); break; @@ -2780,12 +2766,6 @@ static void Generate(Trees_Node node, FILE *file, int indent) case TREES_DESIGNATOR: GenerateDesignator(node, file); break; - case TREES_EXCL_PROC: - Indent(file, indent); - fprintf(file, "OBNC_EXCL("); - Generate(Trees_Left(node), file, 0); - fprintf(file, ");\n"); - break; case TREES_EXP_LIST: GenerateExpList(node, file); break; @@ -2830,12 +2810,6 @@ static void Generate(Trees_Node node, FILE *file, int indent) fprintf(file, ");\n"); } break; - case TREES_INCL_PROC: - Indent(file, indent); - fprintf(file, "OBNC_INCL("); - Generate(Trees_Left(node), file, 0); - fprintf(file, ");\n"); - break; case TREES_INTEGER_TYPE: fprintf(file, "OBNC_INTEGER"); break; @@ -2848,19 +2822,9 @@ static void Generate(Trees_Node node, FILE *file, int indent) GenerateArrayLength(Trees_Type(var), EntireVar(var), ArrayDimension(var), file); } break; - case TREES_LSL_PROC: - fprintf(file, "OBNC_LSL("); - Generate(Trees_Left(node), file, 0); - fprintf(file, ")"); - break; case TREES_NEW_PROC: GenerateMemoryAllocation(Trees_Left(Trees_Left(node)), file, indent); break; - case TREES_ODD_PROC: - fprintf(file, "OBNC_ODD("); - Generate(Trees_Left(node), file, 0); - fprintf(file, ")"); - break; case TREES_ORD_PROC: fprintf(file, "OBNC_ORD("); if (Types_IsChar(Trees_Type(Trees_Left(Trees_Left(node))))) { @@ -2869,24 +2833,6 @@ static void Generate(Trees_Node node, FILE *file, int indent) GenerateWithPrecedence(Trees_Left(node), file); fprintf(file, ")"); break; - case TREES_PACK_PROC: - { - Trees_Node params = Trees_Left(node); - - Indent(file, indent); - if (ContainsProcedureCall(params)) { - fprintf(file, "OBNC_Pack(&("); - Generate(Trees_Left(params), file, 0); - fprintf(file, "), "); - Generate(Trees_Right(params), file, 0); - fprintf(file, ");\n"); - } else { - fprintf(file, "OBNC_PACK("); - Generate(params, file, 0); - fprintf(file, ");\n"); - } - } - break; case TREES_PROCEDURE_CALL: GenerateProcedureCall(node, file, indent); break; @@ -2915,15 +2861,6 @@ static void Generate(Trees_Node node, FILE *file, int indent) case TREES_REAL_TYPE: fprintf(file, "OBNC_REAL"); break; - case TREES_ROR_PROC: - if (ContainsProcedureCall(Trees_Left(node)) || ContainsProcedureCall(Trees_Right(node))) { - fprintf(file, "OBNC_Ror("); - } else { - fprintf(file, "OBNC_ROR("); - } - Generate(Trees_Left(node), file, 0); - fprintf(file, ")"); - break; case TREES_SIZE_PROC: fprintf(file, "OBNC_SIZE("); Generate(Trees_Left(node), file, 0); @@ -2933,24 +2870,6 @@ static void Generate(Trees_Node node, FILE *file, int indent) Generate(Trees_Left(node), file, indent); Generate(Trees_Right(node), file, indent); break; - case TREES_UNPK_PROC: - { - Trees_Node params = Trees_Left(node); - - Indent(file, indent); - if (ContainsProcedureCall(params)) { - fprintf(file, "OBNC_Unpk(&("); - Generate(Trees_Left(params), file, 0); - fprintf(file, "), &("); - Generate(Trees_Right(params), file, 0); - fprintf(file, "));\n"); - } else { - fprintf(file, "OBNC_UNPK("); - Generate(params, file, 0); - fprintf(file, ");\n"); - } - } - break; case TREES_VAL_PROC: fprintf(file, "OBNC_VAL("); Generate(Trees_Left(node), file, 0); diff --git a/src/Trees.c b/src/Trees.c index a219ee1..025ad43 100644 --- a/src/Trees.c +++ b/src/Trees.c @@ -268,9 +268,6 @@ static void PrintLabel(int symbol) case TREES_ADR_PROC: printf("SYSTEM.ADR"); break; - case TREES_ASR_PROC: - printf("ASR"); - break; case TREES_ASSERT_PROC: printf("ASSERT"); break; @@ -307,9 +304,6 @@ static void PrintLabel(int symbol) case TREES_DESIGNATOR: printf("designator"); break; - case TREES_EXCL_PROC: - printf("EXCL"); - break; case TREES_EXP_LIST: printf("ExpList"); break; @@ -334,33 +328,21 @@ static void PrintLabel(int symbol) case TREES_INC_PROC: printf("INC"); break; - case TREES_INCL_PROC: - printf("INCL"); - break; case TREES_INTEGER_TYPE: printf("IntegerType"); break; case TREES_LEN_PROC: printf("LEN"); break; - case TREES_LSL_PROC: - printf("LSL"); - break; case TREES_NEW_PROC: printf("NEW"); break; case TREES_NIL_TYPE: printf("NilType"); break; - case TREES_ODD_PROC: - printf("ODD"); - break; case TREES_ORD_PROC: printf("ORD"); break; - case TREES_PACK_PROC: - printf("PACK"); - break; case TREES_PROCEDURE_CALL: printf("ProcedureCall"); break; @@ -373,9 +355,6 @@ static void PrintLabel(int symbol) case TREES_REAL_TYPE: printf("RealType"); break; - case TREES_ROR_PROC: - printf("ROR"); - break; case TREES_SIZE_PROC: printf("SYSTEM.SIZE"); break; @@ -385,9 +364,6 @@ static void PrintLabel(int symbol) case TREES_STRING_TYPE: printf("StringType"); break; - case TREES_UNPK_PROC: - printf("UNPK"); - break; case TREES_VAL_PROC: printf("SYSTEM.VAL"); break; diff --git a/src/Trees.h b/src/Trees.h index 9dd888c..2cdc70b 100644 --- a/src/Trees.h +++ b/src/Trees.h @@ -36,23 +36,15 @@ enum { TREES_NIL_TYPE, TREES_ABS_PROC, - TREES_ASR_PROC, TREES_ASSERT_PROC, TREES_CHR_PROC, TREES_DEC_PROC, - TREES_EXCL_PROC, TREES_FLOOR_PROC, TREES_FLT_PROC, TREES_INC_PROC, - TREES_INCL_PROC, TREES_LEN_PROC, - TREES_LSL_PROC, TREES_NEW_PROC, - TREES_ODD_PROC, TREES_ORD_PROC, - TREES_PACK_PROC, - TREES_ROR_PROC, - TREES_UNPK_PROC, TREES_CASE, TREES_CASE_LABEL_LIST, diff --git a/src/Types.c b/src/Types.c index d27dc9a..b3dd403 100644 --- a/src/Types.c +++ b/src/Types.c @@ -37,24 +37,16 @@ int Types_IsType(Trees_Node node) case TREES_BYTE_TYPE: case TREES_STRING_TYPE: case TREES_ABS_PROC: - case TREES_ASR_PROC: case TREES_ASSERT_PROC: case TREES_CHR_PROC: case TREES_DEC_PROC: - case TREES_EXCL_PROC: case TREES_FLOOR_PROC: case TREES_FLT_PROC: case TREES_INC_PROC: - case TREES_INCL_PROC: case TREES_LEN_PROC: - case TREES_LSL_PROC: case TREES_NEW_PROC: case TREES_NIL_TYPE: - case TREES_ODD_PROC: case TREES_ORD_PROC: - case TREES_PACK_PROC: - case TREES_ROR_PROC: - case TREES_UNPK_PROC: case TREES_ADR_PROC: case TREES_SIZE_PROC: @@ -495,23 +487,15 @@ int Types_IsPredeclaredProcedure(Trees_Node type) predeclared = 0; switch (Trees_Symbol(Types_Structure(type))) { case TREES_ABS_PROC: - case TREES_ASR_PROC: case TREES_ASSERT_PROC: case TREES_CHR_PROC: case TREES_DEC_PROC: - case TREES_EXCL_PROC: case TREES_FLOOR_PROC: case TREES_FLT_PROC: case TREES_INC_PROC: - case TREES_INCL_PROC: case TREES_LEN_PROC: - case TREES_LSL_PROC: case TREES_NEW_PROC: - case TREES_ODD_PROC: case TREES_ORD_PROC: - case TREES_PACK_PROC: - case TREES_ROR_PROC: - case TREES_UNPK_PROC: /*SYSTEM*/ case TREES_ADR_PROC: case TREES_SIZE_PROC: -- 2.49.0