Skip to content

Commit

Permalink
More int work
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Marr <git@stefan-marr.de>
  • Loading branch information
smarr committed Aug 18, 2024
1 parent 7c8cf11 commit 6e7d9b3
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/compiler/Disassembler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ void Disassembler::dumpMethod(uint8_t* bytecodes, size_t numberOfBytecodes,
*/
void Disassembler::DumpBytecode(VMFrame* frame, VMMethod* method,
size_t bc_idx) {
static long long indentc = 0;
static int64_t indentc = 0;
static char ikind = '@';
uint8_t const bc = BC_0;
VMClass* cl = method->GetHolder();
Expand Down
2 changes: 1 addition & 1 deletion src/memory/DebugCopyingCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static gc_oop_t copy_if_necessary(gc_oop_t oop) {
obj->MarkObjectAsInvalid();
}

obj->SetGCField((long)newObj);
obj->SetGCField((uintptr_t)newObj);
return tmp_ptr(newObj);
}

Expand Down
4 changes: 2 additions & 2 deletions src/primitives/Integer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,14 @@ static vm_oop_t intGreaterThanEqual(vm_oop_t leftObj, vm_oop_t rightObj) {
}

static vm_oop_t intAsString(vm_oop_t self) {
long const integer = INT_VAL(self);
int64_t const integer = INT_VAL(self);
ostringstream Str;
Str << integer;
return Universe::NewString(Str.str());
}

static vm_oop_t intAsDouble(vm_oop_t self) {
long const integer = INT_VAL(self);
int64_t const integer = INT_VAL(self);
return Universe::NewDouble((double)integer);
}

Expand Down
7 changes: 4 additions & 3 deletions src/primitives/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "System.h"

#include <cstdint>
#include <ctime>
#include <fstream>
#include <sstream>
Expand Down Expand Up @@ -87,7 +88,7 @@ static vm_oop_t sysLoad_(vm_oop_t /*unused*/, vm_oop_t rightObj) {
}

static vm_oop_t sysExit_(vm_oop_t /*unused*/, vm_oop_t err) {
long const err_no = INT_VAL(err);
int64_t const err_no = INT_VAL(err);
Quit(err_no);
}

Expand Down Expand Up @@ -124,7 +125,7 @@ static vm_oop_t sysTime(vm_oop_t /*unused*/) {

gettimeofday(&now, nullptr);

long long const diff =
int64_t const diff =
((now.tv_sec - start_time.tv_sec) * 1000) + // seconds
((now.tv_usec - start_time.tv_usec) / 1000); // useconds

Expand All @@ -136,7 +137,7 @@ static vm_oop_t sysTicks(vm_oop_t /*unused*/) {

gettimeofday(&now, nullptr);

long long const diff =
int64_t const diff =
((now.tv_sec - start_time.tv_sec) * 1000 * 1000) + // seconds
((now.tv_usec - start_time.tv_usec)); // useconds

Expand Down
2 changes: 1 addition & 1 deletion src/vm/Shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void Shell::Start() {
}
// the statement to evaluate
char inbuf[INPUT_MAX_SIZE];
long bytecodeIndex = 0, counter = 0;
size_t bytecodeIndex = 0, counter = 0;
VMFrame* currentFrame = nullptr;
VMClass* runClass = nullptr;
vm_oop_t it = load_ptr(nilObject); // last evaluation result.
Expand Down
31 changes: 15 additions & 16 deletions src/vm/Universe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ void Universe::Shutdown() {
#endif
}

vector<std::string> Universe::handleArguments(long argc, char** argv) {
vector<std::string> Universe::handleArguments(int32_t argc, char** argv) {
vector<std::string> vmArgs = vector<std::string>();
dumpBytecodes = 0;
gcVerbosity = 0;

for (long i = 1; i < argc; ++i) {
for (int32_t i = 1; i < argc; ++i) {
if (strncmp(argv[i], "-cp", 3) == 0) {
if ((argc == i + 1) || classPath.size() > 0) {
printUsageAndExit(argv[0]);
Expand All @@ -155,7 +155,7 @@ vector<std::string> Universe::handleArguments(long argc, char** argv) {
} else if (strncmp(argv[i], "-g", 2) == 0) {
++gcVerbosity;
} else if (strncmp(argv[i], "-H", 2) == 0) {
long heap_size = 0;
size_t heap_size = 0;
char unit[3];
if (sscanf(argv[i], "-H%ld%2s", &heap_size, unit) == 2) {
if (strcmp(unit, "KB") == 0) {
Expand All @@ -173,7 +173,7 @@ vector<std::string> Universe::handleArguments(long argc, char** argv) {
} else {
vector<std::string> extPathTokens = vector<std::string>(2);
std::string const tmpString = std::string(argv[i]);
if (getClassPathExt(extPathTokens, tmpString) == ERR_SUCCESS) {
if (getClassPathExt(extPathTokens, tmpString)) {
addClassPath(extPathTokens[0]);
}
// Different from CSOM!!!:
Expand All @@ -191,10 +191,10 @@ vector<std::string> Universe::handleArguments(long argc, char** argv) {
return vmArgs;
}

long Universe::getClassPathExt(vector<std::string>& tokens,
bool Universe::getClassPathExt(vector<std::string>& tokens,
const std::string& arg) {
#define EXT_TOKENS 2
long result = ERR_SUCCESS;
bool result = true;
size_t fpIndex = arg.find_last_of(fileSeparator);
size_t ssepIndex = arg.find(".som");

Expand All @@ -206,7 +206,7 @@ long Universe::getClassPathExt(vector<std::string>& tokens,
fpIndex = -1;
// instead of returning here directly, we have to remember that
// there is no new class path and return it later
result = ERR_FAIL;
result = false;
} else {
tokens[0] = arg.substr(0, fpIndex);
}
Expand All @@ -219,7 +219,7 @@ long Universe::getClassPathExt(vector<std::string>& tokens,
return result;
}

long Universe::setupClassPath(const std::string& cp) {
void Universe::setupClassPath(const std::string& cp) {
try {
std::stringstream ss(cp);
std::string token;
Expand All @@ -228,15 +228,14 @@ long Universe::setupClassPath(const std::string& cp) {
classPath.push_back(token);
}

return ERR_SUCCESS;
return;
} catch (std::exception e) {
return ERR_FAIL;
return;
}
}

long Universe::addClassPath(const std::string& cp) {
void Universe::addClassPath(const std::string& cp) {
classPath.push_back(cp);
return ERR_SUCCESS;
}

void Universe::printUsageAndExit(char* executable) {
Expand All @@ -259,7 +258,7 @@ void Universe::printUsageAndExit(char* executable) {
}

VMMethod* Universe::createBootstrapMethod(VMClass* holder,
long numArgsOfMsgSend) {
uint8_t numArgsOfMsgSend) {
vector<BackJump> inlinedLoops;
auto* bootStrapScope = new LexicalScope(nullptr, {}, {});
VMMethod* bootstrapMethod =
Expand Down Expand Up @@ -328,7 +327,7 @@ vm_oop_t Universe::interpretMethod(VMObject* receiver, VMInvokable* initialize,
return Interpreter::Start();
}

void Universe::initialize(long _argc, char** _argv) {
void Universe::initialize(int32_t _argc, char** _argv) {
InitializeAllocationLog();

heapSize = 1 * 1024 * 1024;
Expand Down Expand Up @@ -729,9 +728,9 @@ VMFrame* Universe::NewFrame(VMFrame* previousFrame, VMMethod* method) {
}

VMObject* Universe::NewInstance(VMClass* classOfInstance) {
long const numOfFields = classOfInstance->GetNumberOfInstanceFields();
size_t const numOfFields = classOfInstance->GetNumberOfInstanceFields();
// the additional space needed is calculated from the number of fields
long const additionalBytes = numOfFields * sizeof(VMObject*);
size_t const additionalBytes = numOfFields * sizeof(VMObject*);
auto* result = new (GetHeap<HEAP_CLS>(), additionalBytes)
VMObject(numOfFields, additionalBytes + sizeof(VMObject));
result->SetClass(classOfInstance);
Expand Down
12 changes: 6 additions & 6 deletions src/vm/Universe.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class Universe {
static vm_oop_t interpret(const std::string& className,
const std::string& methodName);

static long setupClassPath(const std::string& cp);
static void setupClassPath(const std::string& cp);

static void Assert(bool /*value*/);

Expand Down Expand Up @@ -123,17 +123,17 @@ class Universe {
static vm_oop_t interpretMethod(VMObject* receiver, VMInvokable* initialize,
VMArray* argumentsArray);

static vector<std::string> handleArguments(long argc, char** argv);
static long getClassPathExt(vector<std::string>& tokens,
static vector<std::string> handleArguments(int32_t argc, char** argv);
static bool getClassPathExt(vector<std::string>& tokens,
const std::string& arg);

static VMMethod* createBootstrapMethod(VMClass* holder,
long numArgsOfMsgSend);
uint8_t numArgsOfMsgSend);

static long addClassPath(const std::string& cp);
static void addClassPath(const std::string& cp);
static void printUsageAndExit(char* executable);

static void initialize(long /*_argc*/, char** /*_argv*/);
static void initialize(int32_t _argc, char** _argv);

static size_t heapSize;
static map<GCSymbol*, gc_oop_t> globals;
Expand Down
4 changes: 2 additions & 2 deletions src/vmobjects/VMClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ size_t VMClass::GetNumberOfInstanceFields() const {
}

bool VMClass::HasPrimitives() const {
long const numInvokables = GetNumberOfInstanceInvokables();
for (long i = 0; i < numInvokables; ++i) {
size_t const numInvokables = GetNumberOfInstanceInvokables();
for (size_t i = 0; i < numInvokables; ++i) {
VMInvokable* invokable = GetInstanceInvokable(i);
if (invokable->IsPrimitive()) {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/vmobjects/VMEvaluationPrimitive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ std::string VMEvaluationPrimitive::AsDebugString() const {
return "VMEvaluationPrimitive(" + to_string(numberOfArguments) + ")";
}

#define INVALID_INT_MARKER 9002002002002002002
#define INVALID_INT_MARKER 0xFF

void VMEvaluationPrimitive::MarkObjectAsInvalid() {
VMInvokable::MarkObjectAsInvalid();
Expand Down

0 comments on commit 6e7d9b3

Please sign in to comment.