| 101 | type Type = Type; |
| 102 | |
| 103 | fn construct(&self, children: &[Self::Type], _ctx: &mut Self::Context) -> Result<Self::Type, Self::Err> { |
| 104 | assert!(children.is_empty(), "spurious children"); |
| 105 | use Variant::*; |
| 106 | match self { |
| 107 | Any => Err("Cannot reify `Any`.".to_string()), |
| 108 | Integer(w) if *w <= 128 => Ok(Type::Int128), |
| 109 | Integer(w) => Err(format!("Integer too wide, {}-bit not supported.", w)), |
| 110 | Fixed(i, f) if *i <= 64 && *f <= 64 => Ok(Type::FixedPointI64F64), |
| 111 | Fixed(i, f) => Err(format!("Fixed point number too wide, I{}F{} not supported.", i, f)), |
| 112 | Numeric => { |
| 113 | Err("Cannot reify a numeric value. Either define a default (int/fixed) or restrict type.".to_string()) |
| 114 | } |
| 115 | Bool => Ok(Type::Bool), |
| 116 | } |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | fn build_type_error() -> Expression { |