From 6e92b03f815b2dcd1164850bd8afdfb30d9bb2e9 Mon Sep 17 00:00:00 2001 From: greg Date: Tue, 13 Aug 2019 04:28:21 -0700 Subject: [PATCH] Add types for (some) builtins --- schala-lang/language/src/builtin.rs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/schala-lang/language/src/builtin.rs b/schala-lang/language/src/builtin.rs index f44848f..2d8c080 100644 --- a/schala-lang/language/src/builtin.rs +++ b/schala-lang/language/src/builtin.rs @@ -35,7 +35,33 @@ pub enum Builtin { impl Builtin { pub fn get_type(&self) -> Type { - ty!(Nat -> Nat -> Nat) + use Builtin::*; + match self { + Add => ty!(Nat -> Nat -> Nat), + Subtract => ty!(Nat -> Nat -> Nat), + Multiply => ty!(Nat -> Nat -> Nat), + Divide => ty!(Nat -> Nat -> Float), + Quotient => ty!(Nat -> Nat -> Nat), + Modulo => ty!(Nat -> Nat -> Nat), + Exponentiation => ty!(Nat -> Nat -> Nat), + BitwiseAnd => ty!(Nat -> Nat -> Nat), + BitwiseOr => ty!(Nat -> Nat -> Nat), + BooleanAnd => ty!(Bool -> Bool -> Bool), + BooleanOr => ty!(Bool -> Bool -> Bool), + BooleanNot => ty!(Bool -> Bool), + Equality => ty!(Nat -> Nat -> Bool), + LessThan => ty!(Nat -> Nat -> Bool), + LessThanOrEqual => ty!(Nat -> Nat -> Bool), + GreaterThan => ty!(Nat -> Nat -> Bool), + GreaterThanOrEqual => ty!(Nat -> Nat -> Bool), + Comparison => ty!(Nat -> Nat -> Ordering), + FieldAccess => ty!(Unit), + IOPrint => ty!(Unit), + IOPrintLn => ty!(Unit) , + IOGetLine => ty!(StringT), + Assignment => ty!(Unit), + Concatenate => ty!(StringT -> StringT -> StringT), + } } }