interpreter: shrink integers to pointer-size in temp type implementation, for speed

This commit is contained in:
John 2024-02-26 15:32:49 -06:00
parent 59b73f314a
commit 1bfeeb1755

View File

@ -27,6 +27,9 @@ pub mod temp_type_impl {
BuiltIn, Callable, Environment, BuiltIn, Callable, Environment,
}; };
use std::ops::*; use std::ops::*;
type Integer = isize;
/// A Conlang value /// A Conlang value
/// ///
/// This is a hack to work around the fact that Conlang doesn't /// This is a hack to work around the fact that Conlang doesn't
@ -37,7 +40,7 @@ pub mod temp_type_impl {
#[default] #[default]
Empty, Empty,
/// An integer /// An integer
Int(i128), Int(Integer),
/// A boolean /// A boolean
Bool(bool), Bool(bool),
/// A unicode character /// A unicode character
@ -49,9 +52,9 @@ pub mod temp_type_impl {
/// A tuple /// A tuple
Tuple(Vec<ConValue>), Tuple(Vec<ConValue>),
/// An exclusive range /// An exclusive range
RangeExc(i128, i128), RangeExc(Integer, Integer),
/// An inclusive range /// An inclusive range
RangeInc(i128, i128), RangeInc(Integer, Integer),
/// A callable thing /// A callable thing
Function(Function), Function(Function),
/// A built-in function /// A built-in function
@ -154,7 +157,7 @@ pub mod temp_type_impl {
})* })*
} }
from! { from! {
i128 => ConValue::Int, Integer => ConValue::Int,
bool => ConValue::Bool, bool => ConValue::Bool,
char => ConValue::Char, char => ConValue::Char,
&str => ConValue::String, &str => ConValue::String,