Add Meta annotation to QualifiedName

This commit is contained in:
greg 2019-09-06 10:03:50 -07:00
parent 2b5b1589b0
commit 79635f2f86
5 changed files with 7 additions and 7 deletions

View File

@ -151,7 +151,7 @@ pub enum ExpressionKind {
BinExp(BinOp, Box<Meta<Expression>>, Box<Meta<Expression>>),
PrefixExp(PrefixOp, Box<Meta<Expression>>),
TupleLiteral(Vec<Meta<Expression>>),
Value(QualifiedName),
Value(Meta<QualifiedName>),
NamedStruct {
name: QualifiedName,
fields: Vec<(Rc<String>, Meta<Expression>)>,

View File

@ -765,7 +765,7 @@ impl Parser {
let fields = self.record_block()?;
Expression::new(NamedStruct { name: qualified_identifier, fields })
},
_ => Expression::new(Value(qualified_identifier))
_ => Expression::new(Value(Meta::new(qualified_identifier)))
})
}

View File

@ -30,7 +30,7 @@ macro_rules! parse_error {
($string:expr) => { assert!(parse($string).is_err()) }
}
macro_rules! val {
($var:expr) => { Value(QualifiedName(vec![Rc::new($var.to_string())])) };
($var:expr) => { Value(Meta::new(QualifiedName(vec![Rc::new($var.to_string())]))) };
}
macro_rules! ty {
($name:expr) => { Singleton(tys!($name)) }
@ -171,13 +171,13 @@ fn qualified_identifiers() {
parse_test_wrap_ast! {
"let q_q = Yolo::Swaggins",
Meta::new(Declaration(Binding { name: rc!(q_q), constant: true, type_anno: None,
expr: Meta::new(Expression::new(Value(QualifiedName(vec![rc!(Yolo), rc!(Swaggins)])))),
expr: Meta::new(Expression::new(Value(Meta::new(QualifiedName(vec![rc!(Yolo), rc!(Swaggins)]))))),
}))
}
parse_test_wrap_ast! {
"thing::item::call()",
exst!(Call { f: bx![ex!(m Value(QualifiedName(vec![rc!(thing), rc!(item), rc!(call)])))], arguments: vec![] })
exst!(Call { f: bx![ex!(m Value(Meta::new(QualifiedName(vec![rc!(thing), rc!(item), rc!(call)]))))], arguments: vec![] })
}
}

View File

@ -31,7 +31,7 @@ impl ScopeResolver {
let inner_expr = expr.mut_node();
match &mut inner_expr.kind {
ExpressionKind::Value(qualified_name) => {
let fqsn = lookup_name_in_scope(&qualified_name);
let fqsn = lookup_name_in_scope(&qualified_name.node());
expr.fqsn = Some(fqsn);
},
NamedStruct { name, .. } => {

View File

@ -317,7 +317,7 @@ impl<'a> TypeContext<'a> {
PrefixExp(op, expr) => self.prefix(op, expr.node())?,
BinExp(op, lhs, rhs) => self.binexp(op, lhs.node(), rhs.node())?,
IfExpression { discriminator, body } => self.if_expr(discriminator, body)?,
Value(val) => self.handle_value(val)?,
Value(val) => self.handle_value(val.node())?,
Call { box ref f, arguments } => self.call(f, arguments)?,
Lambda { params, type_anno, body } => self.lambda(params, type_anno, body)?,
_ => ty!(Unit),