# Mu - 018constant.cc

     1 //: A few literal constants.
     2
     3 :(scenarios load)  // use 'load' instead of 'run' in all scenarios in this layer
     4
     5 :(before "End Mu Types Initialization")
     6 put(Type_ordinal, "literal-boolean", 0);
     7
     8 //: 'true'
     9
    10 :(scenario true)
    11 def main [
    12   1:boolean <- copy true
    13 ]
    14 +parse:   ingredient: {true: "literal-boolean"}
    15
    16 :(before "End Parsing reagent")
    17 if (name == "true") {
    18   if (type != NULL) {
    19     raise << "'true' is a literal and can't take a type\n" << end();
    20     return;
    21   }
    22   type = new type_tree("literal-boolean");
    23   set_value(1);
    24 }
    25
    26 //: 'false'
    27
    28 :(scenario false)
    29 def main [
    30   1:boolean <- copy false
    31 ]
    32 +parse:   ingredient: {false: "literal-boolean"}
    33
    34 :(before "End Parsing reagent")
    35 if (name == "false") {
    36   if (type != NULL) {
    37     raise << "'false' is a literal and can't take a type\n" << end();
    38     return;
    39   }
    40   type = new type_tree("literal-boolean");
    41   set_value(0);
    42 }
    43
    44 //: 'null'
    45
    46 :(before "End Mu Types Initialization")
    47 put(Type_ordinal, "literal-address", 0);
    48
    49 :(scenario null)
    50 def main [
    51   1:address:number <- copy null
    52 ]
    53 +parse:   ingredient: {null: "literal-address"}
    54
    55 :(before "End Parsing reagent")
    56 if (name == "null") {
    57   if (type != NULL) {
    58     raise << "'null' is a literal and can't take a type\n" << end();
    59     return;
    60   }
    61   type = new type_tree("literal-address");
    62   set_value(0);
    63 }