-
Notifications
You must be signed in to change notification settings - Fork 39
Leading dot selection (without chained selections yet) #354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: hkmc2-flow
Are you sure you want to change the base?
Changes from all commits
a404e27
ed80d79
726aa7f
3d83be9
22886ae
a16bf17
41f7379
fdc6e65
d2799b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,7 @@ import Keyword.{`let`, `set`} | |
| object Elaborator: | ||
|
|
||
| val binaryOps = Set( | ||
| ",", | ||
| ",", // * Not currently used directly; but `;` (below) maps to it | ||
| "+", "-", "*", "/", "%", | ||
| "==", "!=", "<", "<=", ">", ">=", | ||
| "===", "!==", | ||
|
|
@@ -564,6 +564,8 @@ extends Importer: | |
| val preTrm = subterm(pre) | ||
| val sym = resolveField(nme, preTrm.symbol, nme) | ||
| Term.SynthSel(preTrm, nme)(sym, N) | ||
| case Sel(Empty(), nme) => | ||
| Term.Sel(Term.LeadingDotTarget, nme)(N, N, S(ctx)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we're going to add a new term, it should be |
||
| case Sel(pre, nme) => | ||
| val preTrm = subterm(pre) | ||
| val sym = resolveField(nme, preTrm.symbol, nme) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ import hkmc2.utils.* | |
| import Elaborator.State | ||
| import Tree.Ident | ||
| import hkmc2.utils.SymbolSubst | ||
| import hkmc2.typing.Type | ||
|
|
||
|
|
||
| abstract class Symbol(using State) extends Located: | ||
|
|
@@ -203,6 +204,27 @@ class BuiltinSymbol | |
|
|
||
| def subst(using sub: SymbolSubst): BuiltinSymbol = sub.mapBuiltInSym(this) | ||
|
|
||
| def signature : semantics.flow.Producer = | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not make this a |
||
| import Type.* | ||
| val binaryType : Type = Fun(args = Ls(Top, Top), ret = Top, eff = N) | ||
| val unaryType : Type = Fun(args = Ls(Top), ret = Top, eff = N) | ||
| val nullaryType : Type = Top | ||
| val typ = | ||
| Union( | ||
| Union( | ||
| if (binary) then binaryType else Bot, | ||
| if (unary) then unaryType else Bot, | ||
| ), | ||
| if (nullary) then nullaryType else Bot, | ||
| ) | ||
| // (binary, unary, nullary) match | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually prefer this version.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what are you referring to? The pattern match or the |
||
| // case (true, true, true) => Union() | ||
| // case (true, _, _) => Fun(args = Ls(Top, Top), ret = Top, eff = N) | ||
| // case (_, true, _) => Fun(args = Ls(Top), ret = Top, eff = N) | ||
| // case (_, _, true) => Top | ||
| // case _ => Bot | ||
| semantics.flow.Producer.Typ(typ) | ||
|
|
||
|
|
||
| /** This is the outside-facing symbol associated to a possibly-overloaded | ||
| * definition living in a block – e.g., a module or class. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,10 +23,11 @@ case class Constraint(lhs: Producer, rhs: Consumer): | |
| enum Producer: | ||
| case Flow(sym: FlowSymbol) | ||
| case Fun(lhs: Consumer, rhs: Producer, captures: Ls[(Producer, Consumer)]) | ||
| case Tup(elems: Ls[Opt[SpreadKind] -> Producer]) | ||
| case Tup(elems: Ls[(Opt[SpreadKind], Producer)]) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personally, |
||
| case Ctor(sym: CtorSymbol, args: List[Producer])(val trm: Term) extends Producer, CtorImpl | ||
| case LeadingDotSel(nme: Ident)(val trm: Term.Sel) // Note: trm.prefix is Missing | ||
| case Typ(typ: Type) | ||
| case Unknown(t: Statement) | ||
| case Unknown(s: Statement) // `s` is just for error reporting/debugging purposes | ||
|
|
||
|
|
||
| def toLoc: Opt[Loc] = this match | ||
|
|
@@ -41,6 +42,7 @@ enum Producer: | |
| case tup: Tup => Document.bracketed("[", "]")(showTupElems(tup)) | ||
| case Ctor(LitSymbol(UnitLit(false)), Nil) => "()" | ||
| case Ctor(sym, args) => doc"${sym.nme}${args.map(_.showAsParams).mkDocument()}" | ||
| case LeadingDotSel(nme) => doc"_?_.${nme.showDbg}" | ||
| case Typ(typ) => doc"type ${typ.show}" | ||
| case Unknown(t) => doc"¿${t.showDbg}?" | ||
|
|
||
|
|
@@ -62,6 +64,7 @@ enum Producer: | |
| case Ctor(sym, Nil) => sym.nme | ||
| case Tup(args) => s"[${args.map((spd, a) => spd.fold("")(_.str) + a.showDbg).mkString(", ")}]" | ||
| case Ctor(sym, args) => s"${sym.nme}${args.map(_.showDbgAsParams).mkString}" | ||
| case sel @ LeadingDotSel(nme) => s"_?_.${nme}" | ||
| case Typ(typ) => s"type ${typ.showDbg}" | ||
| case Unknown(t) => s"¿${t.showDbg}?" | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👎