summary refs log tree commit diff stats
path: root/web/news.txt
Commit message (Expand)AuthorAgeFilesLines
* bugfixes; added events module, sequtils moduleAraq2011-07-261-0/+2
* old pointer deref operator completely removedAraq2011-07-231-0/+2
* bugfix: proper cache for generic instantiationsAraq2011-07-211-2/+20
* first steps to explicit channels for thread communication; added mainThreadIdAraq2011-07-161-1/+3
* 0.8.12 bugfix: some files not in download packageAraq2011-07-111-1/+20
* preparations for 0.8.12Araq2011-07-101-21/+40
* bugfix: 'set' overloadable; further steps for multi threading supportAraq2011-07-081-0/+1
* improvements to get code size down for programs that don't use GCAraq2011-06-261-1/+1
* code gen bugfixes; marshal.nim implementedAraq2011-06-261-3/+7
* zipfiles compiles again; added system.shallowCopyAraq2011-06-201-1/+2
* case branches support constant sets for convenienceAraq2011-06-191-0/+2
* got rid of unsound co/contravariance in procvarsAraq2011-06-171-0/+1
* readFile raises EIO instead of returning nil; added system.writeFileAraq2011-06-161-1/+4
* added encodings stdlibAraq2011-06-161-0/+1
* tuple unpacking is not enforced in for loops anymoreAraq2011-06-151-0/+1
* bugfix: endless loop in parser; added sphinx wrapperAraq2011-06-141-0/+1
* intsets are now a proper module and part of the stdlibAraq2011-06-141-0/+1
* basic generic collections implemented and testedAraq2011-06-071-0/+3
* threads clean up their heapAraq2011-06-041-0/+2
* first steps to thread local heapsAraq2011-06-021-1/+3
* further steps for thread support; bootstrapping should require unzip C source...Araq2011-05-161-0/+1
* deprecated system.copy: use system.substr insteadAraq2011-05-141-0/+1
* newStringOfCap implemented and used to optimize some procsAraq2011-05-081-1/+2
* C source regeneratedAraq2011-04-241-0/+2
* hashtables: 1st version; parseutils additionsAraq2011-04-181-0/+1
* p[] instead of p^Araq2011-04-111-0/+4
* added another system.open; bugfix: koch clean may not break .git dirs anymoreAraq2011-04-031-1/+2
* added 'reset' news entry; fixed #23Araq2011-03-251-0/+1
* bugfixes; field discriminant checks; linearScanEnd, unroll, shallow pragmasAraq2011-03-231-1/+1
* linearScanEnd pragma; string case statement optimizationAraq2011-03-141-1/+5
* distinction between re.replace and re.replacef; speed improvements for re moduleAraq2011-03-061-1/+2
* tests themselves contain the expected resultAraq2011-02-201-0/+2
* REPL improvementsAraq2011-02-131-4/+4
* non-nil AST; continue after errors for IDE supportAraq2011-02-121-0/+1
* changed handling of generalized string literalsAraq2011-02-071-0/+2
* nimgrep --ext supportAraq2011-02-021-0/+4
* nimgrep: first working versionAraq2011-02-021-0/+1
* unary <; countup two type parameters; --recursivePath should work nowAraq2011-01-291-2/+3
* changes to threads; --recursivePath supportAraq2011-01-291-1/+3
* basic thread support; still broken on Windows; untested on Mac OS XAraq2011-01-181-0/+1
* explicit indices in array literalsAraq2011-01-161-0/+2
* Feature: explicit string representation for enum fieldsAraq2011-01-111-0/+11
* bugfix: floating point precision; added strutils.formatFloatAraq2011-01-091-0/+3
* additions to complex moduleAraq2011-01-071-0/+1
* implemented 'emit' pragmaAraq2011-01-071-1/+2
* added test tmultim4.nimAraq2011-01-061-0/+1
* better tester; yet another iterator bugfixAraq2011-01-061-0/+2
* bugfix: multiple yield statements and loop body varsAraq2010-12-131-1/+3
* added strutils.alignAraq2010-12-071-0/+1
* docgen understands and ignores *when false*Araq2010-11-181-4/+5
artik.com> 2015-05-13 10:03:26 -0700 committer Kartik K. Agaram <vc@akkartik.com> 2015-05-13 10:03:26 -0700 1363 - rename 'integer' to 'number'' href='/akkartik/mu/commit/034exclusive_container.cc?h=hlt&id=5497090aa1e708c22cd240913a53dda32bb067aa'>5497090a ^
afa42503 ^
dd994cda ^


88be3dbc ^
dd994cda ^
5497090a ^


afa42503 ^
dd994cda ^


6ea73c22 ^


363be37f ^
dd994cda ^

0487a30e ^
ac0e9db5 ^
363be37f ^
dd994cda ^
ab6ed192 ^
ac0e9db5 ^
0487a30e ^
ac0e9db5 ^
0487a30e ^
dd994cda ^

0487a30e ^
dd994cda ^
0487a30e ^
827898fc ^
dd994cda ^

b98d3876 ^

















02a55f71 ^
















1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145






                                                                            
                                                                            
 
                                                                         

                                     
                                   
                                                                  
                        
                     
                                 
                                                   
                        

                                 
                                                   




                                             


                                                                             
                                    

                                                                                           


                                               
                                                           







                                                                      
                                                   
                                                                   
                                                                                                                                                     



                                                                               
                                                                                                 




                                   
 
                                                                       






                                                                           
                            
 
                         
             


                              
                                                                               


                               
                              
             


                              
                                                                               


                              


                                             
                                                

                                                
                                                                   
                                          
                                            
                                                      
                                                              
                                                                    
                       
                                                                
                            

        
               
   
                     
                                   

        

















                                                         
















                                                                         
//: Exclusive containers contain exactly one of a fixed number of 'variants'
//: of different types.
//:
//: They also implicitly contain a tag describing precisely which variant is
//: currently stored in them.

:(before "End Mu Types Initialization")
//: We'll use this container as a running example, with two number elements.
{
type_ordinal tmp = Type_ordinal["number-or-point"] = Next_type_ordinal++;
Type[tmp].size = 2;
Type[tmp].kind = exclusive_container;
Type[tmp].name = "number-or-point";
//? cout << tmp << ": " << SIZE(Type[tmp].elements) << '\n'; //? 1
vector<type_ordinal> t1;
t1.push_back(number);
Type[tmp].elements.push_back(t1);
//? cout << SIZE(Type[tmp].elements) << '\n'; //? 1
vector<type_ordinal> t2;
t2.push_back(point);
Type[tmp].elements.push_back(t2);
//? cout << SIZE(Type[tmp].elements) << '\n'; //? 1
//? cout << "point: " << point << '\n'; //? 1
Type[tmp].element_names.push_back("i");
Type[tmp].element_names.push_back("p");
}

//: Tests in this layer often explicitly setup memory before reading it as an
//: array. Don't do this in general. I'm tagging exceptions with /raw to
//: avoid warnings.
:(scenario copy_exclusive_container)
# Copying exclusive containers copies all their contents and an extra location for the tag.
recipe main [
  1:number <- copy 1:literal  # 'point' variant
  2:number <- copy 34:literal
  3:number <- copy 35:literal
  4:number-or-point <- copy 1:number-or-point/raw  # unsafe
]
+mem: storing 1 in location 4
+mem: storing 34 in location 5
+mem: storing 35 in location 6

:(before "End size_of(types) Cases")
if (t.kind == exclusive_container) {
  // size of an exclusive container is the size of its largest variant
  // (So like containers, it can't contain arrays.)
//?   cout << "--- " << types.at(0) << ' ' << t.size << '\n'; //? 1
//?   cout << "point: " << Type_ordinal["point"] << " " << Type[Type_ordinal["point"]].name << " " << Type[Type_ordinal["point"]].size << '\n'; //? 1
//?   cout << t.name << ' ' << t.size << ' ' << SIZE(t.elements) << '\n'; //? 1
  long long int result = 0;
  for (long long int i = 0; i < t.size; ++i) {
    long long int tmp = size_of(t.elements.at(i));
//?     cout << i << ": " << t.elements.at(i).at(0) << ' ' << tmp << ' ' << result << '\n'; //? 1
    if (tmp > result) result = tmp;
  }
  // ...+1 for its tag.
  return result+1;
}

//:: To access variants of an exclusive container, use 'maybe-convert'.
//: It always returns an address (so that you can modify it) or null (to
//: signal that the conversion failed (because the container contains a
//: different variant).

//: 'maybe-convert' requires a literal in ingredient 1. We'll use a synonym
//: called 'variant'.
:(before "End Mu Types Initialization")
Type_ordinal["variant"] = 0;

:(scenario maybe_convert)
recipe main [
  12:number <- copy 1:literal
  13:number <- copy 35:literal
  14:number <- copy 36:literal
  20:address:point <- maybe-convert 12:number-or-point/raw, 1:variant  # unsafe
]
+mem: storing 13 in location 20

:(scenario maybe_convert_fail)
recipe main [
  12:number <- copy 1:literal
  13:number <- copy 35:literal
  14:number <- copy 36:literal
  20:address:point <- maybe-convert 12:number-or-point/raw, 0:variant  # unsafe
]
+mem: storing 0 in location 20

:(before "End Primitive Recipe Declarations")
MAYBE_CONVERT,
:(before "End Primitive Recipe Numbers")
Recipe_ordinal["maybe-convert"] = MAYBE_CONVERT;
:(before "End Primitive Recipe Implementations")
case MAYBE_CONVERT: {
  reagent base = canonize(current_instruction().ingredients.at(0));
  long long int base_address = base.value;
  type_ordinal base_type = base.types.at(0);
  assert(Type[base_type].kind == exclusive_container);
  assert(is_literal(current_instruction().ingredients.at(1)));
  long long int tag = current_instruction().ingredients.at(1).value;
  long long int result;
  if (tag == static_cast<long long int>(Memory[base_address])) {
    result = base_address+1;
  }
  else {
    result = 0;
  }
  products.resize(1);
  products.at(0).push_back(result);
  break;
}

//:: Allow exclusive containers to be defined in mu code.

:(scenario exclusive_container)
exclusive-container foo [
  x:number
  y:number
]
+parse: reading exclusive-container foo
+parse:   element name: x
+parse:   type: 1
+parse:   element name: y
+parse:   type: 1

:(before "End Command Handlers")
else if (command == "exclusive-container") {
  insert_container(command, exclusive_container, in);
}

//:: To construct exclusive containers out of variant types, use 'merge'.
:(scenario lift_to_exclusive_container)
exclusive-container foo [
  x:number
  y:number
]

recipe main [
  1:number <- copy 34:literal
  2:foo <- merge 0:literal/x, 1:number
  4:foo <- merge 1:literal/x, 1:number
]
+mem: storing 0 in location 2
+mem: storing 34 in location 3
+mem: storing 1 in location 4
+mem: storing 34 in location 5