piccolo/
raw_ops.rs

1use crate::Value;
2
3// TODO: This module should be entirely replaced by `meta_ops` as they are added.
4
5pub fn add<'gc>(lhs: Value<'gc>, rhs: Value<'gc>) -> Option<Value<'gc>> {
6    Some(lhs.to_constant()?.add(&rhs.to_constant()?)?.into())
7}
8
9pub fn subtract<'gc>(lhs: Value<'gc>, rhs: Value<'gc>) -> Option<Value<'gc>> {
10    Some(lhs.to_constant()?.subtract(&rhs.to_constant()?)?.into())
11}
12
13pub fn multiply<'gc>(lhs: Value<'gc>, rhs: Value<'gc>) -> Option<Value<'gc>> {
14    Some(lhs.to_constant()?.multiply(&rhs.to_constant()?)?.into())
15}
16
17pub fn float_divide<'gc>(lhs: Value<'gc>, rhs: Value<'gc>) -> Option<Value<'gc>> {
18    Some(lhs.to_constant()?.float_divide(&rhs.to_constant()?)?.into())
19}
20
21pub fn floor_divide<'gc>(lhs: Value<'gc>, rhs: Value<'gc>) -> Option<Value<'gc>> {
22    Some(lhs.to_constant()?.floor_divide(&rhs.to_constant()?)?.into())
23}
24
25pub fn modulo<'gc>(lhs: Value<'gc>, rhs: Value<'gc>) -> Option<Value<'gc>> {
26    Some(lhs.to_constant()?.modulo(&rhs.to_constant()?)?.into())
27}
28
29pub fn exponentiate<'gc>(lhs: Value<'gc>, rhs: Value<'gc>) -> Option<Value<'gc>> {
30    Some(lhs.to_constant()?.exponentiate(&rhs.to_constant()?)?.into())
31}
32
33pub fn negate<'gc>(lhs: Value<'gc>) -> Option<Value<'gc>> {
34    Some(lhs.to_constant()?.negate()?.into())
35}
36
37pub fn bitwise_not<'gc>(v: Value<'gc>) -> Option<Value<'gc>> {
38    Some(v.to_constant()?.bitwise_not()?.into())
39}
40
41pub fn bitwise_and<'gc>(lhs: Value<'gc>, rhs: Value<'gc>) -> Option<Value<'gc>> {
42    Some(lhs.to_constant()?.bitwise_and(&rhs.to_constant()?)?.into())
43}
44
45pub fn bitwise_or<'gc>(lhs: Value<'gc>, rhs: Value<'gc>) -> Option<Value<'gc>> {
46    Some(lhs.to_constant()?.bitwise_or(&rhs.to_constant()?)?.into())
47}
48
49pub fn bitwise_xor<'gc>(lhs: Value<'gc>, rhs: Value<'gc>) -> Option<Value<'gc>> {
50    Some(lhs.to_constant()?.bitwise_xor(&rhs.to_constant()?)?.into())
51}
52
53pub fn shift_left<'gc>(lhs: Value<'gc>, rhs: Value<'gc>) -> Option<Value<'gc>> {
54    Some(lhs.to_constant()?.shift_left(&rhs.to_constant()?)?.into())
55}
56
57pub fn shift_right<'gc>(lhs: Value<'gc>, rhs: Value<'gc>) -> Option<Value<'gc>> {
58    Some(lhs.to_constant()?.shift_right(&rhs.to_constant()?)?.into())
59}
60
61pub fn less_than<'gc>(lhs: Value<'gc>, rhs: Value<'gc>) -> Option<bool> {
62    Some(lhs.to_constant()?.less_than(&rhs.to_constant()?)?.into())
63}
64
65pub fn less_equal<'gc>(lhs: Value<'gc>, rhs: Value<'gc>) -> Option<bool> {
66    Some(lhs.to_constant()?.less_equal(&rhs.to_constant()?)?.into())
67}