diff options
Merge branch 'feature/32bit' into master
4 files changed, 20 insertions, 21 deletions
| -rw-r--r-- | spasm/src/asm/lexer.cpp | 4 | ||||
| -rw-r--r-- | spasm/src/asm/lexer.re | 4 | ||||
| -rw-r--r-- | spasm/src/spasm.cpp | 8 | ||||
| -rw-r--r-- | spasm/src/value.hpp | 25 |
diff --git a/spasm/src/asm/lexer.cpp b/spasm/src/asm/lexer.cpp index 996762c..fd522ee 100644 --- a/spasm/src/asm/lexer.cpp +++ b/spasm/src/asm/lexer.cpp @@ -3082,7 +3082,7 @@ void Lexer::read(size_t nbytes) file->read(old_limit, limit - old_limit); if (file->eof()) { - size_t bytes = file->gcount(); + auto bytes = file->gcount(); std::fill(old_limit + bytes, limit, '\0'); } } @@ -3092,7 +3092,7 @@ void Lexer::buffer_init() file->read(buffer, buffer_size); if (file->eof()) { - size_t bytes = file->gcount(); + auto bytes = file->gcount(); std::fill(buffer + bytes, buffer + buffer_size, '\0'); } diff --git a/spasm/src/asm/lexer.re b/spasm/src/asm/lexer.re index bdf792d..7de620d 100644 --- a/spasm/src/asm/lexer.re +++ b/spasm/src/asm/lexer.re @@ -339,7 +339,7 @@ void Lexer::read (size_t nbytes) file->read (old_limit, limit - old_limit); if (file->eof ()) { - size_t bytes = file->gcount (); + auto bytes = file->gcount (); std::fill (old_limit + bytes, limit, '\0'); } } @@ -348,7 +348,7 @@ void Lexer::buffer_init () { file->read (buffer, buffer_size); if (file->eof ()) { - size_t bytes = file->gcount (); + auto bytes = file->gcount (); std::fill (buffer + bytes, buffer + buffer_size, '\0'); } diff --git a/spasm/src/spasm.cpp b/spasm/src/spasm.cpp index 6a62c90..94086a6 100644 --- a/spasm/src/spasm.cpp +++ b/spasm/src/spasm.cpp @@ -331,7 +331,7 @@ void Spasm::gotrue(reg_t a0, reg_t a1) { if (get_local(a0)) { - m_PC = a1; + go(a1); } } @@ -344,7 +344,7 @@ void Spasm::gofalse(reg_t a0, reg_t a1) { if (!get_local(a0)) { - m_PC = a1; + go(a1); } } @@ -354,7 +354,7 @@ void Spasm::gofalse(reg_t a0, reg_t a1) */ void Spasm::go(reg_t a0) { - m_PC = a0; + m_PC = PC_t(a0); } /*! @@ -507,7 +507,7 @@ int64_t Spasm::read_integer(size_t size) data_t Spasm::read_string(size_t size) { - const auto length = read_integer(size); + const auto length = size_t(read_integer(size)); const auto s = reinterpret_cast<const char*>(&m_ByteCode[m_PC]); m_PC += length; const auto value = m_Strings.Get(s, length); diff --git a/spasm/src/value.hpp b/spasm/src/value.hpp index d86c0ef..725d48c 100644 --- a/spasm/src/value.hpp +++ b/spasm/src/value.hpp @@ -25,39 +25,38 @@ struct Value explicit Value(double v) { m_value.as_double = v; } - explicit Value(bool v) : Value(ValueType::Boolean, (size_t)v) {} + explicit Value(bool v) : Value(ValueType::Boolean, (uint64_t)v) {} - Value(ValueType tag, size_t payload) + Value(ValueType tag, uint64_t payload) { assert(tag != ValueType::Number && "Zero tag is plain double"); assert(!(payload >> 48) && "Use only pointers to the heap."); m_value.as_pointer.pointer = payload; - m_value.as_pointer.tag = size_t(tag); + m_value.as_pointer.tag = uint64_t(tag); m_value.as_pointer.nan = 0x1fff; } - Value(ValueType tag, void* pointer) : Value(tag, (size_t)pointer) {} + Value(ValueType tag, void* pointer) : Value(tag, (uint64_t)pointer) {} struct NanPointer { - size_t pointer : 48; - size_t tag : 3; - size_t nan : 13; + uint64_t pointer : 48; + uint64_t tag : 3; + uint64_t nan : 13; }; struct CheckType { - size_t payload : 48; - size_t check : 16; + uint64_t payload : 48; + uint64_t check : 16; }; union { double as_double; NanPointer as_pointer; CheckType to_check; - size_t as_int64; + uint64_t as_int64; } m_value; - static_assert(sizeof(size_t) == 8, "unsupported arch"); static_assert(sizeof(double) == 8, "unsupported arch"); bool is_double() const { return m_value.to_check.check <= 0xFFF8; } @@ -76,7 +75,7 @@ struct Value void* get_pointer() const { - return (void*)(size_t)m_value.as_pointer.pointer; + return (void*)(uint64_t)m_value.as_pointer.pointer; } bool get_boolean() const @@ -173,4 +172,4 @@ inline Value operator!=(const Value& lhs, const Value& rhs) return Value(lhs.get_double() != rhs.get_double()); } -} // namespace Spasm
\ No newline at end of file +} // namespace Spasm |
