From c5db61d59fd75b786bd3e5a57a163d37df20a8b9 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Sun, 26 Feb 2023 19:31:00 -0500 Subject: packed literals; faster execution --- parser.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'parser.cpp') diff --git a/parser.cpp b/parser.cpp index 91c4e5c..7335f90 100644 --- a/parser.cpp +++ b/parser.cpp @@ -62,8 +62,9 @@ int Parser::parseWord(State& state, Word word) if (ins < 0) { return parseNumber(state, word); } else { - imm = ins & CoreWords::Immediate; + imm = ins == CoreWords::Semicolon; ins &= ~CoreWords::Immediate; + ins = (ins << 1) | 1; } } else { imm = state.dict.read(ins) & CoreWords::Immediate; @@ -97,8 +98,14 @@ int Parser::parseNumber(State& state, Word word) if (ec == std::errc() && ptr == buf + i) { if (state.compiling()) { - state.dict.add(CoreWords::findi("_lit")); - state.dict.add(l); + auto ins = (CoreWords::findi("_lit") << 1) | 1; + + if (l >= 0 && l < 0xFF) { + state.dict.add(ins | ((l + 1) << 8)); + } else { + state.dict.add(ins); + state.dict.add(l); + } } else { state.push(l); } -- cgit v1.2.3