mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-01-13 15:38:06 -05:00
Scaffolding for operations
This commit is contained in:
@@ -27,22 +27,18 @@ pub fn op_div(left: Val, right: Val) -> Val {
|
||||
return Val::Number(left.to_number() / right.to_number());
|
||||
}
|
||||
|
||||
pub fn op_exp(left: Val, right: Val) -> Val {
|
||||
return Val::Number(left.to_number().powf(right.to_number()));
|
||||
}
|
||||
|
||||
pub fn op_mod(left: Val, right: Val) -> Val {
|
||||
return Val::Number(left.to_number() % right.to_number());
|
||||
}
|
||||
|
||||
pub fn op_less(left: Val, right: Val) -> Val {
|
||||
if left.typeof_() != VsType::Number || right.typeof_() != VsType::Number {
|
||||
std::panic!("Not implemented");
|
||||
}
|
||||
|
||||
return Val::Bool(left.to_number() < right.to_number());
|
||||
pub fn op_exp(left: Val, right: Val) -> Val {
|
||||
return Val::Number(left.to_number().powf(right.to_number()));
|
||||
}
|
||||
|
||||
// OpEq = 0x0a,
|
||||
// OpNe = 0x0b,
|
||||
// OpTripleEq = 0x0c,
|
||||
|
||||
pub fn op_triple_ne(left: Val, right: Val) -> Val {
|
||||
if left.typeof_() != VsType::Number || right.typeof_() != VsType::Number {
|
||||
std::panic!("Not implemented");
|
||||
@@ -66,3 +62,30 @@ pub fn op_or(left: Val, right: Val) -> Val {
|
||||
right
|
||||
};
|
||||
}
|
||||
|
||||
// OpNot = 0x10,
|
||||
|
||||
pub fn op_less(left: Val, right: Val) -> Val {
|
||||
if left.typeof_() != VsType::Number || right.typeof_() != VsType::Number {
|
||||
std::panic!("Not implemented");
|
||||
}
|
||||
|
||||
return Val::Bool(left.to_number() < right.to_number());
|
||||
}
|
||||
|
||||
// OpLessEq = 0x12,
|
||||
// OpGreater = 0x13,
|
||||
// OpGreaterEq = 0x14,
|
||||
// OpNullishCoalesce = 0x15,
|
||||
// OpOptionalChain = 0x16,
|
||||
// OpBitAnd = 0x17,
|
||||
// OpBitOr = 0x18,
|
||||
// OpBitNot = 0x19,
|
||||
// OpBitXor = 0x1a,
|
||||
// OpLeftShift = 0x1b,
|
||||
// OpRightShift = 0x1c,
|
||||
// OpRightShiftUnsigned = 0x1d,
|
||||
// TypeOf = 0x1e,
|
||||
// InstanceOf = 0x1f,
|
||||
// In = 0x20,
|
||||
// Sub = 0x24,
|
||||
|
||||
Reference in New Issue
Block a user