about summary refs log tree commit diff stats
path: root/030container.cc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2015-10-07 10:20:56 -0700
committerKartik K. Agaram <vc@akkartik.com>2015-10-07 10:20:56 -0700
commit538831ed8a41bdf76684dda1cfc645a26788b288 (patch)
tree7917e8f2ab6f0adeb8355a3b6e765da874948d19 /030container.cc
parentadf16b94b89171bf3b06e1cc802a6d2f71d52d61 (diff)
downloadmu-538831ed8a41bdf76684dda1cfc645a26788b288.tar.gz
2266 - drop experiment with generics
Diffstat (limited to '030container.cc')
-rw-r--r--030container.cc124
1 files changed, 0 insertions, 124 deletions
diff --git a/030container.cc b/030container.cc
index a0b214a0..0c893fbc 100644
--- a/030container.cc
+++ b/030container.cc
@@ -597,127 +597,3 @@ recipe main [
 ]
 +mem: storing 3 in location 1
 +mem: storing 4 in location 2
-
-//:: Container definitions can contain type parameters.
-
-:(scenario size_of_generic_container)
-container foo [
-  t <- next-type
-  x:t
-  y:number
-]
-recipe main [
-  1:foo:number <- merge 12, 13
-  3:foo:point <- merge 14, 15, 16
-]
-+mem: storing 12 in location 1
-+mem: storing 13 in location 2
-+mem: storing 14 in location 3
-+mem: storing 15 in location 4
-+mem: storing 16 in location 5
-
-:(before "End Globals")
-// We'll use large type ordinals to mean "the following type of the variable".
-const int FINAL_TYPE_ORDINAL = 2000;
-:(before "End Test Run Initialization")
-assert(Next_type_ordinal < FINAL_TYPE_ORDINAL);
-
-:(before "End type_info Fields")
-map<string, type_ordinal> ingredient_names;
-
-:(after "End insert_container Special Definitions(element)")
-// check for type ingredients
-if (element.find(':') == string::npos) {
-  // no type; we're defining a generic variable
-  if (next_word(in) != "<-") {
-    raise_error << "Element " << element << " of container " << name << " doesn't provide a type.\n" << end();
-    break;
-  }
-  if (next_word(in) != "next-type") {
-    raise_error << "Type " << element << " of container " << name << " must be defined using 'next-type'\n" << end();
-    break;
-  }
-  type_ordinal next_type_ordinal = SIZE(info.ingredient_names);
-  info.ingredient_names[element] = FINAL_TYPE_ORDINAL + next_type_ordinal;
-  continue;
-}
-
-:(before "End insert_container Special Uses(type_name)")
-// check for use of type ingredients
-if (info.ingredient_names.find(type_name) != info.ingredient_names.end()) {
-  types.push_back(info.ingredient_names[type_name]);
-  trace("parse") << "  type: " << types.back() << end();
-  continue;
-}
-
-:(before "End Container Type Checks")
-if (info.elements.at(i).at(j) >= FINAL_TYPE_ORDINAL
-    && (info.elements.at(i).at(j) - FINAL_TYPE_ORDINAL) < SIZE(info.ingredient_names)) continue;
-
-:(before "End size_of(type) Container Cases")
-if (t.elements.at(i).at(0) >= FINAL_TYPE_ORDINAL) {
-  result += size_of_ingredient(t, i, types);
-  continue;
-}
-
-:(code)
-// generic version of size_of
-long long int size_of_ingredient(const type_info& container_info, long long int element_index, vector<type_ordinal> full_type) {
-  // todo: generics inside generics
-  vector<long long int> subtype;
-  subtype.push_back(full_type.at(/*hack: assumes container is at index 0*/1
-                                 + container_info.elements.at(element_index).at(0)-FINAL_TYPE_ORDINAL));
-  return size_of(subtype);
-}
-
-:(scenario get_on_generic_container)
-container foo [
-  t <- next-type
-  x:t
-  y:number
-]
-recipe main [
-  1:foo:point <- merge 14, 15, 16
-  2:number <- get 1:foo:point, 1:offset
-]
-+mem: storing 16 in location 2
-
-:(before "End GET field Cases")
-if (Type[base_type].elements.at(i).at(0) >= FINAL_TYPE_ORDINAL) {
-  src += size_of_ingredient(Type[base_type], i, base.types);
-  continue;
-}
-
-:(scenario get_address_on_generic_container)
-container foo [
-  t <- next-type
-  x:t
-  y:number
-]
-recipe main [
-  10:foo:point <- merge 14, 15, 16
-  1:address:number <- get-address 10:foo:point, 1:offset
-]
-+mem: storing 12 in location 1
-
-:(before "End GET_ADDRESS field Cases")
-if (Type[base_type].elements.at(i).at(0) >= FINAL_TYPE_ORDINAL) {
-  result += size_of_ingredient(Type[base_type], i, base.types);
-  continue;
-}
-
-:(scenario get_on_generic_container_inside_generic_container)
-container foo [
-  t <- next-type
-  x:t
-  y:number
-]
-container bar [
-  x:foo:point
-  y:number
-]
-recipe main [
-  1:bar <- merge 14, 15, 16, 17
-  2:number <- get 1:bar, 1:offset
-]
-+mem: storing 17 in location 2