Skip to content

Commit

Permalink
finish pulling out closure address table
Browse files Browse the repository at this point in the history
  • Loading branch information
nic-donaldson committed Jun 28, 2020
1 parent 0ea47ed commit 2d5b566
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
29 changes: 28 additions & 1 deletion src/EXTClosureAddressTable.cpp
@@ -1,4 +1,5 @@
#include <EXTClosureAddressTable.h>
#include <EXTZONES.h>

#include <cstring>

Expand Down Expand Up @@ -59,6 +60,32 @@ EXPORT bool check_address_type(uint64_t id, closure_address_table* table, const
return 0;
}


// TODO: don't duplicate this, put it somewhere
static uint64_t string_hash(const char* str)
{
uint64_t result(0);
unsigned char c;
while((c = *(str++))) {
result = result * 33 + uint8_t(c);
}
return result;
}

EXPORT closure_address_table* add_address_table(llvm_zone_t* zone, char* name, uint32_t offset, char* type, int alloctype, struct closure_address_table* table)
{
struct closure_address_table* t = NULL;
if (alloctype == 1) {
t = reinterpret_cast<closure_address_table*>(malloc(sizeof(struct closure_address_table)));
} else {
t = (struct closure_address_table*) extemp::EXTZONES::llvm_zone_malloc(zone,sizeof(struct closure_address_table));
}
t->id = string_hash(name);
t->name = name;
t->offset = offset;
t->type = type;
t->next = table;
return t;
}

} // namespace ClosureAddressTable
} // namespace extemp
19 changes: 0 additions & 19 deletions src/EXTLLVM.cpp
Expand Up @@ -340,25 +340,6 @@ EXPORT float imp_rand2_f(float Start, float Limit)






EXPORT extemp::ClosureAddressTable::closure_address_table* add_address_table(llvm_zone_t* zone, char* name, uint32_t offset, char* type, int alloctype, struct extemp::ClosureAddressTable::closure_address_table* table)
{
struct extemp::ClosureAddressTable::closure_address_table* t = NULL;
if (alloctype == 1) {
t = reinterpret_cast<extemp::ClosureAddressTable::closure_address_table*>(malloc(sizeof(struct extemp::ClosureAddressTable::closure_address_table)));
} else {
t = (struct extemp::ClosureAddressTable::closure_address_table*) extemp::EXTZONES::llvm_zone_malloc(zone,sizeof(struct extemp::ClosureAddressTable::closure_address_table));
}
t->id = string_hash(name);
t->name = name;
t->offset = offset;
t->type = type;
t->next = table;
return t;
}

bool llvm_check_valid_dot_symbol(scheme* sc, char* symbol) {
char c[1024];
auto pos(strchr(symbol, '.'));
Expand Down

0 comments on commit 2d5b566

Please sign in to comment.