11 namespace atlas{
namespace interpreter{
17 typedef std::vector<std::pair<id_type,type_expr> >
vec;
38 bool empty()
const{
return variable.empty();}
41 vec::iterator
begin(){
return variable.begin();}
42 vec::iterator
end(){
return variable.end();}
43 vec::const_iterator
cbegin()
const{
return variable.begin();}
44 vec::const_iterator
cend()
const{
return variable.end();}
46 {
return constness.isMember(it-
cbegin());}
48 {
return not lexical_context.
empty()
49 and lexical_context.
front()->loop_depth>
depth;}
51 {
return not lexical_context.
empty()
52 and lexical_context.
front()->return_type!=
nullptr;}
54 {
return*lexical_context.
front()->return_type;}
64 {denoted_value->print(out);}
72 virtual void print(std::ostream&
out)
const{out<<print_name;}
77 virtual void evaluate(
level l)
const;
78 virtual void print(std::ostream&
out)
const{out<<
" die ";}
84 virtual void evaluate(
level l)
const;
95 virtual void evaluate(
level l)
const;
97 {out<<
" return "<< *exp;}
103 #ifdef incompletecpp11 106 {component.reserve(n);
114 virtual void evaluate(
level l)
const;
115 virtual void print(std::ostream&
out)
const;
120 virtual void evaluate(
level l)
const;
121 virtual void print(std::ostream&
out)
const;
124 #ifdef incompletecpp11 125 #define nothing_new_here {} 127 #define nothing_new_here =default 135 const char*
name()
const;
136 virtual void print(std::ostream&
out)
const;
144 virtual void evaluate(
level l)
const;
152 virtual void evaluate(
level l)
const;
176 virtual void report_origin(std::ostream&o)
const=0;
188 :
call_base(std::move(a),loc),
function(
f.release()){}
190 virtual void evaluate(
level l)
const;
191 virtual void print(std::ostream&
out)
const;
194 {std::ostringstream o;o<< *
function;
return o.str();}
198 template<
bool variadic>
207 {out<<
'{'<<print_name<<
'}';}
220 static const char*
name(){
return "built-in function";}
237 virtual void print(std::ostream&
out)
const;
240 template<
bool variadic>
249 (
const ptr_to_builtin&fun,
255 (
const ptr_to_builtin&fun,
259 ,f(fun),f_ptr(fun->val){}
261 virtual void evaluate(
level l)
const;
273 virtual
void evaluate(
level l)const;
274 virtual
void print(std::ostream&
out)const;
281 :param(std::move(param)),body(std::move(body)),
loc(loc){}
292 virtual void evaluate(
level l)
const;
293 virtual void print(std::ostream&
out)
const;
304 virtual void print(std::ostream&
out)
const;
309 {o<<
"defined "<<p->loc;}
316 static const char*
name(){
return "closure";}
329 virtual void evaluate(
level l)
const;
336 :first(f.release()),last(l.release()){}
338 virtual void evaluate(
level l)
const;
339 virtual void print(std::ostream&
out)
const;
346 :first(f.release()),last(l.release()){}
348 virtual void evaluate(
level l)
const;
349 virtual void print(std::ostream&
out)
const;
355 ,matrix_entry,matrix_column,mod_poly_term,not_so};
364 void print(std::ostream&
out,
bool reversed)
const;
386 template<
bool reversed>
390 virtual void evaluate(
level l)
const;
396 template<
bool reversed>
400 virtual void evaluate(
level l)
const;
405 template<
bool reversed>
409 virtual void evaluate(
level l)
const;
414 template<
bool reversed>
418 virtual void evaluate(
level l)
const;
423 template<
bool reversed>
427 virtual void evaluate(
level l)
const;
428 virtual void print(std::ostream&
out)
const;
431 template<
bool reversed>
435 virtual void evaluate(
level l)
const;
443 virtual void evaluate(
level l)
const;
445 {out<< *array<<
'['<<
']';}
448 template<
unsigned flags>
451 :
slice_base(std::move(a),std::move(l),std::move(u)){}
452 virtual void evaluate(
level l)
const;
458 template<
unsigned flags>
461 :
slice_base(std::move(a),std::move(l),std::move(u)){}
462 virtual void evaluate(
level l)
const;
467 template<
unsigned flags>
470 :
slice_base(std::move(a),std::move(l),std::move(u)){}
471 virtual void evaluate(
level l)
const;
476 template<
unsigned flags>
479 :
slice_base(std::move(a),std::move(l),std::move(u)){}
480 virtual void evaluate(
level l)
const;
485 template<
unsigned flags>
488 :
slice_base(std::move(a),std::move(l),std::move(u)){}
489 virtual void evaluate(
level l)
const;
502 :type(t.
copy()),position(i),id(
id),
loc(loc){}
504 virtual void print(std::ostream&
out)
const;
507 virtual void report_origin(std::ostream&o)
const;
514 static const char*
name(){
return "built-in function";}
517 :type(v.type.copy()),position(v.position),loc(v.loc){}
528 virtual void evaluate(
level l)
const;
529 virtual void print(std::ostream&
out)
const;
537 :condition(c.release()),then_branch(t.release()),else_branch(
e.release())
540 virtual void evaluate(
level l)
const;
541 virtual void print(std::ostream&
out)
const;
549 :condition(c.release()),branches(std::move(b))
552 virtual void evaluate(
level l)
const;
553 virtual void print(std::ostream&
out)
const;
556 template<
unsigned flags>
561 virtual void evaluate(
level l)
const;
562 virtual void print(std::ostream&
out)
const;
565 template<
bool negated>
570 :condition(c.release()),body(b.release()){}
572 virtual void evaluate(
level l)
const;
573 virtual void print(std::ostream&
out)
const;
581 virtual void evaluate(
level l)
const;
582 virtual void print(std::ostream&
out)
const;
587 virtual void evaluate(
level l)
const;
588 virtual void print(std::ostream&
out)
const;
591 template<
unsigned flags,subscr_base::sub_type kind>
598 virtual
void evaluate(
level l)const;
599 virtual
void print(std::ostream&
out)const;
602 template<
unsigned flags>
611 :id(i),count(cnt.release()),bound(bnd.release()),body(b.release())
614 virtual void evaluate(
level l)
const;
615 virtual void print(std::ostream&
out)
const;
623 :lhs(l),rhs(r.release()){}
625 virtual void print(std::ostream&
out)
const;
633 virtual void evaluate(
level l)
const;
641 virtual void evaluate(
level l)
const;
659 ,loc_list&&ll,glob_list&&gl,BitMap&&bm);
661 virtual
void print(std::ostream&
out)const;
662 virtual
void evaluate(
level l)const;
665 template<
bool reversed>
674 virtual void print(std::ostream&
out)
const;
679 template<
bool reversed>
692 template<
bool reversed>
724 std::back_insert_iterator<std::vector<shared_value> >dst);
function_base()
Definition: axis.h:170
id_type id
Definition: axis.h:497
void push_expanded(expression_base::level l, const shared_value &v)
Definition: axis-types.cpp:447
expression_ptr rhs
Definition: axis.h:620
virtual expression_base::level argument_policy() const
Definition: axis.h:306
char * loc
Definition: common.c:89
virtual void print(std::ostream &out) const
Definition: axis.h:436
virtual void print(std::ostream &out) const
Definition: axis.h:472
shared_closure f
Definition: axis.h:322
expression_ptr condition
Definition: axis.h:545
virtual void apply(expression_base::level l) const
Definition: axis.h:208
std::shared_ptr< lambda_struct > shared_lambda
Definition: axis.h:283
size_t offset
Definition: axis.h:148
tuple_expression(size_t n)
Definition: axis.h:111
row_slice(expression_ptr &&a, expression_ptr &&l, expression_ptr &&u)
Definition: axis.h:450
overloaded_builtin_call< true > variadic_builtin_call
Definition: axis.h:265
virtual void print(std::ostream &out) const
Definition: axis.h:401
shared_lambda p
Definition: axis.h:298
std::vector< overload_data > variant_list
Definition: global.h:122
virtual closure_value * clone() const
Definition: axis.h:314
containers::simple_list< layer * > list
Definition: axis.h:15
void thread_components(const id_pat &pat, const shared_value &val, std::back_insert_iterator< std::vector< shared_value > >dst)
Definition: axis.cpp:1864
void add(id_type id, type_expr &&t, bool is_const)
Definition: axis.cpp:654
Hash_table::id_type id_type
Definition: parse_types.h:22
const unsigned loop_depth
Definition: axis.h:22
id_pat pattern
Definition: axis.h:593
std::string print_name
Definition: axis.h:68
ratvec_subscription(expression_ptr &&a, expression_ptr &&i)
Definition: axis.h:407
layer & operator=(const layer &)=delete
uA p
Definition: lists.cpp:26
virtual void print(std::ostream &out) const
Definition: axis.h:444
shared_share address
Definition: axis.h:684
virtual void print(std::ostream &out) const
Definition: axis.h:410
subscr_base::sub_type kind
Definition: axis.h:696
#define nothing_new_here
Definition: axis.h:127
expression_ptr resolve_overload(const expr &e, type_expr &type, const overload_table::variant_list &variants)
Definition: axis.cpp:1516
bool empty() const
Definition: sl_list.h:468
virtual expression_base::level argument_policy() const
Definition: axis.h:210
ratvec_slice(expression_ptr &&a, expression_ptr &&l, expression_ptr &&u)
Definition: axis.h:469
id_type lhs
Definition: axis.h:619
glob_list globals
Definition: axis.h:654
std::shared_ptr< const closure_value > shared_closure
Definition: axis.h:319
std::string print_name
Definition: axis.h:201
Definition: axis-types.h:116
const expression_base & body
Definition: axis.h:299
loc_list locals
Definition: axis.h:653
static bool may_break(unsigned depth)
Definition: axis.h:47
matrix_slice(expression_ptr &&a, expression_ptr &&l, expression_ptr &&u)
Definition: axis.h:487
~layer()
Definition: axis.h:31
expression_ptr index
Definition: axis.h:356
local_identifier(id_type id, size_t i, size_t j)
Definition: axis.h:150
std::unique_ptr< expression_base > expression_ptr
Definition: axis-types.h:206
slice_base(expression_ptr &&a, expression_ptr &&l, expression_ptr &&u)
Definition: axis.h:376
virtual void evaluate(level l) const
Definition: axis.h:62
virtual void print(std::ostream &out) const
Definition: axis.h:463
virtual void print(std::ostream &out) const
Definition: axis.h:419
containers::simple_list< local_dest > loc_list
Definition: axis.h:648
row_subscription(expression_ptr &&a, expression_ptr &&i)
Definition: axis.h:388
static list lexical_context
Definition: axis.h:18
std::unique_ptr< closure_value > closure_ptr
Definition: axis.h:318
vector_slice(expression_ptr &&a, expression_ptr &&l, expression_ptr &&u)
Definition: axis.h:460
virtual std::string function_name() const
Definition: axis.h:236
BitMap is_global
Definition: axis.h:655
expression_ptr convert_expr(const expr &e, type_expr &type)
Definition: axis.cpp:691
returner(expression_ptr &&exp)
Definition: axis.h:94
expression_ptr body
Definition: axis.h:558
shared_value denoted_value
Definition: axis.h:58
id_pat lhs
Definition: axis.h:651
void print(std::ostream &out, unsigned flags) const
Definition: axis.cpp:2045
void reset_evaluator()
Definition: axis.cpp:624
assignment_expr(id_type l, expression_ptr &&r)
Definition: axis.h:622
Definition: axis-types.h:188
virtual void print(std::ostream &out) const
Definition: axis.h:63
void thread_bindings(const id_pat &pat, const type_expr &type, layer &dst, bool is_const)
Definition: axis.cpp:1851
overloaded_builtin_call< false > builtin_call
Definition: axis.h:264
expression_ptr initialiser
Definition: axis.h:269
const shared_share address
Definition: axis.h:140
Definition: parse_types.h:26
type_expr last_type
Definition: axis.cpp:13
subscr_base(expression_ptr &&a, expression_ptr &&i)
Definition: axis.h:358
const type_p return_type
Definition: axis.h:23
Definition: axis-types.h:187
Definition: axis-types.h:51
id_type code
Definition: axis.h:131
string_slice(expression_ptr &&a, expression_ptr &&l, expression_ptr &&u)
Definition: axis.h:478
closure_value(const shared_context &c, const shared_lambda &l)
Definition: axis.h:301
expression_ptr exp
Definition: axis.h:93
call_base(expression_ptr &&arg, const source_location &loc)
Definition: axis.h:159
static type_expr & current_return_type()
Definition: axis.h:53
vec::iterator begin()
Definition: axis.h:41
virtual void print(std::ostream &out) const
Definition: axis.h:490
vector_subscription(expression_ptr &&a, expression_ptr &&i)
Definition: axis.h:398
id_pat param
Definition: axis.h:278
containers::simple_list< shared_share > glob_list
Definition: axis.h:649
unsigned position
Definition: axis.h:496
ptr_to_builtin f
Definition: axis.h:244
void pop_front()
Definition: sl_list.h:439
layer(const layer &)=delete
virtual void print(std::ostream &out) const
Definition: axis.h:96
component_assignment< reversed > base
Definition: axis.h:694
size_t count_identifiers(const id_pat &pat)
Definition: axis.cpp:1834
virtual void print(std::ostream &out) const
Definition: axis.h:391
unsigned depth
Definition: axis.h:82
expression_ptr last
Definition: axis.h:333
next_expression(expression_ptr &&f, expression_ptr &&l)
Definition: axis.h:345
expression_ptr condition
Definition: axis.h:567
static void specialise(size_t depth, size_t offset, const type_expr &t)
Definition: axis.cpp:684
size_t offset
Definition: axis.h:647
unsigned position
Definition: axis.h:521
std::shared_ptr< const builtin_value< variadic > > ptr_to_builtin
Definition: axis.h:242
expression_ptr rhs
Definition: axis.h:652
while_expression(expression_ptr &&b)
Definition: axis.h:559
shared_share address
Definition: axis.h:629
type_expr pattern_type(const id_pat &pat)
Definition: axis.cpp:1828
BitMap constness
Definition: axis.h:21
#define out(c)
Definition: cweave.c:205
expression_ptr body
Definition: axis.h:577
wrapper_function val
Definition: axis.h:200
void(* wrapper_function)(expression_base::level)
Definition: global.h:262
dont_expression()
Definition: axis.h:585
static const char * name()
Definition: axis.h:220
identifier(id_type id)
Definition: axis.h:133
type_expr copy() const
Definition: axis-types.cpp:74
virtual void print(std::ostream &out) const
Definition: axis.h:206
static const_type_p lookup(id_type id, size_t &depth, size_t &offset, bool &is_const)
Definition: axis.cpp:667
matrix_get_column(expression_ptr &&a, expression_ptr &&j)
Definition: axis.h:433
denotation(shared_value &&v)
Definition: axis.h:61
virtual projector_value * clone() const
Definition: axis.h:512
std::vector< std::pair< id_type, type_expr > > vec
Definition: axis.h:17
expression_ptr body
Definition: axis.h:594
std::shared_ptr< const builtin_value< false > > shared_builtin
Definition: axis.h:224
Definition: axis-types.h:188
type_expr type
Definition: axis.h:495
bool empty() const
Definition: axis.h:38
virtual std::string function_name() const
Definition: axis.h:192
virtual void print(std::ostream &out) const
Definition: axis.h:453
builtin_value(wrapper_function v, const std::string &n)
Definition: axis.h:203
breaker(unsigned depth)
Definition: axis.h:83
wrapper_function f_ptr
Definition: axis.h:246
vec variable
Definition: axis.h:20
static const char * name()
Definition: axis.h:514
source_location loc
Definition: axis.h:157
expression_ptr count
Definition: axis.h:605
bool is_const(vec::const_iterator it) const
Definition: axis.h:45
source_location loc
Definition: axis.h:498
std::shared_ptr< class evaluation_context > shared_context
Definition: axis-types.h:167
std::pair< id_type, type_expr > & operator[](size_t i)
Definition: axis.h:39
char * name
Definition: common.c:103
const id_pat variable
Definition: axis.h:268
seq_expression(expression_ptr &&f, expression_ptr &&l)
Definition: axis.h:335
unsigned long n
Definition: axis.cpp:77
module_coefficient(expression_ptr &&pol, expression_ptr &¶m)
Definition: axis.h:441
vec::const_iterator cbegin() const
Definition: axis.h:43
forever_expression(expression_ptr &&b)
Definition: axis.h:579
virtual void print(std::ostream &out) const
Definition: axis.h:78
boolean flags[UCHAR_MAX+1]
Definition: common.c:136
void print(char *s,...)
Definition: common.c:861
expression_ptr upper
Definition: axis.h:374
component_assignment< reversed > base
Definition: axis.h:681
expression_ptr argument
Definition: axis.h:156
denotation(const shared_value &v)
Definition: axis.h:60
std::string name
Definition: axis.h:228
std::shared_ptr< const builtin_value< true > > shared_variadic_builtin
Definition: axis.h:225
virtual void report_origin(std::ostream &o) const
Definition: axis.h:308
sub_type
Definition: axis.h:353
virtual builtin_value * clone() const
Definition: axis.h:219
static const char * name()
Definition: axis.h:316
virtual void print(std::ostream &out) const
Definition: axis.h:72
Definition: parse_types.h:57
const expr & e
Definition: axis.cpp:95
T & front()
Definition: sl_list.h:438
matrix_subscription(expression_ptr &&a, expression_ptr &&ij)
Definition: axis.h:425
static bool may_return()
Definition: axis.h:50
virtual void print(std::ostream &out) const
Definition: axis.h:85
Definition: parse_types.h:156
std::vector< expression_ptr > component
Definition: axis.h:101
vec::iterator end()
Definition: axis.h:42
expression_ptr index
Definition: axis.h:667
virtual void report_origin(std::ostream &o) const
Definition: axis.h:213
projector_value(const projector_value &v)
Definition: axis.h:516
do_expression(expression_ptr &&c, expression_ptr &&b)
Definition: axis.h:569
size_t offset
Definition: axis.h:637
void list_identifiers(const id_pat &pat, std::vector< id_type > &d)
Definition: axis.cpp:1842
virtual void print(std::ostream &out) const
Definition: axis.h:481
expression_ptr last
Definition: axis.h:343
list_expression(size_t n)
Definition: axis.h:119
level
Definition: axis-types.h:188
std::shared_ptr< shared_value > shared_share
Definition: global.h:22
unsigned int depth
Definition: output.cpp:74
id_type id
Definition: axis.h:604
size_t offset
Definition: axis.h:697
void print(std::ostream &out, bool reversed) const
Definition: axis.cpp:2032
shared_context context
Definition: axis.h:297
shared_value last_value
Definition: axis.cpp:14
capture_expression(const shared_value &v, const std::string &name)
Definition: axis.h:70
vec::const_iterator cend() const
Definition: axis.h:44
std::shared_ptr< const value_base > shared_value
Definition: axis-types.h:130
string_subscription(expression_ptr &&a, expression_ptr &&i)
Definition: axis.h:416
std::shared_ptr< const function_base > shared_function
Definition: global.h:80
expression_ptr then_branch
Definition: axis.h:533
shared_lambda p
Definition: axis.h:286
Vertex v
Definition: graph.cpp:116
subscr_base::sub_type kind
Definition: axis.h:683