peon/src/peon/stdlib/arithmetics.pn

208 lines
3.3 KiB
Plaintext

## Builtin arithmetic operators for Peon
# Note: These do nothing on their own. All they do
# is serve as placeholders for emitting specific VM
# instructions. They're implemented this way because:
# - They tie into the existing type system nicely
# - It makes the implementation easier and more flexible
operator `+`(a, b: int): int {
#pragma[magic: "AddInt64", pure]
}
operator `+`(a, b: uint64): uint64 {
#pragma[magic: "AddUInt64", pure]
}
operator `+`(a, b: int32): int32 {
#pragma[magic: "AddInt32", pure]
}
operator `+`(a, b: uint32): uint32 {
#pragma[magic: "AddUInt32", pure]
}
operator `+`(a, b: int16): int16 {
#pragma[magic: "AddInt16", pure]
}
operator `+`(a, b: uint16): uint16 {
#pragma[magic: "AddUInt16", pure]
}
operator `+`(a, b: int8): int8 {
#pragma[magic: "AddInt8", pure]
}
operator `+`(a, b: uint8): uint8 {
#pragma[magic: "AddUInt8", pure]
}
operator `+`(a, b: float64): float64 {
#pragma[magic: "AddFloat64", pure]
}
operator `+`(a, b: float32): float32 {
#pragma[magic: "AddFloat32", pure]
}
operator `-`(a, b: int): int {
#pragma[magic: "SubInt64", pure]
}
operator `-`(a, b: uint64): uint64 {
#pragma[magic: "SubUInt64", pure]
}
operator `-`(a, b: int32): int32 {
#pragma[magic: "SubInt32", pure]
}
operator `-`(a, b: uint32): uint32 {
#pragma[magic: "SubUInt32", pure]
}
operator `-`(a, b: int16): int16 {
#pragma[magic: "SubInt16", pure]
}
operator `-`(a, b: uint16): uint16 {
#pragma[magic: "SubUInt16", pure]
}
operator `-`(a, b: int8): int8 {
#pragma[magic: "SubInt8", pure]
}
operator `-`(a, b: uint8): uint8 {
#pragma[magic: "SubUInt8", pure]
}
operator `-`(a, b: float64): float64 {
#pragma[magic: "SubFloat64", pure]
}
operator `-`(a, b: float32): float32 {
#pragma[magic: "SubFloat32", pure]
}
operator `*`(a, b: int): int {
#pragma[magic: "MulInt64", pure]
}
operator `*`(a, b: uint64): uint64 {
#pragma[magic: "MulUInt64", pure]
}
operator `*`(a, b: int32): int32 {
#pragma[magic: "MulInt32", pure]
}
operator `*`(a, b: uint32): uint32 {
#pragma[magic: "MulUInt32", pure]
}
operator `*`(a, b: int16): int16 {
#pragma[magic: "MulInt16", pure]
}
operator `*`(a, b: uint16): uint16 {
#pragma[magic: "MulUInt16", pure]
}
operator `*`(a, b: int8): int8 {
#pragma[magic: "MulInt8", pure]
}
operator `*`(a, b: uint8): uint8 {
#pragma[magic: "MulUInt8", pure]
}
operator `*`(a, b: float64): float64 {
#pragma[magic: "MulFloat64", pure]
}
operator `*`(a, b: float32): float32 {
#pragma[magic: "MulFloat32", pure]
}
operator `/`(a, b: int): int {
#pragma[magic: "DivInt64", pure]
}
operator `/`(a, b: uint64): uint64 {
#pragma[magic: "DivUInt64", pure]
}
operator `/`(a, b: int32): int32 {
#pragma[magic: "DivInt32", pure]
}
operator `/`(a, b: uint32): uint32 {
#pragma[magic: "DivUInt32", pure]
}
operator `/`(a, b: int16): int16 {
#pragma[magic: "DivInt16", pure]
}
operator `/`(a, b: uint16): uint16 {
#pragma[magic: "DivUInt16", pure]
}
operator `/`(a, b: int8): int8 {
#pragma[magic: "DivInt8", pure]
}
operator `/`(a, b: uint8): uint8 {
#pragma[magic: "DivUInt8", pure]
}
operator `/`(a, b: float64): float64 {
#pragma[magic: "DivFloat64", pure]
}
operator `/`(a, b: float32): float32 {
#pragma[magic: "DivFloat32", pure]
}