From fea45ccbea6bee563b41da199fb3c456c6069cb5 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 10 Apr 2021 23:47:19 -0700 Subject: shell: full closures --- shell/evaluate.mu | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'shell/evaluate.mu') diff --git a/shell/evaluate.mu b/shell/evaluate.mu index e47762ef..3aedb7c7 100644 --- a/shell/evaluate.mu +++ b/shell/evaluate.mu @@ -56,14 +56,19 @@ fn evaluate _in: (addr handle cell), out: (addr handle cell), env-h: (handle cel # trees starting with "fn" are anonymous functions and therefore literals var expr/esi: (addr cell) <- copy in-addr # if its first elem is not "fn", break + var in-addr/edx: (addr cell) <- copy in-addr var first-ah/ecx: (addr handle cell) <- get in-addr, left var first/eax: (addr cell) <- lookup *first-ah var fn?/eax: boolean <- fn? first compare fn?, 0/false break-if-= - # + # turn (fn ...) into (fn env ...) trace-text trace, "eval", "anonymous function" - copy-object _in, out + var rest-ah/eax: (addr handle cell) <- get in-addr, right + var tmp: (handle cell) + var tmp-ah/edi: (addr handle cell) <- address tmp + new-pair tmp-ah, env-h, *rest-ah + new-pair out, *first-ah, *tmp-ah trace-higher trace return } @@ -255,12 +260,12 @@ fn apply _f-ah: (addr handle cell), args-ah: (addr handle cell), out: (addr hand break-if-= var rest-ah/esi: (addr handle cell) <- get f, right var rest/eax: (addr cell) <- lookup *rest-ah + var callee-env-ah/edx: (addr handle cell) <- get rest, left + rest-ah <- get rest, right + rest <- lookup *rest-ah var params-ah/ecx: (addr handle cell) <- get rest, left var body-ah/eax: (addr handle cell) <- get rest, right - var nil-env-h: (handle cell) - var nil-env-ah/edx: (addr handle cell) <- address nil-env-h - allocate-pair nil-env-ah - apply-function params-ah, args-ah, body-ah, out, nil-env-h, globals, trace, screen-cell, keyboard-cell + apply-function params-ah, args-ah, body-ah, out, *callee-env-ah, globals, trace, screen-cell, keyboard-cell trace-higher trace return } -- cgit 1.4.1-2-gfad0 lue='hlt'/>
path: root/tutorial/task6-error-runbook.txt
blob: 237257226d27f3412bdc5de857fc06d7af754714 (plain) (tree)



















                                                                             
If I encounter an error that looks like this:
  fn main: stmt copy: output 'm' not in a register

then I should do the following:
  - find the function mentioned (here `main`);
  - look for a statement that contains the mentioned output (here `m`) before
    the `<-`; and
  - replace the statement with a version of the same instruction that writes
    to an inout in memory. (Here, replace `m <- copy` with `copy-to m`.)

===

If I encounter an error that looks like this:
  label table: get-slice: key not found: copy-to

then I should do the following:
  - look for a statement with the same instruction (here `copy-to`) whose
    first inout is not a variable stored in memory; and
  - email Kartik (http://akkartik.name/contact) to ask why this message is so
    much less helpful then the previous one.