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

Method construct

examples/parametrized_function.rs:102–116  ·  view source on GitHub ↗
(&self, children: &[Self::Type], _ctx: &mut Self::Context)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected