about summary refs log tree commit diff stats
path: root/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp')
-rw-r--r--cpp/002main.cc141
-rw-r--r--cpp/boot.cc3
2 files changed, 134 insertions, 10 deletions
diff --git a/cpp/002main.cc b/cpp/002main.cc
index 2f9e614c..7aac3d6b 100644
--- a/cpp/002main.cc
+++ b/cpp/002main.cc
@@ -1,14 +1,119 @@
-int main(int argc, const char* argv[]) {
-  if (argc == 2 && string(argv[1]) == "test") {
-    run_tests();
-    return 0;
-  }
+enum recipe_number {
+  // arithmetic
+  add = 1,
+  subtract,
+  multiply,
+  divide,
+  divide_with_remainder,
 
-  for (int i = 1; i < argc; ++i) {
-    load(argv[i]);
-  }
-  run("main");
-}
+  // boolean
+  conjunction,  // 'and' is a keyword
+  disjunction,  // 'or' is a keyword
+  negation,  // 'not' is a keyword
+
+  // comparison
+  equal,
+  not_equal,
+  less_than,
+  greater_than,
+  lesser_or_equal,
+  greater_or_equal,
+
+  // control flow
+  jump,
+  jump_if,
+  jump_unless,
+
+  // data management: scalars, arrays, and_records (structs)
+  copy,
+  get,
+  get_address,
+  index,
+  index_address,
+  allocate,
+  size,
+  length,
+
+  // tagged_values require one primitive
+  save_type,
+
+  // code points for characters
+  character_to_integer,
+  integer_to_character,
+
+  // multiprocessing
+  fork,
+  fork_helper,
+  sleep,
+  assert,
+  assert_false,
+
+  // cursor-based (text mode) interaction
+  cursor_mode,
+  retro_mode,
+  clear_host_screen,
+  clear_line_on_host,
+  cursor_on_host,
+  cursor_on_host_to_next_line,
+  cursor_up_on_host,
+  cursor_down_on_host,
+  cursor_right_on_host,
+  cursor_left_on_host,
+  print_character_to_host,
+  read_key_from_host,
+
+  // debugging aides
+  _dump_memory,
+  _dump_trace,
+  _start_tracing,
+  _stop_tracing,
+  _dump_routine,
+  _dump_channel,
+  _quit,
+  _wait_for_key_from_host,
+  _print,
+
+  // first-class continuations
+  current_continuation,
+  continue_from,
+
+  // user-defined functions
+  next_input,
+  input,
+  prepare_reply,
+  reply,
+
+  Max_primitive_recipe,
+};
+
+struct property {
+  vector<string> values;
+};
+
+typedef int type_number;
+
+struct type_info {
+  int size;
+  bool is_address;
+  bool is_record;
+  bool is_array;
+  vector<type_number> target;  // only if is_address
+  vector<vector<type_number> > elements;  // only if is_record or is_array
+};
+
+unordered_map<type_number, type_info> type;
+
+struct reagent {
+  string name;
+  vector<type_number> types;
+  vector<pair<string, property> > properties;
+};
+
+struct instruction {
+  recipe_number op;
+  vector<reagent> ingredients;
+  vector<reagent> products;
+};
 
 void load(const char* filename) {
 }
@@ -54,3 +159,19 @@ string time_string() {
     return "";
   return buffer;
 }
+
+}  // end namespace mu
+
+int main(int argc, const char* argv[]) {
+  if (argc == 2 && string(argv[1]) == "test") {
+    mu::run_tests();
+    return 0;
+  }
+
+  for (int i = 1; i < argc; ++i) {
+    mu::load(argv[i]);
+  }
+  mu::run("main");
+}
+
+namespace mu {
diff --git a/cpp/boot.cc b/cpp/boot.cc
index 89f943a8..64a0c58e 100644
--- a/cpp/boot.cc
+++ b/cpp/boot.cc
@@ -49,6 +49,7 @@ using std::ofstream;
 
 
 // interpreter decls
+namespace mu {
 
 #include "type_list"
 
@@ -61,3 +62,5 @@ using std::ofstream;
 // interpreter tests
 
 #include "test_file_list"
+
+}  // namespace mu