diff options
author | Kartik Agaram <vc@akkartik.com> | 2018-09-22 21:56:00 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2018-09-22 22:17:09 -0700 |
commit | 2b36eee9b13eb16fb2e4b05d7e26f6d09f431912 (patch) | |
tree | 6da2091b71b7ea6928e417699641b70bc65381ee /subx/040---tests.cc | |
parent | 8c580ba1de3a6587c6c8e21387a518c93399e538 (diff) | |
download | mu-2b36eee9b13eb16fb2e4b05d7e26f6d09f431912.tar.gz |
4502 - support string literals directly in code
Doesn't de-duplicate in the data segment, though. If you use the literal "foo" a hundred times in your code segment you're gonna spend a hundred times the space you need to. We can now simplify our test harness a bit in the factorial app, but we still have to put in commandline args to compare with manually. We only support length-prefixed strings, not null-terminated ones.
Diffstat (limited to 'subx/040---tests.cc')
-rw-r--r-- | subx/040---tests.cc | 28 |
1 files changed, 5 insertions, 23 deletions
diff --git a/subx/040---tests.cc b/subx/040---tests.cc index 10356174..b0bcef38 100644 --- a/subx/040---tests.cc +++ b/subx/040---tests.cc @@ -1,14 +1,11 @@ -//: Beginning of level 3: support for automatically aggregating functions into -//: test suites. -//: -//: (As explained in the transform layer, level 3 runs before level 2. We -//: can't use any of the transforms in previous layers. But we *do* rely on -//: those concepts being present in the input. Particularly labels.) +//: Automatically aggregating functions into test suites. +//: We don't rely on any transforms running in previous layers, but this layer +//: knows about labels and will emit labels for previous layers to transform. :(after "Begin Transforms") -// Begin Level-3 Transforms +// Begin Level-4 Transforms Transform.push_back(create_test_function); -// End Level-3 Transforms +// End Level-4 Transforms :(scenario run_test) % Reg[ESP].u = 0x100; @@ -59,21 +56,6 @@ string to_string(const segment& s) { return out.str(); } -string to_string(const word& w) { - ostringstream out; - out << w.data; - for (int i = 0; i < SIZE(w.metadata); ++i) - out << '/' << w.metadata.at(i); - return out.str(); -} - -line label(string s) { - line result; - result.words.push_back(word()); - result.words.back().data = (s+":"); - return result; -} - line call(string s) { line result; result.words.push_back(call()); |