Commit Graph

200 Commits

Author SHA1 Message Date
Kartik K. Agaram
71974f15e3 2622 2015-12-13 20:01:42 -08:00
Kartik K. Agaram
ae5f0b6f6a 2478 2015-11-27 17:49:30 -08:00
Kartik K. Agaram
dc26989108 2461 2015-11-19 08:43:32 -08:00
Kartik K. Agaram
c4e7c10d15 2416 2015-11-10 16:53:21 -08:00
Kartik K. Agaram
0c0bc3aebb 2406
One new issue: the traces for all tests are perturbed by the .mu files we
choose to load.
2015-11-08 23:48:52 -08:00
Kartik K. Agaram
785a60fae9 2398 2015-11-08 14:04:57 -08:00
Kartik K. Agaram
fa8eda4594 2396 - edit working again!!
Still some spurious warnings.

This was an insane experience building out generics. Time to reflect.
Where did I go wrong? How did I end up writing no tests? Let's take some
time and go over the last 50 commits with a fine-tooth comb.

Generics seems to be the feature that has moved mu from a VM project to
a compiler project.
2015-11-08 00:10:56 -08:00
Kartik K. Agaram
6fa778b3e7 2390 - undo 2389
Ooh, I think I see a solution.
2015-11-07 19:54:38 -08:00
Kartik K. Agaram
cb0060ee0f 2389
Now we're back to trying to rerunning idempotent transforms on
specialized recipes. Still doesn't work, but at least we don't see
different results depending on whether the trace is enabled inside the
test or right at the start. That got fixed by the more disciplined
insertion into maps, looks like.
2015-11-07 13:54:49 -08:00
Kartik K. Agaram
d71d3b4aaa 2388 - final layer of edit/ loaded successfully 2015-11-07 13:33:26 -08:00
Kartik K. Agaram
795f5244ab 2377 - stop using operator[] in map
I'm still seeing all sorts of failures in turning on layer 11 of edit/,
so I'm backing away and nailing down every culprit I run into. First up:
stop accidentally inserting empty objects into maps during lookups.

Commands run:
  $ sed -i 's/\(Recipe_ordinal\|Recipe\|Type_ordinal\|Type\|Memory\)\[\([^]]*\)\] = \(.*\);/put(\1, \2, \3);/' 0[1-9]*
  $ vi 075scenario_console.cc  # manually fix up Memory[Memory[CONSOLE]]
  $ sed -i 's/\(Memory\)\[\([^]]*\)\]/get_or_insert(\1, \2)/' 0[1-9]*
  $ sed -i 's/\(Recipe_ordinal\|Type_ordinal\)\[\([^]]*\)\]/get(\1, \2)/' 0[1-9]*
  $ sed -i 's/\(Recipe\|Type\)\[\([^]]*\)\]/get(\1, \2)/' 0[1-9]*

Now mu dies pretty quickly because of all the places I try to lookup a
missing value.
2015-11-06 11:17:25 -08:00
Kartik K. Agaram
e669248264 2321 - more preparations for static dispatch
Deduce operation id from name during transform rather than load, so that
earlier transforms have a chance to modify the name.
2015-10-29 17:15:09 -07:00
Kartik K. Agaram
30277d2e37 2315 2015-10-29 12:16:00 -07:00
Kartik K. Agaram
4f10b93a6a 2314 - final tweaks to trace
I checked these commands:

  $ mu x.mu
  $ grep "===" .traces/interactive
  $ grep "===\|---" .traces/interactive
2015-10-29 12:15:03 -07:00
Kartik K. Agaram
cdd6fd0967 2313 2015-10-29 12:09:23 -07:00
Kartik K. Agaram
b2ec0969e9 2310 - add some more tracing
I've been growing lax on white-box testing when it's one of the three
big thrusts of this whole effort. Perhaps it was because I got too
obsessed with keeping traces stable and didn't notice that stable
doesn't mean "not changing". Or perhaps it's because I still don't have
a zoomable trace browser that can parse traces from disk. Or perhaps
$trace-browser is too clunky and discourages me from using it.
Regardless, I need to make the trace useable again before I work much
more on the next few rewriting transforms.
2015-10-29 11:15:13 -07:00
Kartik K. Agaram
78164bab59 2301 - test_all_layers fixes 2015-10-28 14:16:26 -07:00
Kartik K. Agaram
c6034af308 2277 - reagents now have a tree of types 2015-10-25 21:42:18 -07:00
Kartik K. Agaram
61286c8d69 2272 2015-10-19 15:53:09 -07:00
Kartik K. Agaram
77cdc6d03f 2271 - bugfix: traces cross-contaminating errors
There were several places where we push a call on to a routine without
incrementing call-stack depth, which was used to compute the depth at
which to trace an instruction. So sometimes you ended up one depth lower
than you started a call with. Do this enough times and instructions that
should be traced at level 100 end up at level 0 and pop up as errors.

Solution: since call-stack depth is only used for tracing, include it in
the trace stream and make sure we reset it along with the trace stream.
Then catch all places where we forget to increment call-stack depth and
make sure we catch such places in the future.

When I first ran into this with Caleb I thought there must be some way
that we're writing some output into the warnings result. I didn't
recognize that the spurious output as part of the trace, just at the
wrong level.
2015-10-19 15:45:55 -07:00
Kartik K. Agaram
5f98a10cc7 2258 - separate warnings from errors
At the lowest level I'm reluctantly starting to see the need for errors
that stop the program in its tracks. Only way to avoid memory corruption
and security issues. But beyond that core I still want to be as lenient
as possible at higher levels of abstraction.
2015-10-06 22:15:45 -07:00
Kartik K. Agaram
745e8bdd7a 2246 2015-10-05 18:26:04 -07:00
Kartik K. Agaram
926e1b049b 2238 - dump recipes after tangling 2015-10-04 16:25:20 -07:00
Kartik K. Agaram
4814bf94e7 2226 - standardize warning format
Always show recipe name where error occurred. But don't show internal
'interactive' name for sandboxes, that's just confusing.

What started out as warnings are now ossifying into errors that halt all
execution. Is this how things went with C and Unix as well?
2015-10-01 13:13:10 -07:00
Kartik K. Agaram
4e49b29e63 2221 2015-09-30 01:57:23 -07:00
Kartik K. Agaram
a0fc38c9e1 2218 - check types in instructions much earlier
Front-loads it a bit more than I'd like, but the payoff is that other
recipes will now be able to describe the type checks right next to their
operation.

I'm also introducing a new use of /raw with literals to indicate unsafe
typecasts.
2015-09-30 01:01:34 -07:00
Kartik K. Agaram
bb58e1797e 2214 2015-09-28 23:36:39 -07:00
Kartik K. Agaram
86a6c9cd89 2213 - start moving type checks out of 'run'
That way we only have to check each static instruction once, rather than
every time it runs.
2015-09-28 22:21:15 -07:00
Kartik K. Agaram
48b63d31d7 2209 2015-09-26 11:31:15 -07:00
Kartik K. Agaram
4082acd24f 2199 - stop printing numbers in scientific notation
Turns out the default format for printing floating point numbers is
neither 'scientific' nor 'fixed' even though those are the only two
options offered. Reading the C++ standard I found out that the default
(modulo locale changes) is basically the same as the printf "%g" format.
And "%g" is basically the shorter of:
  a) %f with trailing zeros trimmed
  b) %e
So we'll just do %f and trim trailing zeros.
2015-09-14 23:37:12 -07:00
Kartik K. Agaram
9c362f85a1 2196 2015-09-14 21:44:15 -07:00
Kartik K. Agaram
cea49fdee2 2171 - 'main' can take ingredients from the shell
Ingredients of 'main' are always strings (type address:array:character),
and are delineated from .mu files to load by a "--", e.g.:

  $ ./mu x.mu y.mu -- a b c

Here 'main' must be defined in one of x.mu and y.mu, and will receive
the ingredients "a", "b", and "c".
2015-09-06 12:25:51 -07:00
Kartik K. Agaram
e5e9f7db1c 2170 2015-09-06 11:21:50 -07:00
Kartik K. Agaram
f37eacc948 2169 2015-09-06 11:17:57 -07:00
Kartik K. Agaram
156123829c 2168 2015-09-06 11:17:22 -07:00
Kartik K. Agaram
9f78ec2d5e 2155 - mu can now load all files in a directory 2015-09-05 11:46:34 -07:00
Kartik K. Agaram
0d9d275314 2154 - check types only after loading all layers
Follow-up to 2147, which switched transform_all to only run once, after
loading all layers.
2015-09-05 11:23:20 -07:00
Kartik K. Agaram
e214de81b8 2152 - never warn about redefining main in tests 2015-09-05 11:14:25 -07:00
Kartik K. Agaram
a3481777c6 2147 - starting to split edit.mu into layers
edit.mu is now over 9k lines long. Only 2.6k of them are code. Plan:
chunk it into multiple files inside say an 'edit' directory. Then you
can run it with:

  $ mu edit/*

I also want to be able to test just a few layers:

  $ mu edit/00[1-5]*

When I try to chunk it into files, the first issue I run into is that
before/after can't refer back to previous layers. Solution:
transform_all at one shot after loading all files.
2015-09-05 09:37:32 -07:00
Kartik K. Agaram
86778aa426 2126 2015-09-01 20:29:50 -07:00
Kartik K. Agaram
6c1376f830 2095
Finally terminate the experiment of keeping debug prints around. I'm
also going to give up on maintaining counts.

What we really need is two kinds of tracing:
  a) For tests, just the domain-specific facts, organized by labels.
  b) For debugging, just transient dumps to stdout.
b) only works if stdout is clean by default.

Hmm, I think this means 'stash' should be the transient kind of trace.
2015-08-28 23:25:21 -07:00
Kartik K. Agaram
81b1975fc5 2078 - update entire screen on tb_present()
Termbox had been taking shortcuts when it thinks the screen hasn't
changed, which doesn't work if some other process messes up the screen.

The Go version has a Sync method in addition to Flush/tb_present for
precisely this eventuality. But it feels like an unnecessary
optimization given C's general speed. Just drop it altogether.

---

This took me a long time to track down, and interestingly I found myself
writing a new tracing primitive before I remembered how to selectively
trace just certain layers during manual tests. I'm scared of generating
traces not because of performance but because of the visual noise. Be
aware of this. I'm going to clean up $log now.

Maybe I should also stop using $print..
2015-08-26 01:21:41 -07:00
Kartik K. Agaram
240470163a 2052
If I try to run a single test and it triggers an error the trace gets
saved in the current directory, as if I was trying to log an interactive
run. Then when I try to rerun the test the trace tries to load as mu
code, and hilarity ensues. Just log interactive runs in .traces/ as well.
2015-08-21 10:51:02 -07:00
Kartik K. Agaram
35379c9abc 2005
Turn off profiling.
2015-08-14 22:47:27 -07:00
Kartik K. Agaram
e74a294052 2000 - stop constantly copying large arrays around 2015-08-14 21:13:49 -07:00
Kartik K. Agaram
c062021a34 1999
Still worth trying to optimize, though. Current lowest-hanging fruit:
stop having index/index-address copy entire arrays around.
2015-08-14 20:44:13 -07:00
Kartik K. Agaram
a6306a5de3 1997 2015-08-14 18:59:34 -07:00
Kartik K. Agaram
578327f182 1996 2015-08-14 18:58:38 -07:00
Kartik K. Agaram
e0551d78f1 1995 - simple profile of instruction spend
The slowness of the environment -- even for code spanning just a couple
hundred lines -- is the biggest priority right now.
2015-08-14 18:30:46 -07:00
Kartik K. Agaram
677fa104d0 1973 2015-08-10 21:19:44 -07:00
Kartik K. Agaram
6d2b1168e3 1951 - warn when copying scalars to arrays, etc. 2015-08-07 12:56:09 -07:00
Kartik K. Agaram
11312cecee 1933 - bugfix: backspace now works on right side 2015-08-04 20:55:58 -07:00
Kartik K. Agaram
cfb142b960 1923
Still iterating on the right way to handle incorrect number of
ingredients. My first idea of creating null results doesn't really work
once they're used in later instructions. Just add a warning at one place
in the run loop, but otherwise only add products when there's something
to save in them.

Undoes some work around commit 1886.
2015-08-02 22:18:19 -07:00
Kartik K. Agaram
7f402c85eb 1921 - show trace by clicking on code
Region to click on to edit is now reduced to just the menu bar for the
sandbox (excluding the 'x' for deleting the sandbox). The symmetry there
might be useful, but we'll see if the relative click area is
in line with how commonly the actions are performed.
2015-08-02 16:18:16 -07:00
Kartik K. Agaram
e140ae6382 1901
Don't swamp edit.mu with warnings when something writes to address 0.
Warn once, then keep going.
2015-07-30 19:13:57 -07:00
Kartik K. Agaram
c91caafd5b 1879 - types required at first mention of a name
That should avoid many issues with typos in names.
2015-07-28 19:34:58 -07:00
Kartik K. Agaram
bc64369276 1868 - start using naked literals everywhere
First step to reducing typing burden. Next step: inferring types.
2015-07-28 14:33:22 -07:00
Kartik K. Agaram
f78f92c58a 1863 - two bugfixes in deleting sandboxes
Forgot to show screen after delete, and 'release' events were causing
double deletions.
2015-07-28 01:04:21 -07:00
Kartik K. Agaram
35064671ef 1844 - explicitly end each trace line
More verbose, but it saves trouble when debugging; there's never
something you thought should be traced but just never came out the other
end.

Also got rid of fatal errors entirely. Everything's a warning now, and
code after a warning isn't guaranteed to run.
2015-07-25 00:02:20 -07:00
Kartik K. Agaram
93b7d98351 1830 2015-07-23 23:27:36 -07:00
Kartik K. Agaram
049fa287d6 1824 2015-07-20 23:41:28 -07:00
Kartik K. Agaram
13ba3defe9 1814 - save code in editor
Very rudimentary ability to read/write from file+version control. No
control over name.

Recipes now saved. But what to do about sandboxes?
2015-07-18 13:48:49 -07:00
Kartik K. Agaram
094548498b 1782 - stop tracing anything but warnings inside edit
Speeds up edit.mu tests by 10x, and shrinks memory usage by 100x.
We need a more efficient implementation of traces, but we can keep going
for now.

We didn't really need to reclaim memory just yet, after all. Mu is
pretty memory-efficient.
2015-07-14 15:54:39 -07:00
Kartik K. Agaram
885315fe88 1751 - sluggishness fixed
Ah, I was indeed double-rendering, but somehow it was still hard to see
the problem past that preliminary diagnosis.

Still two failing tests to fix.
2015-07-10 15:52:38 -07:00
Kartik K. Agaram
9fdda88b2e 1724 - first stab at printing interactive results 2015-07-08 14:47:12 -07:00
Kartik K. Agaram
363be37f3f 1702 - experiment: start using 'ordinal' in names
It comes up pretty early in the codebase, but hopefully won't come up
in the mu level until we get to higher-order recipes. Potentially
intimidating name, but such prime real estate with no confusing
overloadings in other projects!
2015-07-04 09:40:50 -07:00
Kartik K. Agaram
7f73795cf5 1699 - first-class recipe types
It should now be easy to do dynamic dispatch, create higher-order
functions, etc.
2015-07-03 19:38:21 -07:00
Kartik K. Agaram
2c7e84c2bc 1620
chessboard finally passing all its tests. What made this hard was that
for some reason one of the background routines in the main chessboard
test wasn't terminating like it used to. And so it was polluting *later*
tests. Just clean up that source of contamination for now. Later we'll
think about routine termination.
2015-06-22 21:16:31 -07:00
Kartik K. Agaram
45c08fea47 1616 - merging keyboard and events into 'console'
Only core layers currently passing. Console apps are probably still
broken.
2015-06-21 23:27:54 -07:00
Kartik K. Agaram
467046ef11 1614 2015-06-21 00:24:12 -07:00
Kartik K. Agaram
18429d408e 1612 2015-06-20 22:59:34 -07:00
Kartik K. Agaram
70179d1f13 1611 - switch to keyboard+mouse events 2015-06-20 22:59:27 -07:00
Kartik K. Agaram
ab6ed192b7 1585 2015-06-17 12:39:09 -07:00
Kartik K. Agaram
2dab0edbbd 1582 2015-06-17 01:22:25 -07:00
Kartik K. Agaram
a7d7073512 1581 2015-06-17 00:57:27 -07:00
Kartik K. Agaram
1066660e66 1523
Variable 'instruction_counter' was obfuscating more than it clarified.
2015-06-03 18:00:11 -07:00
Kartik K. Agaram
87fbfc2d46 1518 - still horribly broken
Just figured out why a first keystroke of backspace was sending me out
for a spin: run_interactive needs all early exits that don't actually
run anything to increment the current_step_index(). FML, this is lousy..
2015-06-01 00:11:31 -07:00
Kartik K. Agaram
7feea75b13 1417 - draft zoom levels in traces 2015-05-21 18:57:25 -07:00
Kartik K. Agaram
d7494165ec 1414 - traces now robust to new recipes/types 2015-05-21 13:00:42 -07:00
Kartik K. Agaram
6152ef13a8 1399 - better 'unknown type' warnings
Implement warnings for types without definitions without constraining
where type definitions must appear.

We also eliminate the anti-pattern where a change in layer 10 had its
test in layer 11 (commit 1383).
2015-05-18 18:40:58 -07:00
Kartik K. Agaram
ac0e9db526 1391 - avoid unsigned integers 2015-05-17 02:22:41 -07:00
Kartik K. Agaram
b142a76202 1383 - warn on unknown type
This bit me in the last commit for the first time.

Layer 010vm.cc is starting to look weird. It has references to stuff
that gets implemented much later, like containers and exclusive
containers. Its helpers are getting an increasing amount of logic. And
it has no tests.

I'm still inclined to think it's useful to have major data structures in
one place, even if they aren't used for a bit. But those helpers should
perhaps move out somehow or get some tests in the same layer.
2015-05-16 13:17:36 -07:00
Kartik K. Agaram
8e41a2b8e5 1374 - chessboard end-to-end test passes!
After like 40 seconds (because of the 120-column screen), but whatever.

The final bug was that clear-screen wasn't actually working right for
fake screens.

(The trace is too large for github, so I'm going to leave it out for
now.)
2015-05-14 16:03:08 -07:00
Kartik K. Agaram
b98d3876b6 1367 2015-05-14 10:30:01 -07:00
Kartik K. Agaram
5497090aa1 1363 - rename 'integer' to 'number'
..now that we support non-integers.
2015-05-13 10:03:26 -07:00
Kartik K. Agaram
fca0ebbe0c 1360 - store doubles in memory
This is a far cleaner way to provide *some* floating-point support. We
can only represent signed integers up to 2^51 rather than 2^63. But in
exchange we don't have to worry about it elsewhere, and it's probably
faster than checking tag bits in every operation.

Hmm, yeah, surprised how easy this was. I think I'll give up on the
other approach.

I still don't have non-integer literals. But we won't bother with those
until we need them. `3.14159:literal` seems ugly.
2015-05-12 18:08:47 -07:00
Kartik K. Agaram
98f3a94201 1359 2015-05-12 17:52:26 -07:00
Kartik K. Agaram
827898fc1b 1357 - temporarily revert floating-point support 2015-05-12 17:10:33 -07:00
Kartik K. Agaram
3663ca6c2d 1356 - snapshot #2: floating point support
I added one test to check that divide can return a float, then hacked at
the rippling failures across the entire entire codebase until all tests
pass. Now I need to look at the changes I made and see if there's a
system to them, identify other places that I missed, and figure out the
best way to cover all cases. I also need to show real rather than
encoded values in the traces, but I can't use value() inside reagent
methods because of the name clash with the member variable. So let's
take a snapshot before we attempt any refactoring. This was non-trivial
to get right.

Even if I convince myself that I've gotten it right, I might back this
all out if I can't easily *persuade others* that I've gotten it right.
2015-05-12 17:00:19 -07:00
Kartik K. Agaram
9131db6eda 1352 2015-05-12 00:15:51 -07:00
Kartik K. Agaram
bb8a644b82 1346
On my ubuntu 14.04.1 + gcc 4.8.2 machine, ifstream doesn't actually
raise an error on trying to open a non-existent file until you try to do
something with it. Garbage!
2015-05-11 12:22:32 -07:00
Kartik K. Agaram
4071055aee 1327 - better error handling in chessboard
Also a bugfix in break to label, because I noticed the screen wasn't
being cleaned up on quit.
2015-05-10 11:40:33 -07:00
Kartik K. Agaram
a1dcc02fe5 1302 2015-05-07 19:15:51 -07:00
Kartik K. Agaram
9d670bb58f 1301 - back to the chessboard
Still need a nice syntax for managing the routine under test.
2015-05-07 19:05:23 -07:00
Kartik K. Agaram
05d177737c 1299 - stop using [] in any vector
Useful check:

  $ grep "[^ '\"]\[[^\"]" *.cc \
    |perl -pwe 's/\Wargv\[|\WTests\[|\Wframe\[|\WMemory\[|\WName\[|\WSurrounding_space\[|\WRecipe\[|\WType\[|\WRecipe_number\[|\WType_number\[|\WBefore_fragments\[|\WAfter_fragments\[//g' \
    |perl -pwe 's/\Wargv\[|\WTests\[|\Wframe\[|\WMemory\[|\WName\[|\WSurrounding_space\[|\WRecipe\[|\WType\[|\WRecipe_number\[|\WType_number\[|\WBefore_fragments\[|\WAfter_fragments\[//g' \
    |grep '[^ ]\['
2015-05-07 15:49:40 -07:00
Kartik K. Agaram
0487a30e70 1298 - better ingredient/product handling
All primitives now always write to all their products. If a product is
not used that's fine, but if an instruction seems to expect too many
products mu will complain.

In the process, many primitives can operate on more than two ingredients
where it seems intuitive. You can add or divide more than two numbers
together, copy or negate multiple corresponding locations, etc.

There's one remaining bit of ugliness. Some instructions like
get/get-address, index/index-address, wait-for-location, these can
unnecessarily load values from memory when they don't need to.

Useful vim commands:
  %s/ingredients\[\([^\]]*\)\]/ingredients.at(\1)/gc
  %s/products\[\([^\]]*\)\]/products.at(\1)/gc
  .,$s/\[\(.\)]/.at(\1)/gc
2015-05-07 15:29:13 -07:00
Kartik K. Agaram
8833d01ccf 1296 - roll back 1295 2015-05-07 12:47:13 -07:00
Kartik K. Agaram
1179f0d456 1295 - broken snapshot
I spent a couple of hours debugging this because routine-state only
sometimes writes to its product. This is unacceptable. Fix this first.
2015-05-07 10:38:19 -07:00
Kartik K. Agaram
768bdb4dbf 1293 - start porting the chessboard app over
Just to put all our new test primitives through their paces, and iron
out any kinks.

Just the one chessboard scenario is taking 1.5-2.5x all the tests we've
written so far. But we're starting from a faster baseline, that was the
point of the C++ port. I also have -O3 optimizations in my back-pocket.
2015-05-06 12:15:25 -07:00
Kartik K. Agaram
b96af395b9 1276 - make C++ version the default
I've tried to update the Readme, but there are at least a couple of issues.
2015-05-05 21:17:24 -07:00