Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions metadata/src/main/scala/Builtin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,27 @@ object Builtin {
/** The id for a method's qualified name, or `None` if it names no builtin. */
def idOf(qualifiedName: string): int = {
qualifiedName match {
case "println" => Println
case "print" => Print
case "panic" => Panic
case "exit" => Exit
case "assert" => Assert
case "mod" => Mod
case "string.apply" => StringApply
case "int.apply" => IntApply
case "bool.apply" => BoolApply
case "char.apply" => CharApply
case "string.substring" => Substring
case "string.endsWith" => EndsWith
case "string.compareTo" => StringCompareTo
case "int.compareTo" => IntCompareTo
case "File.readAllText" => ReadAllText
case "File.readAllBytes" => ReadAllBytes
case "File.writeAllBytes" => WriteAllBytes
case "File.writeAllText" => WriteAllText
case "Path.combine" => PathCombine
case "Path.nameWithoutExtension" => PathName
case _ => None
case "println" => Println
case "print" => Print
case "panic" => Panic
case "exit" => Exit
case "assert" => Assert
case "mod" => Mod
case "string.apply" => StringApply
case "int.apply" => IntApply
case "bool.apply" => BoolApply
case "char.apply" => CharApply
case "string.substring" => Substring
case "string.endsWith" => EndsWith
case "string.compareTo" => StringCompareTo
case "int.compareTo" => IntCompareTo
case "File.readAllText" => ReadAllText
case "File.readAllBytes" => ReadAllBytes
case "File.writeAllBytes" => WriteAllBytes
case "File.writeAllText" => WriteAllText
case "Path.combine" => PathCombine
case "Path.nameWithoutExtension" => PathName
case _ => None
}
}

Expand Down
4 changes: 2 additions & 2 deletions metadata/src/main/scala/Metadata.scala
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,8 @@ case class Metadata() {
/** Every table, in an order `read` repeats.
*
* Strings were left out, which is why nothing could be read back: every
* other table refers to one by token, so an image without them has names
* for nothing and `Ldstr` has no literal to load.
* other table refers to one by token, so an image without them has names for
* nothing and `Ldstr` has no literal to load.
*/
def write(buffer: IntList): unit = {
typeDefs.write(buffer)
Expand Down
6 changes: 3 additions & 3 deletions metadata/src/main/scala/Opcode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ object Opcode {

/** Call a builtin, whose id is the operand.
*
* A builtin is an `extern` method with no body to call into. One
* instruction rather than one per builtin: the id says which, so declaring
* a builtin does not grow the instruction set. See `Builtin`.
* A builtin is an `extern` method with no body to call into. One instruction
* rather than one per builtin: the id says which, so declaring a builtin
* does not grow the instruction set. See `Builtin`.
*/
val Callx = 62

Expand Down
28 changes: 16 additions & 12 deletions pnc/src/Ast.pn
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ class GenericParametersSyntax(
[derive(Eq, Show)]
class SeparatedSyntaxList[T](items: List[T], separators: List[SyntaxToken])

/** One trait named inside a `derive` attribute, with the comma that follows
* it, if any — the same shape `ParameterSyntax` uses for its list.
/** One trait named inside a `derive` attribute, with the comma that follows it,
* if any — the same shape `ParameterSyntax` uses for its list.
*/
[derive(Eq, Show)]
class DerivedTraitSyntax(
Expand All @@ -283,9 +283,9 @@ class DerivedTraitSyntax(

/** `[derive(Eq, Ord, Show)]` ahead of a class or enum.
*
* Derivation is opt-in: a type with no attribute gets no evidence, so `a ==
* b` on it is a diagnostic rather than a silent identity comparison
* ([ADR 0004](../../../docs/architecture/adr/0004-traits-given-evidence-and-contextual-extensions.md)).
* Derivation is opt-in: a type with no attribute gets no evidence, so `a == b`
* on it is a diagnostic rather than a silent identity comparison ([ADR
* 0004](../../../docs/architecture/adr/0004-traits-given-evidence-and-contextual-extensions.md)).
*/
[derive(Eq, Show)]
class DeriveAttributeSyntax(
Expand Down Expand Up @@ -324,24 +324,28 @@ class DeriveAttributeSyntax(
typeAnnotation: Option[TypeAnnotationSyntax],
body: Option[FunctionBodySyntax]
)

/** A trait declares a capability: a name, its type parameters, and the
* members an instance has to supply. It has no constructor parameters
* because a trait is never instantiated — evidence for it comes from a
* `given` ([ADR 0004](../../../docs/architecture/adr/0004-traits-given-evidence-and-contextual-extensions.md)).
* `given` ([ADR
* 0004](../../../docs/architecture/adr/0004-traits-given-evidence-and-contextual-extensions.md)).
*/
case TraitDeclarationSyntax(
traitKeyword: SyntaxToken,
identifier: SyntaxToken,
genericParameters: Option[GenericParametersSyntax],
template: TemplateSyntax
)

/** `given Eq[int] { … }`, or with a premise,
* `given [T: Ord] => Ord[List[T]] { … }`.
*
* The type parameters and the `=>` travel together: a given with nothing to
* bind has neither. There is no name — under global coherence there is one
* given per `(trait, type)` pair, so a name would have nothing to select
* ([ADR 0004](../../../docs/architecture/adr/0004-traits-given-evidence-and-contextual-extensions.md)).
* ([ADR
* 0004](../../../docs/architecture/adr/0004-traits-given-evidence-and-contextual-extensions.md)).
*/
case GivenDeclarationSyntax(
givenKeyword: SyntaxToken,
Expand Down Expand Up @@ -566,13 +570,13 @@ object AstUtils {
locationOfBoundExpression(left).merge(locationOfBoundExpression(right))
case BoundExpression.Block(statements, expression) =>
locationOfBoundExpression(expression)
case BoundExpression.Boolean(location, _) => location
case BoundExpression.Call(location, _, _, _, _, _) => location
case BoundExpression.Boolean(location, _) => location
case BoundExpression.Call(location, _, _, _, _, _) => location
case BoundExpression.EvidenceCall(location, _, _, _, _) => location
case BoundExpression.EvidenceRecord(location, _, _) => location
case BoundExpression.Cast(location, expression, _) => location
case BoundExpression.Character(location, _) => location
case BoundExpression.For(location, _, _, _, _) => location
case BoundExpression.Cast(location, expression, _) => location
case BoundExpression.Character(location, _) => location
case BoundExpression.For(location, _, _, _, _) => location
case BoundExpression.If(
location,
cond,
Expand Down
5 changes: 3 additions & 2 deletions pnc/src/AstPrinter.pn
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ class AstPrinter(withColor: bool, buffer: IndentedStringBuilder) {
case Option.Some(value) => printGenericParameters(value)
}
node.arrowToken match {
case Option.None => ()
case Option.Some(value) => printTokenWithColor(value, ColorPalette.Keyword)
case Option.None => ()
case Option.Some(value) =>
printTokenWithColor(value, ColorPalette.Keyword)
}
printName(node.name)
printTemplate(node.template)
Expand Down
7 changes: 4 additions & 3 deletions pnc/src/BinaryOperators.pn
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,17 @@ class BinaryOperators(binder: Binder) {
* question the caller asks last, because evidence has to come first: a type
* with `Eq` evidence must compare through that evidence rather than by
* identity, and folding the identity rule in here would answer before the
* evidence was ever consulted
* ([ADR 0004](../../../docs/architecture/adr/0004-traits-given-evidence-and-contextual-extensions.md)).
* evidence was ever consulted ([ADR
* 0004](../../../docs/architecture/adr/0004-traits-given-evidence-and-contextual-extensions.md)).
*/
def checkBinary(
left: Type,
right: Type,
operator: BinaryOperatorKind
): Type = _checkBinary(binaryOps, left, right, operator)

/** [ADR 0003](../../../docs/architecture/adr/0003-equality-on-reference-types.md)'s
/** [ADR
* 0003](../../../docs/architecture/adr/0003-equality-on-reference-types.md)'s
* rule, now the last resort rather than part of the table lookup.
*/
def referenceEquality(
Expand Down
Loading
Loading