summary refs log blame commit diff stats
path: root/AUTHORS
blob: 06ac7a6cb7d2dc66aec91220afb4c57234875164 (plain) (tree)
1
2
3
4
5
6
7
8
9
                                                  


                                                       

                                                         

                                                              
                                                             
                                       

                                                          
                                                   



                                                            

                                                    
                                                 
                                              

                                        
                                         
                                                                      
 
                                                                               
                                                                             
                                                     
Copyright 2009-2017  Roman Zimbelmann <hut@hut.pm>
Copyright 2010  David Barnett <davidbarnett2@gmail.com>
Copyright 2010  Lucas de Vries <lucas@glacicle.org>
Copyright 2010  Sitaram Chamarty <sitaram@atc.tcs.com>
Copyright 2011  David Pugnasse <david.pugnasse@gmail.com>
Copyright 2011  ornicar <thibault.duplessis@gmail.com>
Copyright 2011-2012  Abdó Roig-Maranges <abdo.roig@gmail.com>
Copyright 2011-2012  M Rawash <mrawash@gmail.com>
Copyright 2012  Serge Broslavsky <serge.broslavsky@gmail.com>
Copyright 2012  joe <joebodo@gmail.com>
Copyright 2013  Emanuel Guevel
Copyright 2013  Joseph Tannhuber <sepp.tannhuber@yahoo.de>
Copyright 2013-2014  GermainZ <germanosz@gmail.com>
Copyright 2014  Célestin Matte <celestin.matte@gmail.com>
Copyright 2014  Milan Svoboda <milan.svoboda@centrum.cz>
Copyright 2014  rukai <rubickent@gmail.com>
Copyright 2015  Alexander Buddenbrock <a.buddenbrock@ish.de>
Copyright 2015  Delisa Mason <iskanamagus@gmail.com>
Copyright 2015  No Suck <admin@nosuck.org>
Copyright 2015  Randy Nance <randynobx@gmail.com>
Copyright 2015  Ryan Burns <rdburns@gmail.com>
Copyright 2015  anekos <anekos@snca.net>
Copyright 2015  bastorran
Copyright 2015-2017  nfnty <git@nfnty.se>
Copyright 2015-2016  Wojciech Siewierski <wojciech.siewierski@onet.pl>

Ideally, all contributors of non-trivial code are named here to the extent that
a name and email address is available.  Please send an email to hut@hut.pm if
your name is missing, or in case of any other issues.
d } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
// So far we have local variables, and we can nest local variables of short
// lifetimes inside longer ones. Now let's support 'global' variables that
// last for the life of a routine. If we create multiple routines they won't
// have access to each other's globals.

:(scenario global_space)
recipe main [
  # pretend arrays; in practice we'll use new
  10:number <- copy 5
  20:number <- copy 5
  # actual start of this recipe
  global-space:address:array:location <- copy 20/raw
  default-space:address:array:location <- copy 10/raw
  1:number <- copy 23
  1:number/space:global <- copy 24
]
+mem: storing 23 in location 12
+mem: storing 24 in location 22

//: to support it, create another special variable called global space
:(before "End Disqualified Reagents")
if (x.name == "global-space")
  x.initialized = true;
:(before "End is_special_name Cases")
if (s == "global-space") return true;

//: writes to this variable go to a field in the current routine
:(before "End routine Fields")
long long int global_space;
:(before "End routine Constructor")
global_space = 0;
:(after "void write_memory(reagent x, vector<double> data)")
  if (x.name == "global-space") {
    if (!scalar(data)
        || SIZE(x.types) != 3
        || x.types.at(0) != Type_ordinal["address"]
        || x.types.at(1) != Type_ordinal["array"]
        || x.types.at(2) != Type_ordinal["location"]) {
      raise_error << maybe(current_recipe_name()) << "'global-space' should be of type address:array:location, but tried to write " << to_string(data) << '\n' << end();
    }
    if (Current_routine->global_space)
      raise_error << "routine already has a global-space; you can't over-write your globals" << end();
    Current_routine->global_space = data.at(0);
    return;
  }

//: now marking variables as /space:global looks them up inside this field
:(after "long long int space_base(const reagent& x)")
  if (is_global(x)) {
    if (!Current_routine->global_space)
      raise_error << "routine has no global space\n" << end();
    return Current_routine->global_space;
  }

//: for now let's not bother giving global variables names.
//: don't want to make them too comfortable to use.

:(scenario global_space_with_names)
% Hide_errors = true;
recipe main [
  global-space:address:array:location <- new location:type, 10
  x:number <- copy 23
  1:number/space:global <- copy 24
]
# don't complain about mixing numeric addresses and names
$error: 0

:(after "bool is_numeric_location(const reagent& x)")
  if (is_global(x)) return false;

//: helpers

:(code)
bool is_global(const reagent& x) {
  for (long long int i = /*skip name:type*/1; i < SIZE(x.properties); ++i) {
    if (x.properties.at(i).first == "space")
      return !x.properties.at(i).second.empty() && x.properties.at(i).second.at(0) == "global";
  }
  return false;
}