Commit Graph

38 Commits

Author SHA1 Message Date
Kartik K. Agaram c0db806820 . 2021-07-19 19:46:04 -07:00
Kartik K. Agaram 542773df2f render functions in MRU order 2021-07-19 15:39:36 -07:00
Kartik K. Agaram 76ef912eb2 all tests passing again; infix seems done 2021-06-22 23:39:54 -07:00
Kartik K. Agaram f5e55cbbdb . 2021-06-22 21:57:47 -07:00
Kartik K. Agaram 0436ab71ea clean up lexical categories 2021-06-22 21:43:44 -07:00
Kartik K. Agaram 26e9387df6 snapshot: infix
Like parenthesize, I'm copying tests over from https://github.com/akkartik/wart
Unlike parenthesize, though, I can't just transliterate the code itself.
Wart was operating on an intermediate AST representation. Here I'm all
the way down to cells. That seemed like a good idea when I embarked, but
now I'm not so sure. Operating with the right AST data structure allowed
me to more easily iterate over the elements of a list. The natural recursion
for cells is not a good fit.

This patch and the next couple is an interesting case study in what makes
Unix so effective. Yes, you have to play computer, and yes it gets verbose
and ugly. But just diff and patch go surprisingly far in helping build a
picture of the state space in my brain.

Then again, there's a steep gradient of skills here. There are people who
can visualize state spaces using diff and patch far better than me, and
people who can't do it as well as me. Nature, nurture, having different
priorities, whatever the reason. Giving some people just the right crutch
excludes others.
2021-06-22 21:23:40 -07:00
Kartik K. Agaram 6e1aa99a00 start guessing parentheses based on indentation 2021-06-20 21:18:38 -07:00
Kartik K. Agaram 9d7d99fe6c snapshot
This is going better than expected; just 3 failing tests among the new
ones.
2021-06-20 20:36:47 -07:00
Kartik K. Agaram 29795a0db4 start emitting indent tokens 2021-06-18 21:42:01 -07:00
Kartik K. Agaram e5cf570890 redo next-token in more high-level terms 2021-06-18 20:39:33 -07:00
Kartik K. Agaram 6169ec59c0 make tests pass again
I'm temporarily disabling the pending state. I'm also providing a clearer
error message when we encounter the bug.
2021-06-09 16:05:09 -07:00
Kartik K. Agaram b7e8c2810a snapshot: attempt at modifying a function name
It turns out there's another problem, and it predates the ability to create
new definitions:

  ctrl-s triggers a call to `evaluate`, which inserts a new definition
  into globals. which has a null gap buffer.

All this happens long before the new code in this commit, resulting in a
null gap buffer by the time we get to word-at-cursor.

Which in turn happens because we perform a raw `evaluate`, which doesn't
update the gap buffer like `run` does (using `maybe-stash-gap-buffer-to-global`).

And arguably `evaluate` shouldn't mess with the gap buffer. Gap buffers
are a UI concern.

The hardest version of this immediate scenario: It's unclear how to guarantee
that every definition have a gap buffer, when two definitions may share
one (closures sharing a lexical environment).

New plan:
  - improve the logic for detecting definitions. Looking at the outermost
    layer isn't enough. And a single expression can create multiple definitions.
  - extract a helper to attach a single gap buffer to multiple definitions.
  - have the UI detect conflicts in gap buffers and prompt the user for
    a decision if a different gap buffer already exists for a definition.
2021-06-09 09:16:52 -07:00
Kartik K. Agaram 67aeff8934 .
I wrote a comment about how some code was not covered by tests, and then
promptly forgot what it was for. This is why we need tests.

Now the hack is gone.
2021-06-08 15:06:08 -07:00
Kartik K. Agaram 3d4e1b8b28 working on jumping to word at cursor
I had a nice clean definition for word-at-cursor, but it's wrong and I'm
going to have to mangle it.
2021-06-05 09:35:37 -07:00
Kartik K. Agaram bd49d5c35c shell: more stable trace when rerunning 2021-06-02 23:57:23 -07:00
Kartik K. Agaram 888b4cd8ea always check for null in 'index' instructions 2021-05-07 21:04:45 -07:00
Kartik K. Agaram 8482d5d7b4 . 2021-05-03 20:39:49 -07:00
Kartik K. Agaram 4541bfa59b extremely threadbare null-pointer protection
This protects us from reading null arrays, but not null structs.
It also doesn't protect us from writes to address 0 itself.

It is also incredibly unsafe. According to https://wiki.osdev.org/Memory_Map_(x86),
address 0 contains the real-mode IVT. Am I sure it'll never ever get used
after I switch to protected mode? I really need a page table, something
minimal to protect the first 4KB of physical memory or something.

I wonder what other languages/OSs do to protect against really large struct
definitions.
2021-04-28 22:22:55 -07:00
Kartik K. Agaram 5c5bca9df5 re-enable tests
Disabled in commit 1354161a3, and then I forgot about them for a while.
2021-04-18 23:26:38 -07:00
Kartik K. Agaram 1354161a36 tmp: debugging why brline prints no pixels
Among other things, we turned off the trace to significantly speed up the
debug cycle.

State as of https://merveilles.town/@akkartik/106079258606146213

Ohhh, as I save the commit I notice a big problem: I've been editing the
disk image directly because writes to the Mu disk lose indentation. But
I've been forgetting that the state in the Mu disk needs to be pre-evaluated.
So function bindings need extra parens for the environment. The `pixel`
calls in the previous commit message are the first statement in the body,
and they aren't actually considered part of the body right now. No wonder
they don't run.

There are lots of other problems, but this will clarify a lot.
2021-04-17 08:34:48 -07:00
Kartik K. Agaram 1d724f9260 shell: structural equality check
Mu can now compute (factorial 5)
2021-04-09 22:51:24 -07:00
Kartik K. Agaram 7bf8adb893 explicitly pass data disk to main 2021-03-27 17:50:44 -07:00
Kartik K. Agaram 1a43d12b15 explicitly pass screen and keyboard to main 2021-03-26 23:07:35 -07:00
Kartik K. Agaram e6b42204ef shell: read initial expression from secondary disk
See shell/README.md for (extremely klunky) instructions.
2021-03-21 23:10:55 -07:00
Kartik K. Agaram fba2146593 snapshot: reading from disk without BIOS!!
Both LBA and CHS coordinates are now working for the primary disk on the
primary bus.

Failure modes I ran into:
  - ATA ports are 16-bit values. Using instructions with 8-bit immediates
    will yield strange results. (I had to debug this twice because I missed
    poll-ata-primary-bus-primary-drive-regular-status-word the first time
    around.)

    Mu's toolchain has been found out here. bootstrap has good
    errors but doesn't support the instructions I need in boot.subx. The
    self-hosted phases support the instructions but provide no error-checking.
    Might be worth starting to add error-checking as I encounter the need.
    In this case, a vote for validating metadata sizes even if we don't
    validate that instructions pass in the right metadata sizes.

  - Can't poll readiness first thing. Maybe we need to always select the
    drive first.

  - Reading 8-bit values from a 16-bit port (data port 0x1f0) returns garbage.
    Reading 32-bit values however works totally fine; go figure. (Maybe
    it won't work on real hardware?)

    https://forum.osdev.org/viewtopic.php?t=36415

  - Passing in a 0 segment will never return data.
2021-03-21 22:29:24 -07:00
Kartik K. Agaram 341f0c59be . 2021-03-15 20:41:13 -07:00
Kartik K. Agaram 460528e85b reintroduce Entry label 2021-03-15 20:41:13 -07:00
Kartik K. Agaram 2d306e2a98 7846 2021-03-04 00:11:23 -08:00
Kartik K. Agaram 71e4f38129 7842 - new directory organization
Baremetal is now the default build target and therefore has its sources
at the top-level. Baremetal programs build using the phase-2 Mu toolchain
that requires a Linux kernel. This phase-2 codebase which used to be at
the top-level is now under the linux/ directory. Finally, the phase-2 toolchain,
while self-hosting, has a way to bootstrap from a C implementation, which
is now stored in linux/bootstrap. The bootstrap C implementation uses some
literate programming tools that are now in linux/bootstrap/tools.

So the whole thing has gotten inverted. Each directory should build one
artifact and include the main sources (along with standard library). Tools
used for building it are relegated to sub-directories, even though those
tools are often useful in their own right, and have had lots of interesting
programs written using them.

A couple of things have gotten dropped in this process:
  - I had old ways to run on just a Linux kernel, or with a Soso kernel.
    No more.
  - I had some old tooling for running a single test at the cursor. I haven't
    used that lately. Maybe I'll bring it back one day.

The reorg isn't done yet. Still to do:
  - redo documentation everywhere. All the README files, all other markdown,
    particularly vocabulary.md.
  - clean up how-to-run comments at the start of programs everywhere
  - rethink what to do with the html/ directory. Do we even want to keep
    supporting it?

In spite of these shortcomings, all the scripts at the top-level, linux/
and linux/bootstrap are working. The names of the scripts also feel reasonable.
This is a good milestone to take stock at.
2021-03-03 22:21:03 -08:00
Kartik Agaram 8d2dece291 7250 2020-11-16 00:00:32 -08:00
Kartik Agaram 66daf3cc1f 6720 2020-08-22 10:14:37 -07:00
Kartik Agaram 4d14c3fefd 6393 - start running .mu apps in CI 2020-05-24 20:36:31 -07:00
Kartik Agaram 546a92985f start migrating handles to fat pointers
CI will fail from this commit onward. Currently working:
  $ bootstrap translate init.linux 0[4-7]*.subx 080zero-out.subx -o a.elf  &&  ./a.elf test
  $ bootstrap run a.elf test
  $ chmod +x a.elf;  ./a.elf test

Plan: migrate functions that used to return handles to pass in a new arg
of type (addr handle). That's a bit of a weird type. There should be few
of these functions. (Open question: do we even want to expose this type
in the Mu language?)

Functions that just need to read from heap without modifying the handle
will receive `(addr T)` or `(handle T)` types as arguments.

As I sanitize each new file, I need to update signatures for any new functions
and add them to a list. I also need to update calls to any functions on
the list.
2020-05-18 00:44:46 -07:00
Kartik Agaram c48ce3c8bf 6153 - switch 'main' to use Mu strings
At the SubX level we have to put up with null-terminated kernel strings
for commandline args. But so far we haven't done much with them. Rather
than try to support them we'll just convert them transparently to standard
length-prefixed strings.

In the process I realized that it's not quite right to treat the combination
of argc and argv as an array of kernel strings. Argc counts the number
of elements, whereas the length of an array is usually denominated in bytes.
2020-03-15 21:03:12 -07:00
Kartik Agaram 65eb2a5714 6007 2020-02-14 01:57:37 -08:00
Kartik Agaram 5946a64453 6006 2020-02-14 01:57:30 -08:00
Kartik Agaram 71eb22a5bf 5924 2020-01-27 00:36:44 -08:00
Kartik Agaram 7ca19e4e1d 5850 - driver script for translating Mu programs 2020-01-01 16:35:02 -08:00