Start to get rid of Meta
This commit is contained in:
parent
69c215eac9
commit
8d1e0ebdea
@ -203,7 +203,7 @@ pub enum ExpressionKind {
|
|||||||
BinExp(BinOp, Box<Meta<Expression>>, Box<Meta<Expression>>),
|
BinExp(BinOp, Box<Meta<Expression>>, Box<Meta<Expression>>),
|
||||||
PrefixExp(PrefixOp, Box<Meta<Expression>>),
|
PrefixExp(PrefixOp, Box<Meta<Expression>>),
|
||||||
TupleLiteral(Vec<Meta<Expression>>),
|
TupleLiteral(Vec<Meta<Expression>>),
|
||||||
Value(Meta<QualifiedName>),
|
Value(QualifiedName),
|
||||||
NamedStruct {
|
NamedStruct {
|
||||||
name: Meta<QualifiedName>,
|
name: Meta<QualifiedName>,
|
||||||
fields: Vec<(Rc<String>, Meta<Expression>)>,
|
fields: Vec<(Rc<String>, Meta<Expression>)>,
|
||||||
|
@ -769,7 +769,7 @@ impl Parser {
|
|||||||
let fields = self.record_block()?;
|
let fields = self.record_block()?;
|
||||||
Expression::new(self.id_store.fresh(), NamedStruct { name: Meta::new(qualified_identifier), fields })
|
Expression::new(self.id_store.fresh(), NamedStruct { name: Meta::new(qualified_identifier), fields })
|
||||||
},
|
},
|
||||||
_ => Expression::new(self.id_store.fresh(), Value(Meta::new(qualified_identifier)))
|
_ => Expression::new(self.id_store.fresh(), Value(qualified_identifier))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ macro_rules! qname {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
macro_rules! val {
|
macro_rules! val {
|
||||||
($var:expr) => { Value(Meta::new(QualifiedName { components: vec![Rc::new($var.to_string())], id: ItemIdStore::new_id() })) };
|
($var:expr) => { Value(QualifiedName { components: vec![Rc::new($var.to_string())], id: ItemIdStore::new_id() }) };
|
||||||
}
|
}
|
||||||
macro_rules! ty {
|
macro_rules! ty {
|
||||||
($name:expr) => { Singleton(tys!($name)) }
|
($name:expr) => { Singleton(tys!($name)) }
|
||||||
@ -190,13 +190,13 @@ fn qualified_identifiers() {
|
|||||||
parse_test_wrap_ast! {
|
parse_test_wrap_ast! {
|
||||||
"let q_q = Yolo::Swaggins",
|
"let q_q = Yolo::Swaggins",
|
||||||
Meta::new(decl!(Binding { name: rc!(q_q), constant: true, type_anno: None,
|
Meta::new(decl!(Binding { name: rc!(q_q), constant: true, type_anno: None,
|
||||||
expr: Meta::new(Expression::new(ItemIdStore::new_id(), Value(Meta::new(qname!(Yolo, Swaggins))))),
|
expr: Meta::new(Expression::new(ItemIdStore::new_id(), Value(qname!(Yolo, Swaggins)))),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
parse_test_wrap_ast! {
|
parse_test_wrap_ast! {
|
||||||
"thing::item::call()",
|
"thing::item::call()",
|
||||||
exst!(Call { f: bx![ex!(m Value(Meta::new(qname!(thing, item, call))))], arguments: vec![] })
|
exst!(Call { f: bx![ex!(m Value(qname!(thing, item, call)))], arguments: vec![] })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ impl<'a> Reducer<'a> {
|
|||||||
BinExp(binop, lhs, rhs) => self.binop(binop, lhs, rhs),
|
BinExp(binop, lhs, rhs) => self.binop(binop, lhs, rhs),
|
||||||
PrefixExp(op, arg) => self.prefix(op, arg),
|
PrefixExp(op, arg) => self.prefix(op, arg),
|
||||||
Value(qualified_name) => {
|
Value(qualified_name) => {
|
||||||
let ref id = qualified_name.node().id;
|
let ref id = qualified_name.id;
|
||||||
let ref sym_name = match symbol_table.get_fqsn_from_id(id) {
|
let ref sym_name = match symbol_table.get_fqsn_from_id(id) {
|
||||||
Some(fqsn) => fqsn,
|
Some(fqsn) => fqsn,
|
||||||
None => return Expr::ReductionError(format!("FQSN lookup for Value {:?} failed", qualified_name)),
|
None => return Expr::ReductionError(format!("FQSN lookup for Value {:?} failed", qualified_name)),
|
||||||
|
@ -42,8 +42,8 @@ impl<'a> ScopeResolver<'a> {
|
|||||||
let inner_expr = expr.mut_node();
|
let inner_expr = expr.mut_node();
|
||||||
match &mut inner_expr.kind {
|
match &mut inner_expr.kind {
|
||||||
ExpressionKind::Value(qualified_name) => {
|
ExpressionKind::Value(qualified_name) => {
|
||||||
let fqsn = lookup_name_in_scope(&qualified_name.node());
|
let fqsn = lookup_name_in_scope(&qualified_name);
|
||||||
let ref id = qualified_name.node().id;
|
let ref id = qualified_name.id;
|
||||||
self.symbol_table.map_id_to_fqsn(id, fqsn);
|
self.symbol_table.map_id_to_fqsn(id, fqsn);
|
||||||
},
|
},
|
||||||
NamedStruct { name, .. } => {
|
NamedStruct { name, .. } => {
|
||||||
|
@ -318,7 +318,7 @@ impl<'a> TypeContext<'a> {
|
|||||||
PrefixExp(op, expr) => self.prefix(op, expr.node())?,
|
PrefixExp(op, expr) => self.prefix(op, expr.node())?,
|
||||||
BinExp(op, lhs, rhs) => self.binexp(op, lhs.node(), rhs.node())?,
|
BinExp(op, lhs, rhs) => self.binexp(op, lhs.node(), rhs.node())?,
|
||||||
IfExpression { discriminator, body } => self.if_expr(discriminator, body)?,
|
IfExpression { discriminator, body } => self.if_expr(discriminator, body)?,
|
||||||
Value(val) => self.handle_value(val.node())?,
|
Value(val) => self.handle_value(val)?,
|
||||||
Call { box ref f, arguments } => self.call(f, arguments)?,
|
Call { box ref f, arguments } => self.call(f, arguments)?,
|
||||||
Lambda { params, type_anno, body } => self.lambda(params, type_anno, body)?,
|
Lambda { params, type_anno, body } => self.lambda(params, type_anno, body)?,
|
||||||
_ => ty!(Unit),
|
_ => ty!(Unit),
|
||||||
|
Loading…
Reference in New Issue
Block a user