Commit Graph

1200 Commits

Author SHA1 Message Date
Kartik Agaram
10adec2f21 7155
apps/arith.mu compiling again.
2020-11-01 22:04:35 -08:00
Kartik Agaram
17623a628a 7154 2020-11-01 22:02:13 -08:00
Kartik Agaram
cc7dcdc3b8 7153
Bugfix in computing the label a return should jump to.
2020-11-01 20:37:56 -08:00
Kartik Agaram
ccadc6e604 7152 - 'return' instruction
https://github.com/akkartik/mu/issues/45#issuecomment-719990879, task 1.

We don't have checking for it yet. Soon.
2020-11-01 18:02:02 -08:00
Kartik Agaram
c694b8e2cb 7151
Drop pending tests for the old plan of liveness analysis.
2020-11-01 11:19:03 -08:00
Kartik Agaram
77687ba944 7148 2020-10-31 20:29:09 -07:00
Kartik Agaram
8c44afcccc 7145 - roll back to 7143 2020-10-30 20:23:56 -07:00
Kartik Agaram
264acd9ec9 7144 - tmp: redo checks for function outputs
This isn't done, but an intermediate snapshot seems worth capturing.

Back in March (commit 6082), I made a plan to check writes to function
outputs using liveness analysis. I've been shying away from actually acting
on this plan ever since. In recent weeks I've had this gap bite me three
times.

Returning to the problem now, I think I don't actually need to compute
variable liveness. The compiler can, I think, do the same thing for output
registers whether their variables are alive or dead. The new rule is this:

Once a register gets a function output written to it, no local is popped
into it. Instead of popping outer locals to the register, we simply increment
the stack and keep going.

Since the function output will continue to live on the vars stack past
this point (see clean-up-block), any attempts to read shadowed variables
will throw an error as usual.

This rule is also now easy to explain to people, I think. "You wrote the
function output. Now the register can't be used for anything else."

It's really cool that this works (if it does). Another fruit from "Mu's
lovely property."
2020-10-30 06:05:52 -07:00
Kartik Agaram
8fe51755bf 7143
Am I starting to have too much code duplication?
2020-10-29 22:06:50 -07:00
Kartik Agaram
2486881de0 7142 2020-10-29 21:36:33 -07:00
Kartik Agaram
0a5d247ba7 7141 2020-10-29 21:15:15 -07:00
Kartik Agaram
bc67d01879 7140 2020-10-29 13:19:53 -07:00
Kartik Agaram
7521fcdc1e 7139 - type-check compute-offset 2020-10-29 00:34:00 -07:00
Kartik Agaram
4cbe0ba1ac 7138 - type-check array 'length' instruction 2020-10-29 00:03:19 -07:00
Kartik Agaram
d3657eec0d 7137 2020-10-28 23:25:40 -07:00
Kartik Agaram
216af9cc1c 7136 2020-10-28 23:25:05 -07:00
Kartik Agaram
33b1e9a894 7135 - type-check write-to-stream
Lots of copy-pasta.
2020-10-28 22:39:14 -07:00
Kartik Agaram
d648812c51 7134 - type-check read-from-stream 2020-10-28 22:35:35 -07:00
Kartik Agaram
6b218b8d62 7130 - back to the Mu compiler for a spell
Hacking on apps has created some urgency now for several additional safety
checks.
2020-10-27 21:22:18 -07:00
Kartik Agaram
c5e1cbc4ce 7129 - tile: allow bindings anywhere
Amazing how easy this was. And it does feel more intuitive. If I decide
at some point that I want to bind something to a name I don't usually want
to lose the entire line after that point.

It also sidesteps for now the thorny question of whether to permit organically
switching to a new line (rather than using the 'name value' hotkey), and
how that should work.
2020-10-27 20:51:28 -07:00
Kartik Agaram
603b4c47dd 7128
More consistent spacing in sandbox render.
2020-10-27 10:31:21 -07:00
Kartik Agaram
5df70f4dff 7127 2020-10-27 00:49:02 -07:00
Kartik Agaram
f926aaedfc 7126 2020-10-27 00:44:36 -07:00
Kartik Agaram
61dca1cec4 7125 - tile: fade out values on the stack 2020-10-27 00:43:50 -07:00
Kartik Agaram
332998546d 7124 - tiles: better 'lines' primitive 2020-10-27 00:43:14 -07:00
Kartik Agaram
307a75530f 7123 - tile: truncate string if necessary 2020-10-26 23:57:39 -07:00
Kartik Agaram
c15b6e3fc6 7122 - tile: styling for strings 2020-10-26 23:45:40 -07:00
Kartik Agaram
22ade886d5 7121
Starting to polish 'line-count' demo:

  filename line-count
    = filename open lines len
2020-10-26 23:45:40 -07:00
Kartik Agaram
0f9a65dc0d 7120 - tile: array of lines from file
Requires a quick hacky change to Mu compiler.
2020-10-26 23:45:40 -07:00
Kartik Agaram
f3d1929033 7119 - tile: new primitive to slurp file contents
Stack display is messed up when file contents contain newlines. Ignoring
that for now.
2020-10-26 21:56:47 -07:00
Kartik Agaram
2ddfdf191c 7118 2020-10-26 21:54:31 -07:00
Kartik Agaram
8bbd494aaa 7117 2020-10-26 21:53:02 -07:00
Kartik Agaram
d5ac55d3ca 7116 - tile: regression in typing in strings
We really need to clean up the Mu compiler's logic around function outputs.
2020-10-26 21:50:37 -07:00
Kartik Agaram
71418907f6 7115 2020-10-26 21:24:43 -07:00
Kartik Agaram
c5b1b560e2 7113 2020-10-26 21:06:26 -07:00
Kartik Agaram
14a41f4a27 7112 - tile: arrays of non-integers 2020-10-26 21:01:42 -07:00
Kartik Agaram
16a31669e3 7111 2020-10-26 17:06:00 -07:00
Kartik Agaram
7c9b650d27 7110
Some more helpers that I want to avoid using, but they help me gain confidence
in the current implementation of file handles. Manual test:

  "x" open dup read swap read

Assumes there's a file called `x` in the current directory that contains
at least two (short!) lines.
2020-10-26 09:27:32 -07:00
Kartik Agaram
475da72c61 7109
Turns out I've been including some unnecessary files when building apps/mu!

Treeshaken stats before:
  LoC 26258 => 9717
  LoC including common libraries: 29736 => 12719
  binary size: 406K  => 79K

After:
  LoC 26258 => 9717
  LoC including common libraries: 28322 => 12370
  binary size: 406K  => 77K

So our treeshaking isn't perfect. No surprise there..

The treeshaken build also starts to fail without the one-liner change to
mu.subx, which looks like a bug in the treeshaker.
2020-10-25 22:32:56 -07:00
Kartik Agaram
10d5b13af8 7108 - tile: read from file handle 2020-10-25 21:43:18 -07:00
Kartik Agaram
5f5579e168 7107 - tile: file handles 2020-10-25 21:35:24 -07:00
Kartik Agaram
2d7960d493 7106 - tile: arrays of ints 2020-10-25 21:15:43 -07:00
Kartik Agaram
1787560a6d 7105 - tile: define-function works with strings 2020-10-25 20:33:40 -07:00
Kartik Agaram
fa4cc8c871 7104 - tile: word-rename works with strings 2020-10-25 20:12:32 -07:00
Kartik Agaram
bdf1bf7777 7103 - tile: first primitive for strings 2020-10-25 20:00:36 -07:00
Kartik Agaram
ad54c69667 7102 2020-10-25 19:41:07 -07:00
Kartik Agaram
a148b23a22 7101 - tile: remove quotes when evaluating strings
This found several bugs due to me not checking for null strings.
2020-10-25 18:45:11 -07:00
Kartik Agaram
8a6ad45d8d 7100 - tile: render string literals 2020-10-25 18:14:12 -07:00
Kartik Agaram
517ef9f64f 7099 2020-10-25 15:23:49 -07:00
Kartik Agaram
f37e7f33e8 7098 - tile: string values
Strings can contain spaces.
2020-10-25 14:34:40 -07:00
Kartik Agaram
a87bc353f5 . 2020-10-24 19:33:41 -07:00
Kartik Agaram
e648bc9c88 tile: process space in middle of word 2020-10-24 18:26:19 -07:00
Kartik Agaram
1137dd2a99 tile: process space at start of word
This was very difficult to debug.

We still need to process space in the middle of a word.
2020-10-24 16:52:33 -07:00
Kartik Agaram
03012c91c2 tile: adjust spacing between commandline and stack 2020-10-23 00:09:24 -07:00
Kartik Agaram
4568607634 7087 - defining functions now seems to be working 2020-10-20 22:15:32 -07:00
Kartik Agaram
6b973819d0 7086
Expanding words now seems to be working. I was forgetting to update 'prev'
pointers in a few places.
2020-10-20 21:48:53 -07:00
Kartik Agaram
9ac5159486 7085 2020-10-20 21:18:38 -07:00
Kartik Agaram
cbe90c6a2b 7084
Cursor now updating right.

Still a couple of bugs:
  ctrl-e doesn't know about multiple lines
  function calls don't expand right in multi-line sandboxes
    (but at least I'm now getting to see them in action!)
2020-10-20 13:39:31 -07:00
Kartik Agaram
38ff550455 7083
Defining functions mostly working. But we still need to fix the cursor
afterwards.
2020-10-20 10:02:31 -07:00
Kartik Agaram
ce94374bd1 7082 2020-10-20 09:39:12 -07:00
Kartik Agaram
5bdcb85f67 7081
Defining new functions seems to be working. _However_, we aren't yet detecting
duplicates. `x x *` leads to a declaration of `x x f`.
2020-10-20 09:33:13 -07:00
Kartik Agaram
c2d537c46b 7080
Constructing new functions with ctrl-d is now working right. But the call
seems exactly flipped.
2020-10-20 01:07:21 -07:00
Kartik Agaram
0cdbfff256 7079 2020-10-19 23:53:45 -07:00
Kartik Agaram
e28b949f18 7078 2020-10-19 23:20:33 -07:00
Kartik Agaram
5e9a482193 7077 - tile: render function list 2020-10-19 23:13:28 -07:00
Kartik Agaram
5532ea013b 7066 - tile: some more primitives for testing
Lesson learned: functions store args in _reverse_ order. Since evaluation
is very frequent, it's worth optimizing for it.
2020-10-19 22:41:46 -07:00
Kartik Agaram
3ff287f410 7065 2020-10-19 22:29:08 -07:00
Kartik Agaram
7144ae7638 7064 2020-10-19 22:27:52 -07:00
Kartik Agaram
1158758f20 7063 - tile: scaffolding for defining functions 2020-10-18 23:41:57 -07:00
Kartik Agaram
f1a3f88e95 7062 2020-10-18 23:23:36 -07:00
Kartik Agaram
266ac87340 7061 2020-10-18 23:22:06 -07:00
Kartik Agaram
19fd3c9ca4 7060 - tile: renaming variables now works 2020-10-18 23:07:23 -07:00
Kartik Agaram
956394017e 7059
Cursor now in the right place after rename. But stack still doesn't show
the value of a name.
2020-10-18 22:48:11 -07:00
Kartik Agaram
a3ddc1bdb3 7058
Snapshot; things seem to be working besides ctrl-r, but we aren't yet rendering
only the final line.
2020-10-18 21:57:09 -07:00
Kartik Agaram
47497ea552 7057 - tile: back to names
We can now create new bindings for names while evaluating lines.
2020-10-18 20:51:47 -07:00
Kartik Agaram
82d1fe7c9c 7056 - orange-pink 2020-10-18 20:18:51 -07:00
Kartik Agaram
d7d384a72b 7055 2020-10-18 15:49:20 -07:00
Kartik Agaram
e170b35d8b 7054 2020-10-18 15:39:34 -07:00
Kartik Agaram
dc0e03e4a5 7053
Rename seems to now be working. State still isn't rendered right, so we
can't be sure.
2020-10-17 23:29:02 -07:00
Kartik Agaram
1fc218bf9d 7052 2020-10-17 23:10:00 -07:00
Kartik Agaram
26bfae3d5e 7051 2020-10-17 13:54:33 -07:00
Kartik Agaram
d29dcd1263 7050 2020-10-17 12:32:44 -07:00
Kartik Agaram
ab697ede40 7049 2020-10-17 11:50:43 -07:00
Kartik Agaram
e3d6e067c6 7048 2020-10-17 11:48:13 -07:00
Kartik Agaram
302082ab70 7047 2020-10-17 11:45:37 -07:00
Kartik Agaram
5f8c473c55 7046 - start of flow for naming words
Names don't stick yet, but we have a scaffolding for printing a dialog
and accepting input.
2020-10-17 11:40:29 -07:00
Kartik Agaram
2dd300eb20 7045 2020-10-16 22:46:39 -07:00
Kartik Agaram
b72c5a60ff 7044 2020-10-16 22:40:40 -07:00
Kartik Agaram
7244bf99dd 7043 - the REPL is dead; long live the IVL 2020-10-16 22:29:23 -07:00
Kartik Agaram
16212c63cb 7042 2020-10-15 22:37:21 -07:00
Kartik Agaram
fc1d71dd09 7039
Ok, I think we may finally be done crushing all the pesky bugs.

And now we can insert and delete words in the middle of a line, and have
expanded calls stay stable!
2020-10-15 21:22:51 -07:00
Kartik Agaram
02cefc7065 7038
Arrow keys now seem to be working right within expanded functions. Still
seeing one minor issue with left-arrow skipping words.
2020-10-15 21:19:52 -07:00
Kartik Agaram
2885e1d441 7037
Expanding words now working, but ctrl-f/ctrl-b inside expanded words not
working right.
2020-10-15 20:54:06 -07:00
Kartik Agaram
514dea3aab 7036
ctrl-u now working.
2020-10-15 20:48:27 -07:00
Kartik Agaram
70da3b3846 7035
ctrl-f and ctrl-b working right. Now ctrl-u is segfaulting. Also expanding
words.
2020-10-15 20:46:01 -07:00
Kartik Agaram
6fdfd5607b 7034
Finally following up on commit 7020. Ctrl-a and ctrl-e now work, but word-wise
motions are still showing some funkiness.
2020-10-15 20:37:11 -07:00
Kartik Agaram
480fd9958a 7032 2020-10-14 13:42:03 -07:00
Kartik Agaram
d9f8784d4c 7031 2020-10-14 12:46:53 -07:00
Kartik Agaram
7dd5a41e07 7030 2020-10-14 12:22:32 -07:00
Kartik Agaram
9635163bdc 7029 2020-10-14 12:00:19 -07:00
Kartik Agaram
098dd58df4 7021 2020-10-14 03:51:50 -07:00
Kartik Agaram
5fe86b8348 7020
snapshot: migrating call-path to store word handles rather than word indexes.

ctrl-a and ctrl-e are segfaulting. There are likely other problems.

The major new change here is that allocating a call-path-element no longer
initializes it.
2020-10-14 03:31:06 -07:00
Kartik Agaram
3b18846e1f 7019 2020-10-14 02:52:30 -07:00
Kartik Agaram
c3edaff02a 7018 - tile: tweak spacing between stacks
Until now the word being typed had a slightly larger invisible margin,
which was a little strange. Should look cleaner now.
2020-10-13 10:58:18 -07:00
Kartik Agaram
f3a8a2588f 7017 2020-10-13 10:29:42 -07:00
Kartik Agaram
6310b0c44d 7016 - raw addrs shouldn't escape functions
We don't have the static checks for this yet, but discovering I've not
been following my own rules bumps the priority on it.
2020-10-13 10:15:23 -07:00
Kartik Agaram
af52cb8d1f 7015 - bugfix in column width computation
I just got bitten by variable shadowing! It's a lot less theoretical concern
now.
2020-10-13 00:05:05 -07:00
Kartik Agaram
54fd7d7a99 7014
7013 had broken right-justification when rendering the stack. Redo.
2020-10-12 21:25:41 -07:00
Kartik Agaram
1faea03428 7013 2020-10-12 19:00:16 -07:00
Kartik Agaram
32cc6779af 7012
Fix CI.
2020-10-12 12:08:25 -07:00
Kartik Agaram
6c21568f03 7011 - tile: keep garbage out of the stack 2020-10-12 11:39:28 -07:00
Kartik Agaram
598f942624 7010
A new example that better demonstrates the value of named arguments.
2020-10-12 10:10:31 -07:00
Kartik Agaram
855431280d 7009 - tile: real hotkey to quit 2020-10-12 10:07:55 -07:00
Kartik Agaram
4d985cda1e 7008 - tile: center menu 2020-10-11 23:06:13 -07:00
Kartik Agaram
5668acaf44 7007 - tile: hotkey to clear sandbox
Alternative symbols considered for the menu option:
  ∅
  AC (like in a calculator)
2020-10-11 23:00:45 -07:00
Kartik Agaram
e6c19a3465 7006 2020-10-11 22:56:46 -07:00
Kartik Agaram
fcdf04ee78 7005 - tile: move to start/end of line 2020-10-11 22:37:18 -07:00
Kartik Agaram
aceeba8d48 7004 2020-10-11 22:15:29 -07:00
Kartik Agaram
31a1ade9a2 7003 2020-10-11 22:11:03 -07:00
Kartik Agaram
9cbb6dce54 7002 - tile: next-word 2020-10-11 00:23:35 -07:00
Kartik Agaram
8c0d0c8464 7001 2020-10-11 00:17:24 -07:00
Kartik Agaram
1c441baf96 7000 - tile: previous-word also bumps up to caller 2020-10-11 00:11:04 -07:00
Kartik Agaram
28d99f031d 6999 - tile: move to previous word 2020-10-10 23:38:42 -07:00
Kartik Agaram
cfad9c494e 6998 2020-10-10 22:08:23 -07:00
Kartik Agaram
4b75c6b554 6997 2020-10-10 22:07:13 -07:00
Kartik Agaram
3d203a4484 6996 2020-10-10 21:43:34 -07:00
Kartik Agaram
7c2d5dc88b 6995 2020-10-10 21:40:03 -07:00
Kartik Agaram
24c4854223 6994 2020-10-10 21:32:43 -07:00
Kartik Agaram
818512d15a 6993 2020-10-10 21:31:33 -07:00
Kartik Agaram
07faf800ac 6992
Left arrow key out of an expanded word now working.

Still to fix: left arrow key out of the first word in the first word.
2020-10-10 21:30:02 -07:00
Kartik Agaram
ae6340f225 6991 - tile: nested calls now expanding
I just needed to remove an obsolete guardrail in render-line.

Still seeing some bugs with left-arrow when playing around with the full
expansion of `1 2+`.
2020-10-10 21:22:00 -07:00
Kartik Agaram
831a133a4b 6990
Bring back definitions for 1+ and 2+. Expanding nested calls still doesn't
work.
2020-10-10 02:08:46 -07:00
Kartik Agaram
dae19c9fe6 6989 - tile: arrow keys now seem to handle calls 2020-10-10 02:00:46 -07:00
Kartik Agaram
b25167a9ae 6988
Oh, of course. I can't compare the word with the word at the cursor. Not
even its interned pointer. We have to track the call path.
2020-10-10 01:43:12 -07:00
Kartik Agaram
e8367b2bc2 6987 - left-arrow to jump to caller/callee
Starting to work. I'm still seeing problems in lines with multiple expanded
calls, but perhaps that's a rendering issue.

The code is absolutely ghastly.
2020-10-10 01:42:58 -07:00
Kartik Agaram
f864cf0874 6986
Cursor now stays on the right row as we bounce in and out of function calls.
2020-10-09 23:43:24 -07:00
Kartik Agaram
5b7ccbc8f4 6985 - tile: make calls read-only 2020-10-09 23:35:19 -07:00
Kartik Agaram
cbd076e02c 6984 2020-10-09 23:32:50 -07:00
Kartik Agaram
6e93444ff4 6983 - tile: right-arrow can now move out of calls 2020-10-09 23:30:19 -07:00
Kartik Agaram
5ba974b4e5 6982 - right-arrow now moves into expanded calls
Rendering is still ugly. Cursor isn't on the right row. But the hard part
is behind us.

This was a stupid mistake in function-body, and it happened because I've
been getting lazy and passing (addr handle) objects when I should be passing
in "constant" addr objects.

I'm not sure why I was so resistant to debugging by print here. I spent
3 days waffling about with this bug.
2020-10-09 23:24:00 -07:00
Kartik Agaram
8c43582fb2 6981
Tile: simplify the contract for render-column.
2020-10-09 22:27:22 -07:00
Kartik Agaram
ec6221b485 6980
Changing tack..
2020-10-09 22:15:14 -07:00
Kartik Agaram
315926f732 6979
Use the fake-screen infrastructure we already have for non-interactive
mode.
2020-10-09 21:43:42 -07:00
Kartik Agaram
cb01075a2e 6978
We don't have tests yet in the tile prototype, mostly because we don't
yet feel confident about what desired behavior should be. But it's still
helpful to have a non-interactive mode for tracking down segfaults.
2020-10-09 21:25:32 -07:00
Kartik Agaram
7c6bb4d316 6977
Snapshot. We've gotten arrow keys navigating, but segfault when getting
to the second word in an expanded function call body.
2020-10-09 21:17:51 -07:00
Kartik Agaram
eb2ccccceb 6976 2020-10-09 21:10:14 -07:00
Kartik Agaram
0c465d1dcc 6975 2020-10-09 21:08:40 -07:00
Kartik Agaram
5659eccded 6974 2020-10-08 20:32:49 -07:00
Kartik Agaram
e9957c78da 6972 - tile: stop persisting cursor-word
Rather surprisingly, this transformation worked the first time!
2020-10-08 20:32:34 -07:00
Kartik Agaram
b8fd119b78 6969
Fix and cleanup.
2020-10-06 00:41:20 -07:00