about summary refs log tree commit diff stats
path: root/tools/iso/kernel.soso/fatfs_integer.h
Commit message (Expand)AuthorAgeFilesLines
* 5858Kartik Agaram2020-01-011-0/+39
t; 2015-03-28 20:57:21 -0700 committer Kartik K. Agaram <vc@akkartik.com> 2015-03-28 20:57:21 -0700 992 - c++ chain spaces for lexical scope' href='/akkartik/mu/commit/cpp/028space_surround?h=hlt&id=8f1db754005616054192b3f75e54af9929df26cc'>8f1db754 ^
bc643692 ^

a0fc38c9 ^

bc643692 ^

8f1db754 ^
d7494165 ^
8f1db754 ^
d7494165 ^
8f1db754 ^
d7494165 ^
8f1db754 ^





ac0e9db5 ^

31401373 ^
8f1db754 ^

ac0e9db5 ^
82ac0b7e ^
82ac0b7e ^

ac0e9db5 ^
82ac0b7e ^
8f1db754 ^

ac0e9db5 ^
047296d8 ^
0487a30e ^
e4630643 ^
4814bf94 ^
0f125d5f ^
0487a30e ^
8f1db754 ^


047296d8 ^


bc643692 ^
047296d8 ^
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





                                                                          
                             

                                                                                   

                                      

                                                                                                       

                             
 
             
                               
                        
                               
                        





                                                                           

                                                         
                                                                                     

 
                                                                                           
                         

                
                                                                      
                

 
                                             
                                                                            
                                              
                                               
                                                                                                                                           
                                                         
     


           


                                         
                        
 
//: So far you can have global variables by not setting default-space, and
//: local variables by setting default-space. You can isolate variables
//: between those extremes by creating 'surrounding' spaces.
//:
//: (Surrounding spaces are like lexical scopes in other languages.)

:(scenario surrounding_space)
# location 1 in space 1 refers to the space surrounding the default space, here 20.
recipe main [
  10:number <- copy 5  # pretend array
  20:number <- copy 5  # pretend array
  default-space:address:array:location <- copy 10/raw
  0:address:array:location/names:dummy <- copy 20/raw  # later layers will explain the /names: property
  1:number <- copy 32
  1:number/space:1 <- copy 33
]
# chain space
+mem: storing 20 in location 11
# store to default-space
+mem: storing 32 in location 12
# store to chained space
+mem: storing 33 in location 22

//: If you think of a space as a collection of variables with a common
//: lifetime, surrounding allows managing shorter lifetimes inside a longer
//: one.

:(replace{} "long long int space_base(const reagent& x)")
long long int space_base(const reagent& x) {
  return space_base(x, space_index(x), Current_routine->calls.front().default_space);
}

long long int space_base(const reagent& x, long long int space_index, long long int base) {
  if (space_index == 0) {
    return base;
  }
  long long int result = space_base(x, space_index-1, Memory[base+1]);
  return result;
}

long long int space_index(const reagent& x) {
  for (long long int i = /*skip name:type*/1; i < SIZE(x.properties); ++i) {
    if (x.properties.at(i).first == "space") {
      if (SIZE(x.properties.at(i).second) != 1)
        raise << maybe(current_recipe_name()) << "/space metadata should take exactly one value in " << x.original_string << '\n' << end();
      return to_integer(x.properties.at(i).second.at(0));
    }
  }
  return 0;
}

:(scenario permit_space_as_variable_name)
recipe main [
  space:number <- copy 0
]