Permalink
Browse files

Initial commit. Adds basic types

  • Loading branch information...
0x7CFE committed Nov 18, 2012
0 parents commit b49eaeec38a50e59efd29bb9e2f373383e552733
Showing with 102 additions and 0 deletions.
  1. +12 −0 .kdev4/llst.kdev4
  2. +7 −0 CMakeLists.txt
  3. +1 −0 include/CMakeLists.txt
  4. +71 −0 include/vm.h
  5. +4 −0 llst.kdev4
  6. +1 −0 src/CMakeLists.txt
  7. +6 −0 src/main.cpp
@@ -0,0 +1,12 @@
[Buildset]
BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x08\x00l\x00l\x00s\x00t)
[CMake]
BuildDirs=/home/korvin/projects/smalltalk/llst/build
CMakeDir=/usr/share/cmake-2.8/Modules
Current CMake Binary=file:///usr/bin/cmake
CurrentBuildDir=file:///home/korvin/projects/smalltalk/llst/build
CurrentBuildType=Debug
CurrentInstallDir=
Extra Arguments=
ProjectRootRelative=./
@@ -0,0 +1,7 @@
project(llst)
add_executable(llst src/main.cpp)
add_subdirectory(src)
add_subdirectory(include)
@@ -0,0 +1 @@
@@ -0,0 +1,71 @@
#include <sys/types.h>
// typedef uint32_t llstUInt;
// typedef int32_t llstInt;
// typedef int64_t llstInt64;
struct TSize {
private:
uint32_t data;
const int FLAG_RELOCATED = 1;
const int FLAG_BINARY = 2;
const int FLAGS_MASK = FLAG_RELOCATED | FLAG_BINARY;
public:
TSize(uint32_t size, bool isBinary = false, bool isRelocated = false)
{
data = size & ~FLAGS_MASK; // masking lowest two bits
data |= (isBinary << 1);
data |= isRelocated;
}
TSize(const TSize& size) : data(size.data) {}
uint32_t getSize() const { return data & FLAGS_MASK; }
bool isBinary() const { return data & FLAG_BINARY; }
bool isRelocated() const { return data & FLAG_RELOCATED; }
void setBinary(bool value) { data &= (value << 1); }
void setRelocated(bool value) { data &= value; }
};
struct TObject {
private:
TSize size;
TObject* klass;
TObject* data[0];
public:
TObject(uint32_t size, const TObject* klass, bool isBinary = false)
: size(size), klass(klass)
{
size.setBinary(isBinary);
}
uint32_t getSize() const { return size.getSize(); }
TObject* getClass() const { return klass; }
// delegated methods from TSize
bool isBinary() const { size.isBinary(); }
bool isRelocated() const { return size.isRelocated(); }
// void setBinary(bool value) { size.setBinary(value); }
void setRelocated(bool value) { size.setRelocated(value); }
// TODO boundary checks
TObject* getData(uint32_t index) const { return data[index]; }
TObject* operator [] (uint32_t index) const { return getData(index); }
void putData(uint32_t index, TObject* value) { data[index] = value; }
void operator [] (uint32_t index, TObject* value) { return putData(index, value); }
};
struct TByteObject : public TObject {
public:
// TODO boundary checks
TByteObject(uint32_t size, const TObject* klass) : TObject(size, klass, true) { }
uint8_t getByte(uint32_t index) { return reinterpret_cast<uint8_t*>(data)[index]; }
uint8_t operator [] (uint32_t index) const { return getByte(index); }
void putByte(uint32_t index, uint8_t value) { reinterpret_cast<uint8_t*>(data)[index] = value; }
uint8_t operator [] (uint32_t index) { return getByte(index); }
};
@@ -0,0 +1,4 @@
[Project]
Name=llst
Manager=KDevCMakeManager
VersionControl=
@@ -0,0 +1 @@
@@ -0,0 +1,6 @@
#include <iostream>
int main(int argc, char **argv) {
std::cout << "Hello, world!" << std::endl;
return 0;
}

0 comments on commit b49eaee

Please sign in to comment.