Some type renaming in builtins
Builtins will remain entirely separate from the actual type representation, whatever that ends up being
This commit is contained in:
parent
2c298c7247
commit
1d5e5aa735
@ -3,18 +3,18 @@ use std::collections::HashMap;
|
|||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use tokenizing::TokenType;
|
use tokenizing::TokenType;
|
||||||
use self::Type::*; use self::TConstOld::*;
|
use self::BuiltinTypeSpecifier::*;
|
||||||
|
use self::BuiltinTConst::*;
|
||||||
|
|
||||||
|
|
||||||
//TODO get rid of these types and replace them with the right MonoType or whatever ones later
|
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
pub enum Type {
|
pub enum BuiltinTypeSpecifier {
|
||||||
Const(TConstOld),
|
Const(BuiltinTConst),
|
||||||
Func(Box<Type>, Box<Type>),
|
Func(Box<BuiltinTypeSpecifier>, Box<BuiltinTypeSpecifier>),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
pub enum TConstOld {
|
pub enum BuiltinTConst {
|
||||||
Nat,
|
Nat,
|
||||||
Int,
|
Int,
|
||||||
Float,
|
Float,
|
||||||
@ -22,7 +22,7 @@ pub enum TConstOld {
|
|||||||
Bool,
|
Bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for Type {
|
impl fmt::Display for BuiltinTypeSpecifier {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(f, "{:?}", self)
|
write!(f, "{:?}", self)
|
||||||
}
|
}
|
||||||
@ -104,7 +104,7 @@ impl PrefixOp {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref PREFIX_OPS: HashMap<&'static str, (Type, ())> =
|
static ref PREFIX_OPS: HashMap<&'static str, (BuiltinTypeSpecifier, ())> =
|
||||||
hashmap! {
|
hashmap! {
|
||||||
"+" => (Func(bx!(Const(Int)), bx!(Const(Int))), ()),
|
"+" => (Func(bx!(Const(Int)), bx!(Const(Int))), ()),
|
||||||
"-" => (Func(bx!(Const(Int)), bx!(Const(Int))), ()),
|
"-" => (Func(bx!(Const(Int)), bx!(Const(Int))), ()),
|
||||||
@ -115,7 +115,7 @@ lazy_static! {
|
|||||||
/* the second tuple member is a placeholder for when I want to make evaluation rules tied to the
|
/* the second tuple member is a placeholder for when I want to make evaluation rules tied to the
|
||||||
* binop definition */
|
* binop definition */
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref BINOPS: HashMap<&'static str, (Type, (), i32)> =
|
static ref BINOPS: HashMap<&'static str, (BuiltinTypeSpecifier, (), i32)> =
|
||||||
hashmap! {
|
hashmap! {
|
||||||
"+" => (Func(bx!(Const(Nat)), bx!(Func(bx!(Const(Nat)), bx!(Const(Nat))))), (), 10),
|
"+" => (Func(bx!(Const(Nat)), bx!(Func(bx!(Const(Nat)), bx!(Const(Nat))))), (), 10),
|
||||||
"-" => (Func(bx!(Const(Nat)), bx!(Func(bx!(Const(Nat)), bx!(Const(Nat))))), (), 10),
|
"-" => (Func(bx!(Const(Nat)), bx!(Func(bx!(Const(Nat)), bx!(Const(Nat))))), (), 10),
|
||||||
|
Loading…
Reference in New Issue
Block a user