Skip to content

Commit

Permalink
Merge pull request #3197 from seagull-kamome/removaloftheworld
Browse files Browse the repository at this point in the history
[RefC] [Cleanup] Erase the World (not a fantasy things)
  • Loading branch information
andrevidela committed Jan 21, 2024
2 parents d34cf62 + cabc7ab commit d2d6be5
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 20 deletions.
8 changes: 4 additions & 4 deletions src/Compiler/RefC/RefC.idr
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ cPrimType Bits64Type = "Bits64"
cPrimType StringType = "string"
cPrimType CharType = "char"
cPrimType DoubleType = "double"
cPrimType WorldType = "f32"
cPrimType WorldType = "void"

cConstant : Constant -> String
cConstant (I x) = "(Value*)makeInt64("++ showIntMin x ++")"
Expand All @@ -155,7 +155,7 @@ cConstant (Db x) = "(Value*)makeDouble("++ show x ++")"
cConstant (Ch x) = "(Value*)makeChar("++ escapeChar x ++")"
cConstant (Str x) = "(Value*)makeString("++ cStringQuoted x ++")"
cConstant (PrT t) = cPrimType t
cConstant WorldVal = "(Value*)makeWorld()"
cConstant WorldVal = "(Value*)NULL"

extractConstant : Constant -> String
extractConstant (I x) = show x
Expand Down Expand Up @@ -803,7 +803,7 @@ extractValue _ CFPtr varName = "((Value_Pointer*)" ++ varName ++ ")->
extractValue _ CFGCPtr varName = "((Value_GCPointer*)" ++ varName ++ ")->p->p"
extractValue CLangC CFBuffer varName = "((Value_Buffer*)" ++ varName ++ ")->buffer->data"
extractValue CLangRefC CFBuffer varName = "((Value_Buffer*)" ++ varName ++ ")->buffer"
extractValue _ CFWorld varName = "(Value_World*)" ++ varName
extractValue _ CFWorld _ = "(Value *)NULL"
extractValue _ (CFFun x y) varName = "(Value_Closure*)" ++ varName
extractValue c (CFIORes x) varName = extractValue c x varName
extractValue _ (CFStruct x xs) varName = assert_total $ idris_crash ("INTERNAL ERROR: Struct access not implemented: " ++ varName)
Expand All @@ -828,7 +828,7 @@ packCFType CFChar varName = "makeChar(" ++ varName ++ ")"
packCFType CFPtr varName = "makePointer(" ++ varName ++ ")"
packCFType CFGCPtr varName = "makePointer(" ++ varName ++ ")"
packCFType CFBuffer varName = "makeBuffer(" ++ varName ++ ")"
packCFType CFWorld varName = "makeWorld(" ++ varName ++ ")"
packCFType CFWorld _ = "(Value *)NULL"
packCFType (CFFun x y) varName = "makeFunction(" ++ varName ++ ")"
packCFType (CFIORes x) varName = packCFType x varName
packCFType (CFStruct x xs) varName = "makeStruct(" ++ varName ++ ")"
Expand Down
6 changes: 0 additions & 6 deletions support/refc/_datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#define CONDITION_TAG 31

#define COMPLETE_CLOSURE_TAG 98 // for trampoline tail recursion handling
#define WORLD_TAG 99

typedef struct {
int refCounter;
Expand Down Expand Up @@ -176,8 +175,3 @@ typedef struct {
int filled;
int total;
} IORef_Storage;

typedef struct {
Value_header header;
IORef_Storage *listIORefs;
} Value_World;
9 changes: 0 additions & 9 deletions support/refc/memoryManagement.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,6 @@ Value_Array *makeArray(int length) {
return a;
}

Value_World *makeWorld() {
Value_World *retVal = IDRIS2_NEW_VALUE(Value_World);
retVal->header.tag = WORLD_TAG;
return retVal;
}

Value *newReference(Value *source) {
// note that we explicitly allow NULL as source (for erased arguments)
if (source) {
Expand Down Expand Up @@ -291,9 +285,6 @@ void removeReference(Value *elem) {
removeReference((Value *)vPtr->p);
break;
}
case WORLD_TAG:
/* nothing to delete, added for sake of completeness */
break;

default:
break;
Expand Down
1 change: 0 additions & 1 deletion support/refc/memoryManagement.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,3 @@ Value_Pointer *makePointer(void *);
Value_GCPointer *makeGCPointer(void *ptr_Raw, Value_Closure *onCollectFct);
Value_Buffer *makeBuffer(void *buf);
Value_Array *makeArray(int length);
Value_World *makeWorld(void);

0 comments on commit d2d6be5

Please sign in to comment.