about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--cpp/.traces/run25
-rw-r--r--cpp/.traces/run_multiple47
-rw-r--r--cpp/049scenario_helpers.cc44
3 files changed, 116 insertions, 0 deletions
diff --git a/cpp/.traces/run b/cpp/.traces/run
new file mode 100644
index 00000000..6d7b4d41
--- /dev/null
+++ b/cpp/.traces/run
@@ -0,0 +1,25 @@
+parse/0: instruction: run
+parse/0:   ingredient: {name: "
+    1:integer <- copy 13:literal
+  ", value: 0, type: 0, properties: ["
+    1:integer <- copy 13:literal
+  ": "literal-string"]}
+after-brace/0: recipe main
+after-brace/0: run ...
+new/0: routine allocated memory from 1000 to 101000
+schedule/0: main
+run/0: instruction main/0
+run/0: run {name: "
+    1:integer <- copy 13:literal
+  ", value: 0, type: 0, properties: ["
+    1:integer <- copy 13:literal
+  ": "literal-string"]}
+parse/0: instruction: copy
+parse/0:   ingredient: {name: "13", value: 0, type: 0, properties: ["13": "literal"]}
+parse/0:   product: {name: "1", value: 0, type: 1, properties: ["1": "integer"]}
+after-brace/0: recipe tmp0
+after-brace/0: copy ...
+run/0: instruction tmp0/0
+run/0: {name: "1", value: 1, type: 1, properties: ["1": "integer"]} <- copy {name: "13", value: 13, type: 0, properties: ["13": "literal"]}
+run/0: ingredient 0 is 13
+mem/0: storing 13 in location 1
diff --git a/cpp/.traces/run_multiple b/cpp/.traces/run_multiple
new file mode 100644
index 00000000..9da9ba0a
--- /dev/null
+++ b/cpp/.traces/run_multiple
@@ -0,0 +1,47 @@
+parse/0: instruction: run
+parse/0:   ingredient: {name: "
+    1:integer <- copy 13:literal
+  ", value: 0, type: 0, properties: ["
+    1:integer <- copy 13:literal
+  ": "literal-string"]}
+parse/0: instruction: run
+parse/0:   ingredient: {name: "
+    2:integer <- copy 13:literal
+  ", value: 0, type: 0, properties: ["
+    2:integer <- copy 13:literal
+  ": "literal-string"]}
+after-brace/0: recipe main
+after-brace/0: run ...
+after-brace/0: run ...
+new/0: routine allocated memory from 1000 to 101000
+schedule/0: main
+run/0: instruction main/0
+run/0: run {name: "
+    1:integer <- copy 13:literal
+  ", value: 0, type: 0, properties: ["
+    1:integer <- copy 13:literal
+  ": "literal-string"]}
+parse/0: instruction: copy
+parse/0:   ingredient: {name: "13", value: 0, type: 0, properties: ["13": "literal"]}
+parse/0:   product: {name: "1", value: 0, type: 1, properties: ["1": "integer"]}
+after-brace/0: recipe tmp0
+after-brace/0: copy ...
+run/0: instruction tmp0/0
+run/0: {name: "1", value: 1, type: 1, properties: ["1": "integer"]} <- copy {name: "13", value: 13, type: 0, properties: ["13": "literal"]}
+run/0: ingredient 0 is 13
+mem/0: storing 13 in location 1
+run/0: instruction main/1
+run/0: run {name: "
+    2:integer <- copy 13:literal
+  ", value: 0, type: 0, properties: ["
+    2:integer <- copy 13:literal
+  ": "literal-string"]}
+parse/0: instruction: copy
+parse/0:   ingredient: {name: "13", value: 0, type: 0, properties: ["13": "literal"]}
+parse/0:   product: {name: "2", value: 0, type: 1, properties: ["2": "integer"]}
+after-brace/0: recipe tmp1
+after-brace/0: copy ...
+run/0: instruction tmp1/0
+run/0: {name: "2", value: 2, type: 1, properties: ["2": "integer"]} <- copy {name: "13", value: 13, type: 0, properties: ["13": "literal"]}
+run/0: ingredient 0 is 13
+mem/0: storing 13 in location 2
diff --git a/cpp/049scenario_helpers.cc b/cpp/049scenario_helpers.cc
new file mode 100644
index 00000000..8234c21f
--- /dev/null
+++ b/cpp/049scenario_helpers.cc
@@ -0,0 +1,44 @@
+//: Some pseudo-primitives to support writing tests in mu.
+//: When we throw out the C layer these will require more work.
+
+:(scenario run)
+#? % Trace_stream->dump_layer = "all";
+recipe main [
+  run [
+    1:integer <- copy 13:literal
+  ]
+]
++mem: storing 13 in location 1
+
+:(before "End Globals")
+size_t Num_temporary_recipes = 0;
+:(before "End Setup")
+Num_temporary_recipes = 0;
+
+:(before "End Primitive Recipe Declarations")
+RUN,
+:(before "End Primitive Recipe Numbers")
+Recipe_number["run"] = RUN;
+:(before "End Primitive Recipe Implementations")
+case RUN: {
+//?   cout << "recipe " << current_instruction().ingredients[0].name << '\n'; //? 1
+  ostringstream tmp;
+  tmp << "recipe tmp" << Num_temporary_recipes++ << " [ " << current_instruction().ingredients[0].name << " ]";
+  vector<recipe_number> tmp_recipe = load(tmp.str());
+  transform_all();
+//?   cout << tmp_recipe[0] << ' ' << Recipe_number["main"] << '\n'; //? 1
+  Current_routine->calls.push(call(tmp_recipe[0]));
+  continue;  // not done with caller; don't increment current_step_index()
+}
+
+:(scenario run_multiple)
+recipe main [
+  run [
+    1:integer <- copy 13:literal
+  ]
+  run [
+    2:integer <- copy 13:literal
+  ]
+]
++mem: storing 13 in location 1
++mem: storing 13 in location 2
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540