Merge pull request #4993 from joshuawarner32/tuple-gen-tuple-backend-experiment

Implement mono / code generation for tuples
This commit is contained in:
Ayaz 2023-02-08 10:42:51 -05:00 committed by GitHub
commit 9340a67e87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 1773 additions and 290 deletions

View file

@ -12,6 +12,7 @@ use roc_parse::ast::{
AssignedField, Base, Collection, CommentOrNewline, Expr, ExtractSpaces, Pattern, WhenBranch,
};
use roc_parse::ast::{StrLiteral, StrSegment};
use roc_parse::ident::Accessor;
use roc_region::all::Loc;
impl<'a> Formattable for Expr<'a> {
@ -35,9 +36,8 @@ impl<'a> Formattable for Expr<'a> {
| NonBase10Int { .. }
| SingleQuote(_)
| RecordAccess(_, _)
| RecordAccessorFunction(_)
| AccessorFunction(_)
| TupleAccess(_, _)
| TupleAccessorFunction(_)
| Var { .. }
| Underscore { .. }
| MalformedIdent(_, _)
@ -453,21 +453,19 @@ impl<'a> Formattable for Expr<'a> {
buf.push(')');
}
}
RecordAccessorFunction(key) => {
AccessorFunction(key) => {
buf.indent(indent);
buf.push('.');
buf.push_str(key);
match key {
Accessor::RecordField(key) => buf.push_str(key),
Accessor::TupleIndex(key) => buf.push_str(key),
}
}
RecordAccess(expr, key) => {
expr.format_with_options(buf, Parens::InApply, Newlines::Yes, indent);
buf.push('.');
buf.push_str(key);
}
TupleAccessorFunction(key) => {
buf.indent(indent);
buf.push('.');
buf.push_str(key);
}
TupleAccess(expr, key) => {
expr.format_with_options(buf, Parens::InApply, Newlines::Yes, indent);
buf.push('.');