From edccc346fe644b96ef4e873aefa66d3db22fe6bc Mon Sep 17 00:00:00 2001 From: Bill Hails Date: Sun, 1 Dec 2024 12:20:03 +0000 Subject: [PATCH] removed unused xor and not primitives --- docs/generated/anf.md | 4 --- docs/generated/lambda.md | 4 --- fn/rewrite/pratt.fn | 2 +- src/anf.yaml | 9 ------- src/anf_normalize.c | 55 -------------------------------------- src/anf_pp.c | 19 ------------- src/anf_pp.h | 1 - src/annotate.c | 15 ----------- src/bytecode.c | 24 ----------------- src/bytecode.h | 1 - src/cekfs.yaml | 2 -- src/debug.c | 8 ------ src/inline.c | 9 ------- src/lambda.yaml | 9 ------- src/lambda_pp.c | 28 ------------------- src/lambda_pp.h | 2 -- src/lambda_simplfication.c | 10 ------- src/lambda_substitution.c | 12 --------- src/macro_substitution.c | 10 ------- src/step.c | 34 ----------------------- src/tc_analyze.c | 36 ------------------------- 21 files changed, 1 insertion(+), 293 deletions(-) diff --git a/docs/generated/anf.md b/docs/generated/anf.md index 4dd04ca9..0d76a749 100644 --- a/docs/generated/anf.md +++ b/docs/generated/anf.md @@ -25,8 +25,6 @@ AexpAnnotatedVar --var--> HashSymbol AexpPrimApp --type--> AexpPrimOp AexpPrimApp --exp1--> Aexp AexpPrimApp --exp2--> Aexp -AexpUnaryApp --type--> AexpUnaryOp -AexpUnaryApp --exp--> Aexp AexpList --exp--> Aexp AexpList --next--> AexpList AexpIntList --integer--> int @@ -80,7 +78,6 @@ Aexp --biginteger--> MaybeBigInt Aexp --littleinteger--> int Aexp --character--> character Aexp --prim--> AexpPrimApp -Aexp --unary--> AexpUnaryApp Aexp --makeVec--> AexpMakeVec Aexp --namespaces--> AexpNamespaces Cexp --back--> void_ptr @@ -101,7 +98,6 @@ Exp --let--> ExpLet Exp --lookup--> ExpLookup AexpAnnotatedVarType["enum AexpAnnotatedVarType"] AexpPrimOp["enum AexpPrimOp"] -AexpUnaryOp["enum AexpUnaryOp"] AexpNamespaceArray["AexpNamespaceArray[]"] --entries--> AexpNamespace CTEnvArray["CTEnvArray[]"] --entries--> CTEnv CexpCondCasesVal diff --git a/docs/generated/lambda.md b/docs/generated/lambda.md index 90e92d00..ca1976d0 100644 --- a/docs/generated/lambda.md +++ b/docs/generated/lambda.md @@ -16,8 +16,6 @@ LamVarList --next--> LamVarList LamPrimApp --type--> LamPrimOp LamPrimApp --exp1--> LamExp LamPrimApp --exp2--> LamExp -LamUnaryApp --type--> LamUnaryOp -LamUnaryApp --exp--> LamExp LamSequence --exp--> LamExp LamSequence --next--> LamSequence LamList --exp--> LamExp @@ -116,7 +114,6 @@ LamExp --var--> HashSymbol LamExp --stdint--> int LamExp --biginteger--> MaybeBigInt LamExp --prim--> LamPrimApp -LamExp --unary--> LamUnaryApp LamExp --list--> LamSequence LamExp --makeVec--> LamMakeVec LamExp --construct--> LamConstruct @@ -156,7 +153,6 @@ LamInfo --typeConstructorInfo--> LamTypeConstructorInfo LamInfo --namespaceInfo--> LamContext LamInfo --nsid--> int LamPrimOp["enum LamPrimOp"] -LamUnaryOp["enum LamUnaryOp"] LamNamespaceArray["LamNamespaceArray[]"] --entries--> LamExp LamExpVal LamExpType diff --git a/fn/rewrite/pratt.fn b/fn/rewrite/pratt.fn index 1fbf1a86..20bfc2c0 100644 --- a/fn/rewrite/pratt.fn +++ b/fn/rewrite/pratt.fn @@ -51,7 +51,7 @@ let } (some(#(lex.Op(it), lexer))) { expr_bp(lexer, prefix_bp(it)) => fn (#(rhs, lexer)) { - []; + // []; loop(exp.Cons(it, [rhs]), lex.peek(lexer), lexer) } } diff --git a/src/anf.yaml b/src/anf.yaml index 35da31c6..f7b7eb87 100644 --- a/src/anf.yaml +++ b/src/anf.yaml @@ -56,10 +56,6 @@ structs: exp1: Aexp exp2: Aexp - AexpUnaryApp: - type: AexpUnaryOp - exp: Aexp - AexpList: exp: Aexp next: AexpList @@ -153,7 +149,6 @@ unions: littleinteger: int character: character prim: AexpPrimApp - unary: AexpUnaryApp makeVec: AexpMakeVec namespaces: AexpNamespaces @@ -195,13 +190,9 @@ enums: - LE - GE - VEC - - XOR - MOD - CMP - AexpUnaryOp: - - NOT - hashes: AnfSymbolTable: {} diff --git a/src/anf_normalize.c b/src/anf_normalize.c index d7019a65..581d8800 100644 --- a/src/anf_normalize.c +++ b/src/anf_normalize.c @@ -42,7 +42,6 @@ static Exp *normalizeVar(HashSymbol *var, Exp *tail); static Exp *normalizeMaybeBigInteger(MaybeBigInt *integer, Exp *tail); static Exp *normalizeStdInteger(int integer, Exp *tail); static Exp *normalizeCharacter(Character character, Exp *tail); -static Exp *normalizeUnary(LamUnaryApp *app, Exp *tail); static Exp *normalizeAmb(LamAmb *app, Exp *tail); static Exp *normalizeSequence(LamSequence *sequence, Exp *tail); static Exp *normalizePrim(LamPrimApp *app, Exp *tail); @@ -52,7 +51,6 @@ static Exp *normalizeError(Exp *tail); static HashSymbol *freshSymbol(); static LamExpTable *makeLamExpHashTable(); static Aexp *replaceLamExp(LamExp *lamExp, LamExpTable *replacements); -static AexpUnaryOp mapUnaryOp(LamUnaryOp op); static Exp *letBind(Exp *body, LamExpTable *replacements); static AexpPrimOp mapPrimOp(LamPrimOp op); static Aexp *aexpNormalizeVar(HashSymbol *var); @@ -65,8 +63,6 @@ static AexpVarList *convertVarList(LamVarList *args); static AexpList *replaceLamList(LamList *list, LamExpTable *replacements); static Aexp *replaceLamPrim(LamPrimApp *lamPrimApp, LamExpTable *replacements); -static Aexp *replaceLamUnary(LamUnaryApp *lamUnaryApp, - LamExpTable *replacements); static Aexp *replaceLamMakeVec(LamMakeVec *makeVec, LamExpTable *replacements); static Aexp *replaceLamConstruct(LamConstruct *construct, @@ -113,8 +109,6 @@ static Exp *normalize(LamExp *lamExp, Exp *tail) { return normalizeMaybeBigInteger(lamExp->val.biginteger, tail); case LAMEXP_TYPE_PRIM: return normalizePrim(lamExp->val.prim, tail); - case LAMEXP_TYPE_UNARY: - return normalizeUnary(lamExp->val.unary, tail); case LAMEXP_TYPE_AMB: return normalizeAmb(lamExp->val.amb, tail); case LAMEXP_TYPE_LIST: @@ -535,27 +529,6 @@ static Exp *wrapTail(Exp *exp, Exp *tail) { return exp; } -static Exp *normalizeUnary(LamUnaryApp *app, Exp *tail) { - ENTER(normalizeUnary); - LamExpTable *replacements = makeLamExpHashTable(); - int save = PROTECT(replacements); - Aexp *aexp = replaceLamExp(app->exp, replacements); - int save2 = PROTECT(aexp); - AexpUnaryApp *aexpUnaryApp = newAexpUnaryApp(mapUnaryOp(app->type), aexp); - UNPROTECT(save2); - save2 = PROTECT(aexpUnaryApp); - Aexp *aexp2 = newAexp_Unary(aexpUnaryApp); - REPLACE_PROTECT(save2, aexp2); - Exp *exp = wrapAexp(aexp2); - REPLACE_PROTECT(save2, exp); - exp = wrapTail(exp, tail); - REPLACE_PROTECT(save2, exp); - Exp *res = letBind(exp, replacements); - UNPROTECT(save); - LEAVE(normalizeUnary); - return res; -} - static Exp *normalizePrim(LamPrimApp *app, Exp *tail) { ENTER(normalizePrim); LamExpTable *replacements = makeLamExpHashTable(); @@ -930,9 +903,6 @@ static Aexp *replaceLamExp(LamExp *lamExp, LamExpTable *replacements) { case LAMEXP_TYPE_PRIM: res = replaceLamPrim(lamExp->val.prim, replacements); break; - case LAMEXP_TYPE_UNARY: - res = replaceLamUnary(lamExp->val.unary, replacements); - break; case LAMEXP_TYPE_PRINT: res = replaceLamPrint(lamExp->val.print, replacements); break; @@ -995,7 +965,6 @@ static bool lamExpIsLambda(LamExp *val) { case LAMEXP_TYPE_ERROR: case LAMEXP_TYPE_AMB: case LAMEXP_TYPE_PRIM: - case LAMEXP_TYPE_UNARY: case LAMEXP_TYPE_LIST: case LAMEXP_TYPE_APPLY: case LAMEXP_TYPE_IFF: @@ -1120,28 +1089,6 @@ static Aexp *replaceLamPrim(LamPrimApp *lamPrimApp, LamExpTable *replacements) { return res; } -static Aexp *replaceLamUnary(LamUnaryApp *lamUnaryApp, - LamExpTable *replacements) { - ENTER(replaceLamUnary); - Aexp *exp = replaceLamExp(lamUnaryApp->exp, replacements); - int save = PROTECT(exp); - AexpUnaryApp *unary = newAexpUnaryApp(mapUnaryOp(lamUnaryApp->type), exp); - PROTECT(unary); - Aexp *res = newAexp_Unary(unary); - UNPROTECT(save); - LEAVE(replaceLamUnary); - return res; -} - -static AexpUnaryOp mapUnaryOp(LamUnaryOp op) { - switch (op) { - case LAMUNARYOP_TYPE_NOT: - return AEXPUNARYOP_TYPE_NOT; - default: - cant_happen("unrecognised type %d in mapUnaryOp", op); - } -} - static AexpPrimOp mapPrimOp(LamPrimOp op) { switch (op) { case LAMPRIMOP_TYPE_ADD: @@ -1168,8 +1115,6 @@ static AexpPrimOp mapPrimOp(LamPrimOp op) { return AEXPPRIMOP_TYPE_LE; case LAMPRIMOP_TYPE_VEC: return AEXPPRIMOP_TYPE_VEC; - case LAMPRIMOP_TYPE_XOR: - return AEXPPRIMOP_TYPE_XOR; case LAMPRIMOP_TYPE_MOD: return AEXPPRIMOP_TYPE_MOD; case LAMPRIMOP_TYPE_CMP: diff --git a/src/anf_pp.c b/src/anf_pp.c index f0baefae..10c4c5bd 100644 --- a/src/anf_pp.c +++ b/src/anf_pp.c @@ -122,9 +122,6 @@ void ppAexpPrimApp(AexpPrimApp *x) { case AEXPPRIMOP_TYPE_LE: eprintf("le "); break; - case AEXPPRIMOP_TYPE_XOR: - eprintf("xor "); - break; case AEXPPRIMOP_TYPE_VEC: eprintf("vec "); break; @@ -148,19 +145,6 @@ void ppAexpPrimApp(AexpPrimApp *x) { eprintf(")"); } -void ppAexpUnaryApp(AexpUnaryApp *x) { - eprintf("("); - switch (x->type) { - case AEXPUNARYOP_TYPE_NOT: - eprintf("not "); - break; - default: - cant_happen("unrecognized op in ppAexpUnaryApp (%d)", x->type); - } - ppAexp(x->exp); - eprintf(")"); -} - static void ppAexpListContents(AexpList *x) { while (x != NULL) { ppAexp(x->exp); @@ -390,9 +374,6 @@ void ppAexp(Aexp *x) { case AEXP_TYPE_PRIM: ppAexpPrimApp(x->val.prim); break; - case AEXP_TYPE_UNARY: - ppAexpUnaryApp(x->val.unary); - break; case AEXP_TYPE_MAKEVEC: ppAexpMakeVec(x->val.makeVec); break; diff --git a/src/anf_pp.h b/src/anf_pp.h index 86994099..4fdb36b8 100644 --- a/src/anf_pp.h +++ b/src/anf_pp.h @@ -32,7 +32,6 @@ void ppAexpVarList(AexpVarList *x); void ppAexpVar(HashSymbol *x); void ppAexpAnnotatedVar(AexpAnnotatedVar *x); void ppAexpPrimApp(AexpPrimApp *x); -void ppAexpUnaryApp(AexpUnaryApp *x); void ppAexpList(AexpList *x); void ppAexpIntList(AexpIntList *x); void ppAexpMakeList(AexpList *x); diff --git a/src/annotate.c b/src/annotate.c index cb454961..efb70624 100644 --- a/src/annotate.c +++ b/src/annotate.c @@ -43,7 +43,6 @@ static CTEnv *annotateExp(Exp *x, CTEnv *env); static CTEnv *annotateAexpLam(AexpLam *x, CTEnv *env); static AexpAnnotatedVar *annotateAexpVar(HashSymbol *x, CTEnv *env); static CTEnv *annotateAexpPrimApp(AexpPrimApp *x, CTEnv *env); -static CTEnv *annotateAexpUnaryApp(AexpUnaryApp *x, CTEnv *env); static CTEnv *annotateAexpList(AexpList *x, CTEnv *env); static CTEnv *annotateCexpApply(CexpApply *x, CTEnv *env); static CTEnv *annotateCexpIf(CexpIf *x, CTEnv *env); @@ -119,18 +118,6 @@ static CTEnv *annotateAexpPrimApp(AexpPrimApp *x, CTEnv *env) { return env; } -static CTEnv *annotateAexpUnaryApp(AexpUnaryApp *x, CTEnv *env) { -#ifdef DEBUG_ANNOTATE2 - eprintf("annotateAexpPrimApp "); - ppAexpUnaryApp(x); - eprintf(" "); - ppCTEnv(env); - eprintf("\n"); -#endif - annotateAexp(x->exp, env); - return env; -} - static CTEnv *annotateAexpList(AexpList *x, CTEnv *env) { #ifdef DEBUG_ANNOTATE2 eprintf("annotateAexpList "); @@ -387,8 +374,6 @@ static CTEnv *annotateAexp(Aexp *x, CTEnv *env) { return env; case AEXP_TYPE_PRIM: return annotateAexpPrimApp(x->val.prim, env); - case AEXP_TYPE_UNARY: - return annotateAexpUnaryApp(x->val.unary, env); case AEXP_TYPE_MAKEVEC: return annotateAexpMakeVec(x->val.makeVec, env); case AEXP_TYPE_NAMESPACES: diff --git a/src/bytecode.c b/src/bytecode.c index 02f4840b..ec39bca3 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -196,23 +196,6 @@ void writeAexpAnnotatedVar(AexpAnnotatedVar *x, ByteCodeArray *b) { LEAVE(writeAexpAnnotatedVar); } -void writeAexpUnaryApp(AexpUnaryApp *x, ByteCodeArray *b) { - ENTER(writeAexpUnaryApp); - if (x == NULL) - return; - writeAexp(x->exp, b); - Byte prim; - switch (x->type) { - case AEXPUNARYOP_TYPE_NOT: - prim = BYTECODES_TYPE_PRIM_NOT; - break; - default: - cant_happen("unrecognised AexpUnaryOp in writeAexpUnaryApp"); - } - addByte(b, prim); - LEAVE(writeAexpUnaryApp); -} - void writeAexpPrimApp(AexpPrimApp *x, ByteCodeArray *b) { ENTER(writeAexpPrimApp); if (x == NULL) @@ -257,9 +240,6 @@ void writeAexpPrimApp(AexpPrimApp *x, ByteCodeArray *b) { case AEXPPRIMOP_TYPE_LE: prim = BYTECODES_TYPE_PRIM_LE; break; - case AEXPPRIMOP_TYPE_XOR: - prim = BYTECODES_TYPE_PRIM_XOR; - break; case AEXPPRIMOP_TYPE_VEC: prim = BYTECODES_TYPE_PRIM_VEC; break; @@ -652,10 +632,6 @@ void writeAexp(Aexp *x, ByteCodeArray *b) { writeAexpPrimApp(x->val.prim, b); } break; - case AEXP_TYPE_UNARY:{ - writeAexpUnaryApp(x->val.unary, b); - } - break; case AEXP_TYPE_MAKEVEC:{ writeAexpMakeVec(x->val.makeVec, b); } diff --git a/src/bytecode.h b/src/bytecode.h index da53bda0..4d6f48a4 100644 --- a/src/bytecode.h +++ b/src/bytecode.h @@ -40,7 +40,6 @@ void resetByteCodeArray(ByteCodeArray *b); void writeAexpLam(AexpLam *x, ByteCodeArray *b); void writeAexpAnnotatedVar(AexpAnnotatedVar *x, ByteCodeArray *b); void writeAexpPrimApp(AexpPrimApp *x, ByteCodeArray *b); -void writeAexpUnaryApp(AexpUnaryApp *x, ByteCodeArray *b); void writeAexpList(AexpList *x, ByteCodeArray *b); void writeCexpApply(CexpApply *x, ByteCodeArray *b); void writeCexpIf(CexpIf *x, ByteCodeArray *b); diff --git a/src/cekfs.yaml b/src/cekfs.yaml index 07b73868..939a42fb 100644 --- a/src/cekfs.yaml +++ b/src/cekfs.yaml @@ -121,10 +121,8 @@ enums: - PRIM_LT - PRIM_GE - PRIM_LE - - PRIM_XOR - PRIM_MAKEVEC - PRIM_VEC - - PRIM_NOT - MATCH - APPLY - IF diff --git a/src/debug.c b/src/debug.c index 46ad0545..1e603287 100644 --- a/src/debug.c +++ b/src/debug.c @@ -107,14 +107,6 @@ void dumpByteCode(ByteCodeArray *bca) { eprintf("CMP\n"); } break; - case BYTECODES_TYPE_PRIM_XOR:{ - eprintf("XOR\n"); - } - break; - case BYTECODES_TYPE_PRIM_NOT:{ - eprintf("NOT\n"); - } - break; case BYTECODES_TYPE_PRIM_MAKEVEC:{ int size = readByte(bca, &i); eprintf("MAKEVEC [%d]\n", size); diff --git a/src/inline.c b/src/inline.c index cc8bc0b1..4e488806 100644 --- a/src/inline.c +++ b/src/inline.c @@ -25,7 +25,6 @@ static LamTypeDefs *inlineTypeDefs(LamTypeDefs *x); static LamNamespaceArray *inlineNamespaces(LamNamespaceArray *x); static LamLam *inlineLam(LamLam *x); static LamPrimApp *inlinePrim(LamPrimApp *x); -static LamUnaryApp *inlineUnary(LamUnaryApp *x); static LamSequence *inlineSequence(LamSequence *x); static LamList *inlineList(LamList *x); static LamExp *inlineApply(LamApply *x); @@ -84,11 +83,6 @@ static LamPrimApp *inlinePrim(LamPrimApp *x) { return x; } -static LamUnaryApp *inlineUnary(LamUnaryApp *x) { - x->exp = inlineExp(x->exp); - return x; -} - static LamSequence *inlineSequence(LamSequence *x) { if (x != NULL) { x->next = inlineSequence(x->next); @@ -280,9 +274,6 @@ static LamExp *inlineExp(LamExp *x) { case LAMEXP_TYPE_PRIM: x->val.prim = inlinePrim(x->val.prim); break; - case LAMEXP_TYPE_UNARY: - x->val.unary = inlineUnary(x->val.unary); - break; case LAMEXP_TYPE_LIST: x->val.list = inlineSequence(x->val.list); break; diff --git a/src/lambda.yaml b/src/lambda.yaml index 2469397d..f7f1d8a9 100644 --- a/src/lambda.yaml +++ b/src/lambda.yaml @@ -40,10 +40,6 @@ structs: exp1: LamExp exp2: LamExp - LamUnaryApp: - type: LamUnaryOp - exp: LamExp - LamSequence: exp: LamExp next: LamSequence @@ -222,13 +218,9 @@ enums: - LT - GE - LE - - XOR - CMP - VEC - LamUnaryOp: - - NOT - unions: LamExp: namespaces: LamNamespaceArray @@ -237,7 +229,6 @@ unions: stdint: int biginteger: MaybeBigInt prim: LamPrimApp - unary: LamUnaryApp list: LamSequence makeVec: LamMakeVec construct: LamConstruct diff --git a/src/lambda_pp.c b/src/lambda_pp.c index bbc22276..ec41b0c5 100644 --- a/src/lambda_pp.c +++ b/src/lambda_pp.c @@ -94,9 +94,6 @@ void ppLamExp(LamExp *exp) { case LAMEXP_TYPE_PRIM: ppLamPrimApp(exp->val.prim); break; - case LAMEXP_TYPE_UNARY: - ppLamUnary(exp->val.unary); - break; case LAMEXP_TYPE_LIST: ppLamSequence(exp->val.list); break; @@ -253,9 +250,6 @@ void ppLamPrimOp(LamPrimOp type) { case LAMPRIMOP_TYPE_VEC: eprintf("vec"); break; - case LAMPRIMOP_TYPE_XOR: - eprintf("xor"); - break; case LAMPRIMOP_TYPE_MOD: eprintf("mod"); break; @@ -270,28 +264,6 @@ void ppLamPrimOp(LamPrimOp type) { } } -void ppLamUnary(LamUnaryApp *unaryApp) { - if (unaryApp == NULL) { - eprintf(""); - return; - } - eprintf("("); - ppLamUnaryOp(unaryApp->type); - eprintf(" "); - ppLamExp(unaryApp->exp); - eprintf(")"); -} - -void ppLamUnaryOp(LamUnaryOp type) { - switch (type) { - case LAMUNARYOP_TYPE_NOT: - eprintf("not"); - break; - default: - cant_happen("unrecognised type %s in ppLamUnaryOp", lamUnaryOpName(type)); - } -} - static void _ppLamSequence(LamSequence *sequence) { if (sequence == NULL) return; diff --git a/src/lambda_pp.h b/src/lambda_pp.h index f4443753..10777683 100644 --- a/src/lambda_pp.h +++ b/src/lambda_pp.h @@ -30,8 +30,6 @@ void ppLamExp(LamExp *exp); void ppHashSymbol(HashSymbol *symbol); void ppLamPrimApp(LamPrimApp *primApp); void ppLamPrimOp(LamPrimOp type); -void ppLamUnary(LamUnaryApp *unaryApp); -void ppLamUnaryOp(LamUnaryOp type); void ppLamSequence(LamSequence *sequence); void ppLamMakeVec(LamMakeVec *makeVec); void ppLamApply(LamApply *apply); diff --git a/src/lambda_simplfication.c b/src/lambda_simplfication.c index d6e6687c..aa591af2 100644 --- a/src/lambda_simplfication.c +++ b/src/lambda_simplfication.c @@ -58,13 +58,6 @@ static LamPrimApp *performPrimSimplifications(LamPrimApp *prim) { return prim; } -static LamUnaryApp *performUnarySimplifications(LamUnaryApp *unary) { - ENTER(performUnarySimplifications); - unary->exp = lamPerformSimplifications(unary->exp); - LEAVE(performUnarySimplifications); - return unary; -} - static LamSequence *_performSequenceSimplifications(LamSequence *sequence) { ENTER(_performSequenceSimplifications); if (sequence == NULL) { @@ -306,9 +299,6 @@ LamExp *lamPerformSimplifications(LamExp *exp) { case LAMEXP_TYPE_PRIM: exp->val.prim = performPrimSimplifications(exp->val.prim); break; - case LAMEXP_TYPE_UNARY: - exp->val.unary = performUnarySimplifications(exp->val.unary); - break; case LAMEXP_TYPE_LIST: exp = performSequenceSimplifications(CPI(exp), exp->val.list); break; diff --git a/src/lambda_substitution.c b/src/lambda_substitution.c index 7bfa8907..358c6086 100644 --- a/src/lambda_substitution.c +++ b/src/lambda_substitution.c @@ -92,14 +92,6 @@ static LamPrimApp *performPrimSubstitutions(LamPrimApp *prim, TpmcSubstitutionTa return prim; } -static LamUnaryApp *performUnarySubstitutions(LamUnaryApp *unary, TpmcSubstitutionTable - *substitutions) { - ENTER(performUnarySubstitutions); - unary->exp = lamPerformSubstitutions(unary->exp, substitutions); - LEAVE(performUnarySubstitutions); - return unary; -} - static LamSequence *performSequenceSubstitutions(LamSequence *sequence, TpmcSubstitutionTable *substitutions) { ENTER(performSequenceSubstitutions); @@ -357,10 +349,6 @@ LamExp *lamPerformSubstitutions(LamExp *exp, exp->val.prim = performPrimSubstitutions(exp->val.prim, substitutions); break; - case LAMEXP_TYPE_UNARY: - exp->val.unary = - performUnarySubstitutions(exp->val.unary, substitutions); - break; case LAMEXP_TYPE_LIST: exp->val.list = performSequenceSubstitutions(exp->val.list, substitutions); diff --git a/src/macro_substitution.c b/src/macro_substitution.c index f2f92e26..993eb25b 100644 --- a/src/macro_substitution.c +++ b/src/macro_substitution.c @@ -129,13 +129,6 @@ static LamPrimApp *performPrimSubstitutions(LamPrimApp *prim, LamMacroArgsTable return prim; } -static LamUnaryApp *performUnarySubstitutions(LamUnaryApp *unary, LamMacroArgsTable *symbols) { - ENTER(performUnarySubstitutions); - unary->exp = lamPerformMacroSubstitutions(unary->exp, symbols); - LEAVE(performUnarySubstitutions); - return unary; -} - static LamSequence *performSequenceSubstitutions(LamSequence *sequence, LamMacroArgsTable *symbols) { ENTER(performSequenceSubstitutions); if (sequence == NULL) { @@ -392,9 +385,6 @@ LamExp *lamPerformMacroSubstitutions(LamExp *exp, LamMacroArgsTable *symbols) { case LAMEXP_TYPE_PRIM: exp->val.prim = performPrimSubstitutions(exp->val.prim, symbols); break; - case LAMEXP_TYPE_UNARY: - exp->val.unary = performUnarySubstitutions(exp->val.unary, symbols); - break; case LAMEXP_TYPE_LIST: exp->val.list = performSequenceSubstitutions(exp->val.list, symbols); break; diff --git a/src/step.c b/src/step.c index 9622ea51..141eb5f6 100644 --- a/src/step.c +++ b/src/step.c @@ -286,10 +286,6 @@ static bool _lt(Value left, Value right) { return _cmp(left, right) == CMP_LT; } -static bool _xor(Value left, Value right) { - return truthy(left) ? !truthy(right) : truthy(right); -} - static Value eq(Value left, Value right) { bool result = _eq(left, right); return result ? vTrue : vFalse; @@ -315,19 +311,11 @@ static Value ge(Value left, Value right) { return result ? vFalse : vTrue; } -static Value xor(Value left, Value right) { - return _xor(left, right) ? vTrue : vFalse; -} - static Value le(Value left, Value right) { bool result = _gt(left, right); return result ? vFalse : vTrue; } -static Value not(Value left) { - return truthy(left) ? vFalse : vTrue; -} - static Value vec(Value index, Value vector) { #ifdef SAFETY_CHECKS if (index.type != VALUE_TYPE_STDINT) @@ -734,28 +722,6 @@ static void step() { } break; - case BYTECODES_TYPE_PRIM_XOR:{ - // pop two values, perform the binop and push the result - DEBUG("XOR"); - Value right = pop(); - int save = protectValue(right); - Value left = pop(); - protectValue(left); - push(xor(left, right)); - UNPROTECT(save); - } - break; - - case BYTECODES_TYPE_PRIM_NOT:{ - // pop value, perform the op and push the result - DEBUG("NOT"); - Value a = pop(); - int save = protectValue(a); - push(not(a)); - UNPROTECT(save); - } - break; - case BYTECODES_TYPE_PRIM_VEC:{ DEBUG("VEC"); Value b = pop(); diff --git a/src/tc_analyze.c b/src/tc_analyze.c index a645046d..f65a155f 100644 --- a/src/tc_analyze.c +++ b/src/tc_analyze.c @@ -62,7 +62,6 @@ static TcType *analyzeVar(ParserInfo I, HashSymbol *var, TcEnv *env, TcNg *ng); static TcType *analyzeSmallInteger(); static TcType *analyzeBigInteger(); static TcType *analyzePrim(LamPrimApp *app, TcEnv *env, TcNg *ng); -static TcType *analyzeUnary(LamUnaryApp *app, TcEnv *env, TcNg *ng); static TcType *analyzeSequence(LamSequence *sequence, TcEnv *env, TcNg *ng); static TcType *analyzeConstruct(LamConstruct *construct, TcEnv *env, TcNg *ng); static TcType *analyzeDeconstruct(LamDeconstruct *deconstruct, TcEnv *env, TcNg *ng); @@ -229,8 +228,6 @@ static TcType *analyzeExp(LamExp *exp, TcEnv *env, TcNg *ng) { return prune(analyzeBigInteger()); case LAMEXP_TYPE_PRIM: return prune(analyzePrim(exp->val.prim, env, ng)); - case LAMEXP_TYPE_UNARY: - return prune(analyzeUnary(exp->val.unary, env, ng)); case LAMEXP_TYPE_LIST: return prune(analyzeSequence(exp->val.list, env, ng)); case LAMEXP_TYPE_MAKEVEC: @@ -408,22 +405,6 @@ static TcType *analyzeSpaceship(LamExp *exp1, LamExp *exp2, TcEnv *env, return res; } -static TcType *analyzeBinaryBool(LamExp *exp1, LamExp *exp2, TcEnv *env, - TcNg *ng) { - // ENTER(analyzeBinaryBool); - (void) analyzeBooleanExp(exp1, env, ng); - TcType *res = analyzeBooleanExp(exp2, env, ng); - // LEAVE(analyzeBinaryBool); - return res; -} - -static TcType *analyzeUnaryBool(LamExp *exp, TcEnv *env, TcNg *ng) { - // ENTER(analyzeUnaryBool); - TcType *res = analyzeBooleanExp(exp, env, ng); - // LEAVE(analyzeUnaryBool); - return res; -} - static TcType *analyzePrim(LamPrimApp *app, TcEnv *env, TcNg *ng) { // ENTER(analyzePrim); TcType *res = NULL; @@ -450,9 +431,6 @@ static TcType *analyzePrim(LamPrimApp *app, TcEnv *env, TcNg *ng) { case LAMPRIMOP_TYPE_VEC: cant_happen("encountered VEC in analyzePrim"); break; - case LAMPRIMOP_TYPE_XOR: - res = analyzeBinaryBool(app->exp1, app->exp2, env, ng); - break; default: cant_happen("unrecognised type %d in analyzePrim", app->type); } @@ -460,20 +438,6 @@ static TcType *analyzePrim(LamPrimApp *app, TcEnv *env, TcNg *ng) { return res; } -static TcType *analyzeUnary(LamUnaryApp *app, TcEnv *env, TcNg *ng) { - // ENTER(analyzeUnary); - TcType *res = NULL; - switch (app->type) { - case LAMUNARYOP_TYPE_NOT: - res = analyzeUnaryBool(app->exp, env, ng); - break; - default: - cant_happen("unrecognized type %d in analyzeUnary", app->type); - } - // LEAVE(analyzeUnary); - return res; -} - static TcType *analyzeSequence(LamSequence *sequence, TcEnv *env, TcNg *ng) { // ENTER(analyzeSequence); if (sequence == NULL) {