Skip to content

Commit

Permalink
Change pretty printing of state instructions.
Browse files Browse the repository at this point in the history
  • Loading branch information
phischu committed Jul 26, 2023
1 parent e28548b commit dde7dcf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ object PrettyPrinter extends ParenPrettyPrinter {
"invoke" <+> receiver <> "." <> tag.toString <> parens(arguments map toDoc)

case Allocate(name, init, ev, rest) =>
toDoc(name.tpe) <+> name <> "<" <> ev <> ">" <+> "=" <+> init <> ";" <> line <> toDoc(rest)
"let" <+> name <+> "=" <+> "allocate" <> parens(List(init, ev) map toDoc) <> ";" <> line <> toDoc(rest)

case Load(name, ref, ev, rest) =>
name <+> "=" <+> "*" <> ref <> "<" <> ev <> ">" <> ";" <> line <> toDoc(rest)
"let" <+> name <+> "=" <+> "load" <> parens(List(ref, ev) map toDoc) <> ";" <> line <> toDoc(rest)

case Store(ref, value, ev, rest) =>
"*" <> ref <> "<" <> ev <> ">" <+> "=" <+> value <> ";" <> line <> toDoc(rest)
"store" <> parens(List(ref, ev, value) map toDoc) <> ";" <> line <> toDoc(rest)

case PushFrame(frame, rest) =>
"push" <+> toDoc(frame) <> ";" <> line <> toDoc(rest)
Expand Down
6 changes: 3 additions & 3 deletions effekt/shared/src/main/scala/effekt/machine/Tree.scala
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,17 @@ enum Statement {
case Invoke(receiver: Variable, tag: Tag, arguments: Environment)

/**
* e.g. Int x in r = 42; s
* e.g. let x = allocate(42, ev); s
*/
case Allocate(name: Variable, init: Variable, ev: Variable, rest: Statement)

/**
* e.g. y = *x; s
* e.g. let y = load(x, ev); s
*/
case Load(name: Variable, ref: Variable, ev: Variable, rest: Statement)

/**
* e.g. *x = 42; s
* e.g. store(x, 42, ev); s
*/
case Store(ref: Variable, value: Variable, ev: Variable, rest: Statement)

Expand Down

0 comments on commit dde7dcf

Please sign in to comment.