MCPcopy Create free account
hub / github.com/Schwenger/RustTyC / construct

Method construct

src/tests.rs:103–117  ·  view source on GitHub ↗
(&self, children: &[Self::Type], _ctx: &mut Self::Context)

Source from the content-addressed store, hash-verified

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
120fn build_type_error() -> Expression {

Callers 1

construct_typesMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected