aboutsummaryrefslogtreecommitdiffstats
path: root/parser.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2023-02-26 19:31:00 -0500
committerClyne Sullivan <clyne@bitgloo.com>2023-02-26 19:31:00 -0500
commitc5db61d59fd75b786bd3e5a57a163d37df20a8b9 (patch)
tree74d00b7f264c9f9ef287a36f602cf8ce06450ea3 /parser.cpp
parent42d64c6da242bd100533ab0c31c3835b50fa1b2d (diff)
packed literals; faster execution
Diffstat (limited to 'parser.cpp')
-rw-r--r--parser.cpp13
1 files changed, 10 insertions, 3 deletions
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);
}