More Value ops
This commit is contained in:
parent
e2a487a59b
commit
1aa4e6ced2
@ -142,6 +142,10 @@ impl Display for Value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Value {
|
impl Value {
|
||||||
|
pub fn is_null(&self) -> bool {
|
||||||
|
self == &Value::Null
|
||||||
|
}
|
||||||
|
|
||||||
pub fn is_true(&self) -> bool {
|
pub fn is_true(&self) -> bool {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
@ -174,6 +178,7 @@ impl Value {
|
|||||||
TokenKind::Symbol(Symbol::CloseParen) => Some(left),
|
TokenKind::Symbol(Symbol::CloseParen) => Some(left),
|
||||||
TokenKind::Symbol(Symbol::Plus)
|
TokenKind::Symbol(Symbol::Plus)
|
||||||
| TokenKind::Symbol(Symbol::Minus)
|
| TokenKind::Symbol(Symbol::Minus)
|
||||||
|
| TokenKind::Op(_)
|
||||||
| TokenKind::Symbol(Symbol::Mul)
|
| TokenKind::Symbol(Symbol::Mul)
|
||||||
| TokenKind::Symbol(Symbol::Div)
|
| TokenKind::Symbol(Symbol::Div)
|
||||||
| TokenKind::Symbol(Symbol::Percent) => {
|
| TokenKind::Symbol(Symbol::Percent) => {
|
||||||
@ -183,6 +188,7 @@ impl Value {
|
|||||||
TokenKind::Symbol(Symbol::Mul) => Op::Mul,
|
TokenKind::Symbol(Symbol::Mul) => Op::Mul,
|
||||||
TokenKind::Symbol(Symbol::Div) => Op::Div,
|
TokenKind::Symbol(Symbol::Div) => Op::Div,
|
||||||
TokenKind::Symbol(Symbol::Percent) => Op::Rem,
|
TokenKind::Symbol(Symbol::Percent) => Op::Rem,
|
||||||
|
TokenKind::Op(op) => op,
|
||||||
_ => unsafe { std::hint::unreachable_unchecked() },
|
_ => unsafe { std::hint::unreachable_unchecked() },
|
||||||
};
|
};
|
||||||
toks.next();
|
toks.next();
|
||||||
@ -279,7 +285,7 @@ impl Value {
|
|||||||
let func = match scope.functions.get(&s) {
|
let func = match scope.functions.get(&s) {
|
||||||
Some(f) => f,
|
Some(f) => f,
|
||||||
None => match GLOBAL_FUNCTIONS.get(&s) {
|
None => match GLOBAL_FUNCTIONS.get(&s) {
|
||||||
Some(f) => return Some(f(&args)),
|
Some(f) => return f(&args),
|
||||||
None => todo!("called undefined function"),
|
None => todo!("called undefined function"),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user