GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
pt-classdef.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2012-2015 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if !defined (octave_tree_classdef_h)
24 #define octave_tree_classdef_h 1
25 
26 class octave_value;
27 
28 class tree_walker;
29 
30 #include "pt-cmd.h"
31 #include "pt-exp.h"
32 #include "pt-id.h"
33 
34 #include "base-list.h"
35 
36 #include <list>
37 
39 {
40 public:
41 
43  : id (i), expr (e), neg (false) { }
44 
46  : id (i), expr (0), neg (b) { }
47 
49  {
50  delete id;
51  delete expr;
52  }
53 
54  tree_identifier *ident (void) { return id; }
55 
56  tree_expression *expression (void) { return expr; }
57 
58  bool negate (void) { return neg; }
59 
60  void accept (tree_walker&);
61 
62 private:
63 
66  bool neg;
67 
68  // No copying!
69 
71 
73 };
74 
75 class tree_classdef_attribute_list : public octave_base_list<tree_classdef_attribute *>
76 {
77 public:
78 
80 
82 
85 
87 
88  void accept (tree_walker&);
89 
90 private:
91 
92  // No copying!
93 
95 
97 };
98 
100 {
101 public:
102 
103  tree_classdef_superclass (const std::string& cname)
104  : cls_name (cname) { }
105 
107 
108  std::string class_name (void) { return cls_name; }
109 
110  void accept (tree_walker&);
111 
112 private:
113 
114  std::string cls_name;
115 
116  // No copying!
117 
119 
121 };
122 
123 class tree_classdef_superclass_list : public octave_base_list<tree_classdef_superclass *>
124 {
125 public:
126 
128 
130 
133 
135 
136  void accept (tree_walker&);
137 
138 private:
139 
140  // No copying!
141 
143 
145 };
146 
147 template <typename T>
149 {
150 public:
151 
153  octave_base_list<T> *elist,
155  int l = -1, int c = -1)
156  : tree (l, c), attr_list (a), elt_list (elist),
157  lead_comm (lc), trail_comm (tc)
158  { }
159 
161  {
162  delete attr_list;
163  delete elt_list;
164  delete lead_comm;
165  delete trail_comm;
166  }
167 
169 
171 
173 
175 
176  void accept (tree_walker&) { }
177 
178 private:
179 
180  // List of attributes that apply to this class.
182 
183  // The list of objects contained in this block.
185 
186  // Comment preceding the token marking the beginning of the block.
188 
189  // Comment preceding END token.
191 
192  // No copying!
193 
195 
197 };
198 
200 {
201 public:
202 
204  : id (i), expr (e) { }
205 
207  {
208  delete id;
209  delete expr;
210  }
211 
212  tree_identifier *ident (void) { return id; }
213 
214  tree_expression *expression (void) { return expr; }
215 
216  void accept (tree_walker&);
217 
218 private:
219 
222 
223  // No copying!
224 
226 
228 };
229 
230 class tree_classdef_property_list : public octave_base_list<tree_classdef_property *>
231 {
232 public:
233 
235 
237 
240 
242 
243  void accept (tree_walker&);
244 
245 private:
246 
247  // No copying!
248 
250 
252 };
253 
255  : public tree_classdef_element<tree_classdef_property *>
256 {
257 public:
258 
263  int l = -1, int c = -1)
264  : tree_classdef_element<tree_classdef_property *> (a, plist, lc, tc, l, c) { }
265 
267 
268  void accept (tree_walker&);
269 
270 private:
271 
272  // No copying!
273 
275 
277 };
278 
279 class tree_classdef_methods_list : public octave_base_list<octave_value>
280 {
281 public:
282 
284 
286 
288  : octave_base_list<octave_value> (a) { }
289 
291 
292  void accept (tree_walker&);
293 
294 private:
295 
296  // No copying!
297 
299 
301 };
302 
304 {
305 public:
306 
310  octave_comment_list *tc, int l = -1, int c = -1)
311  : tree_classdef_element<octave_value> (a, mlist, lc, tc, l, c) { }
312 
314 
315  void accept (tree_walker&);
316 
317 private:
318 
319  // No copying!
320 
322 
324 };
325 
327 {
328 public:
329 
331 
333  {
334  delete id;
335  }
336 
337  tree_identifier *ident (void) { return id; }
338 
339  void accept (tree_walker&);
340 
341 private:
342 
344 
345  // No copying!
346 
348 
350 };
351 
352 class tree_classdef_events_list : public octave_base_list<tree_classdef_event *>
353 {
354 public:
355 
357 
359 
362 
364 
365  void accept (tree_walker&);
366 
367 private:
368 
369  // No copying!
370 
372 
374 };
375 
377  : public tree_classdef_element<tree_classdef_event *>
378 {
379 public:
380 
384  octave_comment_list *tc, int l = -1, int c = -1)
385  : tree_classdef_element<tree_classdef_event *> (a, elist, lc, tc, l, c) { }
386 
388 
389  void accept (tree_walker&);
390 
391 private:
392 
393  // No copying!
394 
396 
398 };
399 
401 {
402 public:
403 
404  tree_classdef_enum (void) : id (0), expr (0) { }
405 
407  : id (i), expr (e) { }
408 
410  {
411  delete id;
412  delete expr;
413  }
414 
415  tree_identifier *ident (void) { return id; }
416 
417  tree_expression *expression (void) { return expr; }
418 
419  void accept (tree_walker&);
420 
421 private:
422 
425 
426  // No copying!
427 
429 
431 };
432 
433 class tree_classdef_enum_list : public octave_base_list<tree_classdef_enum *>
434 {
435 public:
436 
438 
440 
443 
445 
446  void accept (tree_walker&);
447 
448 private:
449 
450  // No copying!
451 
453 
455 };
456 
458  : public tree_classdef_element<tree_classdef_enum *>
459 {
460 public:
461 
465  octave_comment_list *tc, int l = -1, int c = -1)
466  : tree_classdef_element<tree_classdef_enum *> (a, elist, lc, tc, l, c) { }
467 
469 
470  void accept (tree_walker&);
471 
472 private:
473 
474  // No copying!
475 
477 
479 };
480 
482 {
483 public:
484 
485  typedef std::list<tree_classdef_properties_block *>::iterator properties_list_iterator;
486  typedef std::list<tree_classdef_properties_block *>::const_iterator properties_list_const_iterator;
487 
488  typedef std::list<tree_classdef_methods_block *>::iterator methods_list_iterator;
489  typedef std::list<tree_classdef_methods_block *>::const_iterator methods_list_const_iterator;
490 
491  typedef std::list<tree_classdef_events_block *>::iterator events_list_iterator;
492  typedef std::list<tree_classdef_events_block *>::const_iterator events_list_const_iterator;
493 
494  typedef std::list<tree_classdef_enum_block *>::iterator enum_list_iterator;
495  typedef std::list<tree_classdef_enum_block *>::const_iterator enum_list_const_iterator;
496 
498  : properties_lst (), methods_lst (), events_lst (), enum_lst () { }
499 
502  {
503  append (pb);
504  }
505 
508  {
509  append (mb);
510  }
511 
514  {
515  append (evb);
516  }
517 
520  {
521  append (enb);
522  }
523 
524  ~tree_classdef_body (void);
525 
527  {
528  properties_lst.push_back (pb);
529  }
530 
532  {
533  methods_lst.push_back (mb);
534  }
535 
537  {
538  events_lst.push_back (evb);
539  }
540 
542  {
543  enum_lst.push_back (enb);
544  }
545 
546  std::list<tree_classdef_properties_block *> properties_list (void)
547  {
548  return properties_lst;
549  }
550 
551  std::list<tree_classdef_methods_block *> methods_list (void)
552  {
553  return methods_lst;
554  }
555 
556  std::list<tree_classdef_events_block *> events_list (void)
557  {
558  return events_lst;
559  }
560 
561  std::list<tree_classdef_enum_block *> enum_list (void)
562  {
563  return enum_lst;
564  }
565 
566  void accept (tree_walker&);
567 
568 private:
569 
570  std::list<tree_classdef_properties_block *> properties_lst;
571 
572  std::list<tree_classdef_methods_block *> methods_lst;
573 
574  std::list<tree_classdef_events_block *> events_lst;
575 
576  std::list<tree_classdef_enum_block *> enum_lst;
577 
578  // No copying!
579 
581 
583 };
584 
585 // Classdef definition.
586 
588 {
589 public:
590 
595  const std::string& pn = std::string (), int l = -1,
596  int c = -1)
597  : tree_command (l, c), attr_list (a), id (i),
598  supclass_list (sc), element_list (b), lead_comm (lc), trail_comm (tc),
599  pack_name (pn) { }
600 
602  {
603  delete attr_list;
604  delete id;
605  delete supclass_list;
606  delete element_list;
607  delete lead_comm;
608  delete trail_comm;
609  }
610 
612 
613  tree_identifier *ident (void) { return id; }
614 
616 
618 
621 
622  const std::string& package_name (void) const { return pack_name; }
623 
624  octave_function* make_meta_class (bool is_at_folder = false);
625 
628 
629  void accept (tree_walker& tw);
630 
631 private:
632 
634 
636 
638 
640 
643 
644  std::string pack_name;
645 
646  // No copying!
647 
648  tree_classdef (const tree_classdef&);
649 
651 };
652 
653 #endif
tree_classdef_body & operator=(const tree_classdef_body &)
tree_classdef_property_list(const octave_base_list< tree_classdef_property * > &a)
Definition: pt-classdef.h:238
tree_classdef_events_list(const octave_base_list< tree_classdef_event * > &a)
Definition: pt-classdef.h:360
tree_classdef_attribute(tree_identifier *i=0, tree_expression *e=0)
Definition: pt-classdef.h:42
void accept(tree_walker &)
tree_classdef_methods_list(const octave_base_list< octave_value > &a)
Definition: pt-classdef.h:287
octave_comment_list * lead_comm
Definition: pt-classdef.h:641
std::list< tree_classdef_methods_block * >::iterator methods_list_iterator
Definition: pt-classdef.h:488
void append(tree_classdef_properties_block *pb)
Definition: pt-classdef.h:526
octave_comment_list * leading_comment(void)
Definition: pt-classdef.h:172
void accept(tree_walker &)
Definition: pt-classdef.cc:187
tree_classdef_enum & operator=(const tree_classdef_enum &)
tree_classdef(tree_classdef_attribute_list *a, tree_identifier *i, tree_classdef_superclass_list *sc, tree_classdef_body *b, octave_comment_list *lc, octave_comment_list *tc, const std::string &pn=std::string(), int l=-1, int c=-1)
Definition: pt-classdef.h:591
tree_classdef_superclass_list(const octave_base_list< tree_classdef_superclass * > &a)
Definition: pt-classdef.h:131
tree_expression * expression(void)
Definition: pt-classdef.h:417
octave_comment_list * trailing_comment(void)
Definition: pt-classdef.h:174
tree_classdef_element & operator=(const tree_classdef_element &)
tree_classdef_enum_list & operator=(const tree_classdef_enum_list &)
tree_classdef_property & operator=(const tree_classdef_property &)
tree_classdef_body * element_list
Definition: pt-classdef.h:639
tree_classdef_attribute_list * attribute_list(void)
Definition: pt-classdef.h:168
tree_classdef_body * body(void)
Definition: pt-classdef.h:617
tree_classdef_property(tree_identifier *i=0, tree_expression *e=0)
Definition: pt-classdef.h:203
std::list< tree_classdef_methods_block * > methods_list(void)
Definition: pt-classdef.h:551
tree_classdef_enum(tree_identifier *i, tree_expression *e)
Definition: pt-classdef.h:406
tree_classdef_property_list(tree_classdef_property *p)
Definition: pt-classdef.h:236
tree_identifier * ident(void)
Definition: pt-classdef.h:613
tree_classdef_event & operator=(const tree_classdef_event &)
void accept(tree_walker &)
Definition: pt-classdef.cc:127
tree_identifier * id
Definition: pt-classdef.h:220
tree_classdef_superclass & operator=(const tree_classdef_superclass &)
octave_comment_list * leading_comment(void)
Definition: pt-classdef.h:619
tree_classdef_attribute_list * attr_list
Definition: pt-classdef.h:181
~tree_classdef(void)
Definition: pt-classdef.h:601
tree_classdef_superclass(const std::string &cname)
Definition: pt-classdef.h:103
octave_comment_list * lead_comm
Definition: pt-classdef.h:187
tree_classdef_events_list(tree_classdef_event *e)
Definition: pt-classdef.h:358
tree_identifier * id
Definition: pt-classdef.h:423
tree_classdef_methods_list & operator=(const tree_classdef_methods_list &)
tree_classdef_methods_block(tree_classdef_attribute_list *a, tree_classdef_methods_list *mlist, octave_comment_list *lc, octave_comment_list *tc, int l=-1, int c=-1)
Definition: pt-classdef.h:307
std::list< tree_classdef_properties_block * > properties_lst
Definition: pt-classdef.h:570
std::list< tree_classdef_methods_block * > methods_lst
Definition: pt-classdef.h:572
std::list< tree_classdef_properties_block * >::iterator properties_list_iterator
Definition: pt-classdef.h:485
octave_comment_list * trailing_comment(void)
Definition: pt-classdef.h:620
octave_base_list< T > * element_list(void)
Definition: pt-classdef.h:170
tree_classdef_attribute_list(tree_classdef_attribute *a)
Definition: pt-classdef.h:81
void append(tree_classdef_enum_block *enb)
Definition: pt-classdef.h:541
octave_comment_list * trail_comm
Definition: pt-classdef.h:190
std::list< tree_classdef_enum_block * > enum_lst
Definition: pt-classdef.h:576
tree_classdef_superclass_list * supclass_list
Definition: pt-classdef.h:637
tree_classdef_element(tree_classdef_attribute_list *a, octave_base_list< T > *elist, octave_comment_list *lc, octave_comment_list *tc, int l=-1, int c=-1)
Definition: pt-classdef.h:152
tree_classdef * dup(symbol_table::scope_id scope, symbol_table::context_id context) const
Definition: pt-classdef.cc:248
tree_identifier * id
Definition: pt-classdef.h:343
tree_identifier * ident(void)
Definition: pt-classdef.h:212
void accept(tree_walker &)
Definition: pt-classdef.cc:85
tree_classdef_property_list & operator=(const tree_classdef_property_list &)
tree_classdef_body(tree_classdef_enum_block *enb)
Definition: pt-classdef.h:518
std::list< tree_classdef_enum_block * >::iterator enum_list_iterator
Definition: pt-classdef.h:494
void append(const tree_classdef_attribute *&s)
Definition: base-list.h:105
F77_RET_T const double const double * f
void accept(tree_walker &)
Definition: pt-classdef.cc:33
void accept(tree_walker &)
Definition: pt-classdef.cc:161
static llvm::LLVMContext & context
Definition: jit-typeinfo.cc:76
std::list< tree_classdef_events_block * > events_list(void)
Definition: pt-classdef.h:556
tree_expression * expr
Definition: pt-classdef.h:424
std::list< tree_classdef_events_block * >::iterator events_list_iterator
Definition: pt-classdef.h:491
void accept(tree_walker &)
Definition: pt-classdef.cc:59
void accept(tree_walker &)
Definition: pt-classdef.cc:169
tree_identifier * ident(void)
Definition: pt-classdef.h:415
tree_classdef_enum_block & operator=(const tree_classdef_enum_block &)
void accept(tree_walker &)
Definition: pt-classdef.cc:153
std::string pack_name
Definition: pt-classdef.h:644
tree_classdef_attribute_list & operator=(const tree_classdef_attribute_list &)
tree_classdef_attribute & operator=(const tree_classdef_attribute &)
std::list< tree_classdef_events_block * > events_lst
Definition: pt-classdef.h:574
std::list< tree_classdef_properties_block * > properties_list(void)
Definition: pt-classdef.h:546
tree_classdef_attribute_list(const octave_base_list< tree_classdef_attribute * > &a)
Definition: pt-classdef.h:83
tree_expression * expression(void)
Definition: pt-classdef.h:56
tree_classdef_superclass_list(tree_classdef_superclass *sc)
Definition: pt-classdef.h:129
std::list< tree_classdef_events_block * >::const_iterator events_list_const_iterator
Definition: pt-classdef.h:492
tree_expression * expression(void)
Definition: pt-classdef.h:214
tree_classdef_attribute_list * attr_list
Definition: pt-classdef.h:633
void accept(tree_walker &)
Definition: pt-classdef.cc:51
tree_identifier * ident(void)
Definition: pt-classdef.h:337
tree_identifier * ident(void)
Definition: pt-classdef.h:54
tree_classdef_body(tree_classdef_events_block *evb)
Definition: pt-classdef.h:512
void accept(tree_walker &)
Definition: pt-classdef.h:176
tree_classdef_body(tree_classdef_methods_block *mb)
Definition: pt-classdef.h:506
void accept(tree_walker &)
Definition: pt-classdef.cc:119
tree_classdef_events_list & operator=(const tree_classdef_events_list &)
tree_classdef_event(tree_identifier *i=0)
Definition: pt-classdef.h:330
tree_identifier * id
Definition: pt-classdef.h:64
octave_function * make_meta_class(bool is_at_folder=false)
Definition: pt-classdef.cc:236
octave_comment_list * trail_comm
Definition: pt-classdef.h:642
void accept(tree_walker &)
Definition: pt-classdef.cc:135
void accept(tree_walker &)
Definition: pt-classdef.cc:195
void accept(tree_walker &)
Definition: pt-classdef.cc:103
tree_classdef_events_block & operator=(const tree_classdef_events_block &)
Definition: pt.h:35
tree_classdef_enum_list(tree_classdef_enum *e)
Definition: pt-classdef.h:439
tree_classdef_properties_block(tree_classdef_attribute_list *a, tree_classdef_property_list *plist, octave_comment_list *lc, octave_comment_list *tc, int l=-1, int c=-1)
Definition: pt-classdef.h:259
tree_classdef_enum_block(tree_classdef_attribute_list *a, tree_classdef_enum_list *elist, octave_comment_list *lc, octave_comment_list *tc, int l=-1, int c=-1)
Definition: pt-classdef.h:462
tree_classdef_superclass_list & operator=(const tree_classdef_superclass_list &)
void accept(tree_walker &)
Definition: pt-classdef.cc:77
tree_classdef_superclass_list * superclass_list(void)
Definition: pt-classdef.h:615
tree_classdef_methods_list(const octave_value &f)
Definition: pt-classdef.h:285
tree_classdef_enum_list(const octave_base_list< tree_classdef_enum * > &a)
Definition: pt-classdef.h:441
std::list< tree_classdef_enum_block * >::const_iterator enum_list_const_iterator
Definition: pt-classdef.h:495
void accept(tree_walker &)
Definition: pt-classdef.cc:111
octave_base_list< T > * elt_list
Definition: pt-classdef.h:184
void accept(tree_walker &tw)
Definition: pt-classdef.cc:256
tree_identifier * id
Definition: pt-classdef.h:635
std::list< tree_classdef_properties_block * >::const_iterator properties_list_const_iterator
Definition: pt-classdef.h:486
void append(tree_classdef_methods_block *mb)
Definition: pt-classdef.h:531
std::string class_name(void)
Definition: pt-classdef.h:108
size_t context_id
Definition: symtab.h:51
tree_classdef_body(tree_classdef_properties_block *pb)
Definition: pt-classdef.h:500
const std::string & package_name(void) const
Definition: pt-classdef.h:622
void append(tree_classdef_events_block *evb)
Definition: pt-classdef.h:536
tree_classdef_properties_block & operator=(const tree_classdef_properties_block &)
tree_expression * expr
Definition: pt-classdef.h:65
tree_expression * expr
Definition: pt-classdef.h:221
tree_classdef_attribute_list * attribute_list(void)
Definition: pt-classdef.h:611
std::list< tree_classdef_methods_block * >::const_iterator methods_list_const_iterator
Definition: pt-classdef.h:489
std::list< tree_classdef_enum_block * > enum_list(void)
Definition: pt-classdef.h:561
tree_classdef_attribute(tree_identifier *i, bool b)
Definition: pt-classdef.h:45
tree_classdef_methods_block & operator=(const tree_classdef_methods_block &)
tree_classdef & operator=(const tree_classdef &)
tree_classdef_events_block(tree_classdef_attribute_list *a, tree_classdef_events_list *elist, octave_comment_list *lc, octave_comment_list *tc, int l=-1, int c=-1)
Definition: pt-classdef.h:381