pub fn property_from_field(
    pos: &Position,
    field: &field::Field,
    class: &DirectName,
    env: &Environment,
    constr: &mut ConstrBuilder
) -> Constrained {
    // TODO generate constraints are part of interface
    // TODO add constraint for mutable field
    let node = Node::PropertyCall {
        instance: Box::new(AST { pos: pos.clone(), node: Node::_Self }),
        property: Box::new(AST { pos: pos.clone(), node: Node::Id { lit: field.name.clone() } })
    };
    let property_call = Expected::try_from(&AST::new(&pos, node))?;
    let field_ty = Expected::new(&pos, &Type { name: field.ty.clone() });

    let env = env.insert_var(field.mutable, &field.name, &field_ty);
    constr.add("field property", &field_ty, &property_call);

    let access = Expected::new(&pos, &Access {
        entity: Box::new(Expected::new(&pos, &Type { name: NameUnion::from(class) })),
        name:   Box::new(Expected::new(&pos, &Field { name: field.name.clone() }))
    });

    constr.add("field property", &property_call, &access);
    Ok((constr.clone(), env))
}
/// Generate constraint for a given field.
Generate constraint for a given field.
Generate constraint for a given field .
pub fn property_from_field(
    pos: &Position,
    field: &field::Field,
    class: &DirectName,
    env: &Environment,
    constr: &mut ConstrBuilder
) -> Constrained {
    // TODO generate constraints are part of interface
    // TODO add constraint for mutable field
    let node = Node::PropertyCall {
        instance: Box::new(AST { pos: pos.clone(), node: Node::_Self }),
        property: Box::new(AST { pos: pos.clone(), node: Node::Id { lit: field.name.clone() } })
    };
    let property_call = Expected::try_from(&AST::new(&pos, node))?;
    let field_ty = Expected::new(&pos, &Type { name: field.ty.clone() });
    let env = env.insert_var(field.mutable, &field.name, &field_ty);
    constr.add("field property", &field_ty, &property_call);
    let access = Expected::new(&pos, &Access {
        entity: Box::new(Expected::new(&pos, &Type { name: NameUnion::from(class) })),
        name:   Box::new(Expected::new(&pos, &Field { name: field.name.clone() }))
    });
    constr.add("field property", &property_call, &access);
    Ok((constr.clone(), env))
}
pub fn property_from_field ( pos : & Position , field : & field :: Field , class : & DirectName , env : & Environment , constr : & mut ConstrBuilder ) -> Constrained { // TODO generate constraints are part of interface // TODO add constraint for mutable field let node = Node :: PropertyCall { instance : Box :: new ( AST { pos : pos . clone ( ) , node : Node :: _Self } ) , property : Box :: new ( AST { pos : pos . clone ( ) , node : Node :: Id { lit : field . name . clone ( ) } } ) } ; let property_call = Expected :: try_from ( & AST :: new ( & pos , node ) ) ? ; let field_ty = Expected :: new ( & pos , & Type { name : field . ty . clone ( ) } ) ; let env = env . insert_var ( field . mutable , & field . name , & field_ty ) ; constr . add ( " " , & field_ty , & property_call ) ; let access = Expected :: new ( & pos , & Access { entity : Box :: new ( Expected :: new ( & pos , & Type { name : NameUnion :: from ( class ) } ) ) , name : Box :: new ( Expected :: new ( & pos , & Field { name : field . name . clone ( ) } ) ) } ) ; constr . add ( " " , & property_call , & access ) ; Ok ( ( constr . clone ( ) , env ) ) }
Generate constraint for a given field.
Generate constraint for a given field .
pos
&Position
field
&field::Field
class
&DirectName
env
&Environment
constr
&mut ConstrBuilder