Skip to content

Commit

Permalink
removed unused xor and not primitives
Browse files Browse the repository at this point in the history
  • Loading branch information
billhails committed Dec 1, 2024
1 parent d8b3243 commit edccc34
Show file tree
Hide file tree
Showing 21 changed files with 1 addition and 293 deletions.
4 changes: 0 additions & 4 deletions docs/generated/anf.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 0 additions & 4 deletions docs/generated/lambda.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion fn/rewrite/pratt.fn
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
9 changes: 0 additions & 9 deletions src/anf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ structs:
exp1: Aexp
exp2: Aexp

AexpUnaryApp:
type: AexpUnaryOp
exp: Aexp

AexpList:
exp: Aexp
next: AexpList
Expand Down Expand Up @@ -153,7 +149,6 @@ unions:
littleinteger: int
character: character
prim: AexpPrimApp
unary: AexpUnaryApp
makeVec: AexpMakeVec
namespaces: AexpNamespaces

Expand Down Expand Up @@ -195,13 +190,9 @@ enums:
- LE
- GE
- VEC
- XOR
- MOD
- CMP

AexpUnaryOp:
- NOT

hashes:
AnfSymbolTable: {}

Expand Down
55 changes: 0 additions & 55 deletions src/anf_normalize.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
19 changes: 0 additions & 19 deletions src/anf_pp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion src/anf_pp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 0 additions & 15 deletions src/annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 ");
Expand Down Expand Up @@ -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:
Expand Down
24 changes: 0 additions & 24 deletions src/bytecode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion src/bytecode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions src/cekfs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,8 @@ enums:
- PRIM_LT
- PRIM_GE
- PRIM_LE
- PRIM_XOR
- PRIM_MAKEVEC
- PRIM_VEC
- PRIM_NOT
- MATCH
- APPLY
- IF
Expand Down
8 changes: 0 additions & 8 deletions src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading

0 comments on commit edccc34

Please sign in to comment.