diff --git a/src/Compiler/RefC/RefC.idr b/src/Compiler/RefC/RefC.idr index ac4e68d19..67e79f447 100644 --- a/src/Compiler/RefC/RefC.idr +++ b/src/Compiler/RefC/RefC.idr @@ -780,7 +780,7 @@ extractValue (CFFun x y) varName = assert_total $ idris_crash ("INTERNAL ERR extractValue (CFIORes x) varName = extractValue x varName extractValue (CFStruct x xs) varName = assert_total $ idris_crash ("INTERNAL ERROR: Struct access not implemented: " ++ varName) -- not really total but this way this internal error does not contaminate everything else -extractValue (CFUser x xs) varName = "Value* " ++ varName +extractValue (CFUser x xs) varName = "(Value*)" ++ varName packCFType : (cfType:CFType) -> (varName:String) -> String packCFType CFUnit varName = "NULL" @@ -799,7 +799,7 @@ packCFType CFWorld varName = "makeWorld(" ++ varName ++ ")" packCFType (CFFun x y) varName = "makeFunction(" ++ varName ++ ")" packCFType (CFIORes x) varName = packCFType x varName packCFType (CFStruct x xs) varName = "makeStruct(" ++ varName ++ ")" -packCFType (CFUser x xs) varName = "makeCustomUser(" ++ varName ++ ")" +packCFType (CFUser x xs) varName = varName discardLastArgument : List ty -> List ty discardLastArgument [] = [] diff --git a/support/refc/memoryManagement.c b/support/refc/memoryManagement.c index 275c394e7..5d19c5a12 100644 --- a/support/refc/memoryManagement.c +++ b/support/refc/memoryManagement.c @@ -122,6 +122,15 @@ Value_Pointer *makePointer(void *ptr_Raw) return p; } +Value_GCPointer *makeGCPointer(void *ptr_Raw, Value_Closure *onCollectFct) +{ + Value_GCPointer *p = (Value_GCPointer *)newValue(); + p->header.tag = GC_POINTER_TAG; + p->p = makePointer(ptr_Raw); + p->onCollectFct = onCollectFct; + return p; +} + Value_Array *makeArray(int length) { Value_Array *a = (Value_Array *)newValue(); diff --git a/support/refc/memoryManagement.h b/support/refc/memoryManagement.h index 23a307123..9dbb93962 100644 --- a/support/refc/memoryManagement.h +++ b/support/refc/memoryManagement.h @@ -22,6 +22,7 @@ Value_String *makeEmptyString(size_t l); Value_String *makeString(char *); Value_Pointer *makePointer(void *); +Value_GCPointer *makeGCPointer(void *ptr_Raw, Value_Closure *onCollectFct); Value_Array *makeArray(int length); Value_World *makeWorld(void);