Debian Codegraph @

terps/tads/tads3/tct3drv.h

raw symbols SCIP
1 /* $Header: d:/cvsroot/tads/tads3/TCT3DRV.H,v 1.4 1999/07/11 00:46:57 MJRoberts Exp $ */
2
3 /*
4 * Copyright (c) 1999, 2002 Michael J. Roberts. All Rights Reserved.
5 *
6 * Please see the accompanying license file, LICENSE.TXT, for information
7 * on using and copying this software.
8 */
9 /*
10 Name
11 tct3drv.h - derived final T3-specific parse node classes
12 Function
13
14 Notes
15
16 Modified
17 05/10/99 MJRoberts - Creation
18 */
19
20 #ifndef TCT3DRV_H
21 #define TCT3DRV_H
22
23 #include <assert.h>
24
25 /* include our T3-specific intermediate classes */
26 #include "tct3int.h"
27
28 /* include the target-independent derived classes */
29 #include "tcpndrv.h"
30
31
32 /* ------------------------------------------------------------------------ */
33 /*
34 * "self"
35 */
36 class CTPNSelf: public CTPNSelfBase
37 {
38 public:
39 /* generate code */
40 void gen_code(int discard, int for_condition);
41
42 /* generate a member expression */
43 void gen_code_member(int discard,
44 class CTcPrsNode *prop_expr, int prop_is_expr,
45 int argc, int varargs,
46 struct CTcNamedArgs *named_args);
47
48 /* get the object value for a '.' expression */
49 vm_obj_id_t gen_code_obj_predot(int *is_self);
50 };
51
52 /* ------------------------------------------------------------------------ */
53 /*
54 * "replaced"
55 */
56 class CTPNReplaced: public CTPNReplacedBase
57 {
58 public:
59 /* generate code */
60 void gen_code(int discard, int for_condition);
61
62 /* generate a function call expression */
63 void gen_code_call(int discard, int argc, int varargs,
64 struct CTcNamedArgs *named_args);
65 };
66
67 /* ------------------------------------------------------------------------ */
68 /*
69 * "targetprop"
70 */
71 class CTPNTargetprop: public CTPNTargetpropBase
72 {
73 public:
74 /* generate code */
75 void gen_code(int discard, int for_condition);
76 };
77
78
79 /* ------------------------------------------------------------------------ */
80 /*
81 * "targetobj"
82 */
83 class CTPNTargetobj: public CTPNTargetobjBase
84 {
85 public:
86 /* generate code */
87 void gen_code(int discard, int for_condition);
88 };
89
90
91 /* ------------------------------------------------------------------------ */
92 /*
93 * "definingobj"
94 */
95 class CTPNDefiningobj: public CTPNDefiningobjBase
96 {
97 public:
98 /* generate code */
99 void gen_code(int discard, int for_condition);
100 };
101
102
103 /* ------------------------------------------------------------------------ */
104 /*
105 * "invokee"
106 */
107 class CTPNInvokee: public CTPNInvokeeBase
108 {
109 public:
110 /* generate code */
111 void gen_code(int discard, int for_condition);
112 };
113
114
115 /* ------------------------------------------------------------------------ */
116 /*
117 * "inherited"
118 */
119 class CTPNInh: public CTPNInhBase
120 {
121 public:
122 /* generate code */
123 void gen_code(int discard, int for_condition);
124
125 /* generate a member expression */
126 void gen_code_member(int discard,
127 class CTcPrsNode *prop_expr, int prop_is_expr,
128 int argc, int varargs,
129 struct CTcNamedArgs *named_args);
130
131 protected:
132 /* generate a multi-method inherited() call */
133 void gen_code_mminh(CTcSymFunc *func, int discard,
134 class CTcPrsNode *prop_expr, int prop_is_expr,
135 int argc, int varargs, struct CTcNamedArgs *named_args);
136 };
137
138 /*
139 * "inherited" with explicit superclass
140 */
141 class CTPNInhClass: public CTPNInhClassBase
142 {
143 public:
144 CTPNInhClass(const char *sym, size_t len)
145 : CTPNInhClassBase(sym, len) { }
146
147 /* generate code */
148 void gen_code(int discard, int for_condition);
149
150 /* generate a member expression */
151 void gen_code_member(int discard,
152 class CTcPrsNode *prop_expr, int prop_is_expr,
153 int argc, int varargs,
154 struct CTcNamedArgs *named_args);
155 };
156
157 /*
158 * "delegated"
159 */
160 class CTPNDelegated: public CTPNDelegatedBase
161 {
162 public:
163 CTPNDelegated(CTcPrsNode *delegatee)
164 : CTPNDelegatedBase(delegatee) { }
165
166 /* generate code */
167 void gen_code(int discard, int for_condition);
168
169 /* generate a member expression */
170 void gen_code_member(int discard,
171 class CTcPrsNode *prop_expr, int prop_is_expr,
172 int argc, int varargs,
173 struct CTcNamedArgs *named_args);
174 };
175
176 /* ------------------------------------------------------------------------ */
177 /*
178 * "argcount" node
179 */
180 class CTPNArgc: public CTPNArgcBase
181 {
182 public:
183 void gen_code(int discard, int for_condition);
184 };
185
186
187 /* ------------------------------------------------------------------------ */
188 /*
189 * constant node
190 */
191 class CTPNConst: public CTPNConstBase
192 {
193 public:
194 CTPNConst(const CTcConstVal *val) : CTPNConstBase(val) { }
195
196 /* generate code for the constant */
197 void gen_code(int discard, int for_condition);
198
199 /* generate code for operator 'new' applied to this expression */
200 void gen_code_new(int discard, int argc, int varargs,
201 struct CTcNamedArgs *named_args,
202 int from_call, int is_transient);
203
204 /* generate code for assigning to this expression */
205 int gen_code_asi(int discard, int phase, tc_asitype_t typ, const char *op,
206 CTcPrsNode *rhs,
207 int ignore_errors, int xplicit, void **ctx);
208
209 /* evaluate a property ID */
210 vm_prop_id_t gen_code_propid(int check_only, int is_expr);
211
212 /* generate a member expression */
213 void gen_code_member(int discard,
214 class CTcPrsNode *prop_expr, int prop_is_expr,
215 int argc, int varargs,
216 struct CTcNamedArgs *named_args);
217
218 /* generate a function call expression */
219 void gen_code_call(int discard, int argc, int varargs,
220 struct CTcNamedArgs *named_args);
221
222 /* get the object value for a '.' expression */
223 vm_obj_id_t gen_code_obj_predot(int *is_self);
224
225 /* generate code to push an integer constant */
226 static void s_gen_code_int(long intval);
227
228 /* generate code to push a string constant */
229 static void s_gen_code_str(const CTcConstVal *val);
230 static void s_gen_code_str(const char *str, size_t len);
231
232 /* generate code to push a symbol's name as a string constant */
233 static void s_gen_code_str(const class CTcSymbol *sym);
234
235 /*
236 * generate code to push a string, using the correct code for the
237 * current compilation mode (static vs dynamic)
238 */
239 static void s_gen_code_str_by_mode(const class CTcSymbol *sym);
240 };
241
242 /*
243 * Debugger constant node
244 */
245 class CTPNDebugConst: public CTPNConst
246 {
247 public:
248 CTPNDebugConst(CTcConstVal *val) : CTPNConst(val) { }
249
250 /* debugger constants aren't actual constants - they require code gen */
251 CTcConstVal *get_const_val() { return 0; }
252
253 /* generate code for the constant */
254 void gen_code(int discard, int for_condition);
255
256 /* generate a constant string */
257 static void s_gen_code_str(const char *str, size_t len);
258 };
259
260 /* ------------------------------------------------------------------------ */
261 /*
262 * Unary Operators
263 */
264
265 /* bitwise NOT */
266 CTPNUnary_def(CTPNBNot);
267
268 /* arithmetic positive */
269 CTPNUnary_def(CTPNPos);
270
271 /* arithmetic negative */
272 CTPNUnary_def(CTPNNeg);
273
274 /* pre-increment */
275 CTPNUnary_side_def(CTPNPreInc);
276 void CTPNPreInc_gen_code(class CTcPrsNode *sub, int discard);
277
278 /* pre-decrement */
279 CTPNUnary_side_def(CTPNPreDec);
280
281 /* post-increment */
282 CTPNUnary_side_def(CTPNPostInc);
283
284 /* post-decrement */
285 CTPNUnary_side_def(CTPNPostDec);
286
287 /* delete */
288 CTPNUnary_side_def(CTPNDelete);
289
290 /* boolean-ize */
291 CTPNUnary_def(CTPNBoolize);
292
293 /* ------------------------------------------------------------------------ */
294 /*
295 * NEW operator
296 */
297 class CTPNNew: public CTPNUnary
298 {
299 public:
300 CTPNNew(class CTcPrsNode *sub, int is_transient)
301 : CTPNUnary(sub)
302 {
303 /* remember 'transient' status */
304 transient_ = is_transient;
305 }
306
307 /* generate code */
308 void gen_code(int discard, int for_condition);
309
310 /* note that we have side effects */
311 virtual int has_side_effects() const { return TRUE; }
312
313 protected:
314 /* flag: it's a 'new transient' operator */
315 int transient_;
316 };
317
318
319 /* ------------------------------------------------------------------------ */
320 /*
321 * NOT operator
322 */
323 class CTPNNot: public CTPNNotBase
324 {
325 public:
326 CTPNNot(CTcPrsNode *sub) : CTPNNotBase(sub) { }
327
328 /* generate code */
329 void gen_code(int discard, int for_condition);
330 };
331
332
333 /* ------------------------------------------------------------------------ */
334 /*
335 * Binary Operators
336 */
337
338 class CTPNComma: public CTPNCommaBase
339 {
340 public:
341 CTPNComma(class CTcPrsNode *lhs, class CTcPrsNode *rhs)
342 : CTPNCommaBase(lhs, rhs) { }
343
344 /* generate code */
345 void gen_code(int discard, int for_condition);
346 };
347
348 /* bitwise OR */
349 CTPNBin_def(CTPNBOr);
350
351 /* bitwise AND */
352 CTPNBin_def(CTPNBAnd);
353
354 /* bitwise XOR */
355 CTPNBin_def(CTPNBXor);
356
357 /* greater than */
358 CTPNBin_cmp_def(CTPNGt);
359
360 /* greater or equal */
361 CTPNBin_cmp_def(CTPNGe);
362
363 /* less than */
364 CTPNBin_cmp_def(CTPNLt);
365
366 /* less or equal */
367 CTPNBin_cmp_def(CTPNLe);
368
369 /* bit shift left */
370 CTPNBin_def(CTPNShl);
371
372 /* arithmetic shift right */
373 CTPNBin_def(CTPNAShr);
374
375 /* logical shift right */
376 CTPNBin_def(CTPNLShr);
377
378 /* multiply */
379 CTPNBin_def(CTPNMul);
380
381 /* divide */
382 CTPNBin_def(CTPNDiv);
383
384 /* modulo */
385 CTPNBin_def(CTPNMod);
386
387 /* ------------------------------------------------------------------------ */
388 /*
389 * Addition
390 */
391
392 class CTPNAdd: public CTPNAddBase
393 {
394 public:
395 CTPNAdd(class CTcPrsNode *left, class CTcPrsNode *right)
396 : CTPNAddBase(left, right) { }
397
398 /* generate code */
399 void gen_code(int discard, int for_condition);
400 };
401
402
403 /* ------------------------------------------------------------------------ */
404 /*
405 * Subtraction
406 */
407
408 class CTPNSub: public CTPNSubBase
409 {
410 public:
411 CTPNSub(class CTcPrsNode *left, class CTcPrsNode *right)
412 : CTPNSubBase(left, right) { }
413
414 /* generate code */
415 void gen_code(int discard, int for_condition);
416 };
417
418 /* ------------------------------------------------------------------------ */
419 /*
420 * Equality Comparison
421 */
422
423 class CTPNEq: public CTPNEqBase
424 {
425 public:
426 CTPNEq(class CTcPrsNode *left, class CTcPrsNode *right)
427 : CTPNEqBase(left, right) { }
428
429 /* generate code */
430 void gen_code(int discard, int for_condition);
431 };
432
433
434 /* ------------------------------------------------------------------------ */
435 /*
436 * Inequality Comparison
437 */
438
439 class CTPNNe: public CTPNNeBase
440 {
441 public:
442 CTPNNe(class CTcPrsNode *left, class CTcPrsNode *right)
443 : CTPNNeBase(left, right) { }
444
445 /* generate code */
446 void gen_code(int discard, int for_condition);
447 };
448
449 /* ------------------------------------------------------------------------ */
450 /*
451 * 'is in'
452 */
453
454 class CTPNIsIn: public CTPNIsInBase
455 {
456 public:
457 CTPNIsIn(class CTcPrsNode *left, class CTPNArglist *right)
458 : CTPNIsInBase(left, right) { }
459
460 /* generate code */
461 void gen_code(int discard, int for_condition);
462 };
463
464
465 /* ------------------------------------------------------------------------ */
466 /*
467 * 'not in'
468 */
469
470 class CTPNNotIn: public CTPNNotInBase
471 {
472 public:
473 CTPNNotIn(class CTcPrsNode *left, class CTPNArglist *right)
474 : CTPNNotInBase(left, right) { }
475
476 /* generate code */
477 void gen_code(int discard, int for_condition);
478 };
479
480
481 /* ------------------------------------------------------------------------ */
482 /*
483 * Logical AND (short-circuit logic)
484 */
485
486 class CTPNAnd: public CTPNAndBase
487 {
488 public:
489 CTPNAnd(class CTcPrsNode *left, class CTcPrsNode *right)
490 : CTPNAndBase(left, right) { }
491
492 /* generate code */
493 void gen_code(int discard, int for_condition);
494
495 /* generate a condition */
496 virtual void gen_code_cond(struct CTcCodeLabel *then_label,
497 struct CTcCodeLabel *else_label);
498 };
499
500
501 /* ------------------------------------------------------------------------ */
502 /*
503 * Logical OR (short-circuit logic)
504 */
505
506 class CTPNOr: public CTPNOrBase
507 {
508 public:
509 CTPNOr(class CTcPrsNode *left, class CTcPrsNode *right)
510 : CTPNOrBase(left, right) { }
511
512 /* generate code */
513 void gen_code(int discard, int for_condition);
514
515 /* generate a condition */
516 virtual void gen_code_cond(struct CTcCodeLabel *then_label,
517 struct CTcCodeLabel *else_label);
518 };
519
520
521 /* ------------------------------------------------------------------------ */
522 /*
523 * Assignment Operators
524 */
525
526 /* simple assignment */
527 class CTPNAsi: public CTPNAsiBase
528 {
529 public:
530 CTPNAsi(class CTcPrsNode *left, class CTcPrsNode *right)
531 : CTPNAsiBase(left, right) { }
532
533 /* generate code */
534 void gen_code(int discard, int for_condition);
535 };
536
537 /* add and assign */
538 CTPNBin_side_def(CTPNAddAsi);
539 void CTPNAddAsi_gen_code(class CTcPrsNode *left, class CTcPrsNode *right,
540 int discard);
541
542 /* subtract and assign */
543 CTPNBin_side_def(CTPNSubAsi);
544
545 /* multiple and assign */
546 CTPNBin_side_def(CTPNMulAsi);
547
548 /* divide and assign */
549 CTPNBin_side_def(CTPNDivAsi);
550
551 /* modulo and assign */
552 CTPNBin_side_def(CTPNModAsi);
553
554 /* bitwise AND and assign */
555 CTPNBin_side_def(CTPNBAndAsi);
556
557 /* bitwise OR and assign */
558 CTPNBin_side_def(CTPNBOrAsi);
559
560 /* bitwise XOR and assign */
561 CTPNBin_side_def(CTPNBXorAsi);
562
563 /* bit shift left and assign */
564 CTPNBin_side_def(CTPNShlAsi);
565
566 /* arithmetic shift right and assign */
567 CTPNBin_side_def(CTPNAShrAsi);
568
569 /* logical shift right and assign */
570 CTPNBin_side_def(CTPNLShrAsi);
571
572 /* ------------------------------------------------------------------------ */
573 /*
574 * Array/list Subscript
575 */
576 class CTPNSubscript: public CTPNSubscriptBase
577 {
578 public:
579 CTPNSubscript(CTcPrsNode *lhs, CTcPrsNode *rhs)
580 : CTPNSubscriptBase(lhs, rhs) { }
581
582 /* generate code */
583 void gen_code(int discard, int for_condition);
584
585 /* generate code to assign a value to the symbol */
586 int gen_code_asi(int discard, int phase, tc_asitype_t typ, const char *op,
587 CTcPrsNode *rhs,
588 int ignore_errors, int xplicit, void **ctx);
589 };
590
591
592 /* ------------------------------------------------------------------------ */
593 /*
594 * Address-of Operator
595 */
596
597 class CTPNAddr: public CTPNAddrBase
598 {
599 public:
600 CTPNAddr(CTcPrsNode *sub)
601 : CTPNAddrBase(sub) { }
602
603 /* generate code */
604 void gen_code(int discard, int for_condition)
605 {
606 /*
607 * if we're not discarding the value, tell the subnode to
608 * generate its address; if the value is being discarded, do
609 * nothing, since taking an address has no side effects
610 */
611 if (!discard)
612 sub_->gen_code_addr();
613 }
614
615 /* generate a member expression */
616 void gen_code_member(int discard,
617 class CTcPrsNode *prop_expr, int prop_is_expr,
618 int argc, int varargs,
619 struct CTcNamedArgs *named_args)
620 {
621 /*
622 * let the subnode do the work, since "&obj" is the same as
623 * "obj" in any context
624 */
625 sub_->gen_code_member(discard, prop_expr, prop_is_expr,
626 argc, varargs, named_args);
627 }
628
629 /* evaluate a property ID */
630 vm_prop_id_t gen_code_propid(int check_only, int is_expr)
631 {
632 /*
633 * let the subexpression handle it, so that we treat "x.&prop"
634 * the same as "x.prop"
635 */
636 return sub_->gen_code_propid(check_only, is_expr);
637 }
638
639 /* get the object value for a '.' expression */
640 vm_obj_id_t gen_code_obj_predot(int *is_self)
641 {
642 /*
643 * let the subexpression handle it, since "x.&prop" is the same
644 * as "x.prop"
645 */
646 return sub_->gen_code_obj_predot(is_self);
647 }
648 };
649
650 /* ------------------------------------------------------------------------ */
651 /*
652 * If-nil operator ??
653 */
654 class CTPNIfnil: public CTPNIfnilBase
655 {
656 public:
657 CTPNIfnil(class CTcPrsNode *first, class CTcPrsNode *second)
658 : CTPNIfnilBase(first, second) { }
659
660 /* generate code for the conditional */
661 void gen_code(int discard, int for_condition);
662 };
663
664 /* ------------------------------------------------------------------------ */
665 /*
666 * Conditional Operator
667 */
668 class CTPNIf: public CTPNIfBase
669 {
670 public:
671 CTPNIf(class CTcPrsNode *first, class CTcPrsNode *second,
672 class CTcPrsNode *third)
673 : CTPNIfBase(first, second, third) { }
674
675 /* generate code for the conditional */
676 void gen_code(int discard, int for_condition);
677 };
678
679 /* ------------------------------------------------------------------------ */
680 /*
681 * Symbol node
682 */
683 class CTPNSym: public CTPNSymBase
684 {
685 public:
686 CTPNSym(const char *sym, size_t len)
687 : CTPNSymBase(sym, len) { }
688
689 /* generate code for the symbol evaluated as an rvalue */
690 void gen_code(int discard, int for_condition);
691
692 /* generate code to assign a value to the symbol */
693 int gen_code_asi(int discard, int phase, tc_asitype_t typ, const char *op,
694 CTcPrsNode *rhs,
695 int ignore_errors, int xplicit, void **ctx);
696
697 /* generate code to take the address of the symbol */
698 void gen_code_addr();
699
700 /* generate code to call the symbol */
701 void gen_code_call(int discard, int argc, int varargs,
702 struct CTcNamedArgs *named_args);
703
704 /* generate code for operator 'new' applied to this expression */
705 void gen_code_new(int discard, int argc, int varargs,
706 struct CTcNamedArgs *named_args,
707 int from_call, int is_transient);
708
709 /* evaluate a property ID */
710 vm_prop_id_t gen_code_propid(int check_only, int is_expr);
711
712 /* generate a member expression */
713 void gen_code_member(int discard,
714 class CTcPrsNode *prop_expr, int prop_is_expr,
715 int argc, int varargs,
716 struct CTcNamedArgs *named_args);
717
718 /* get the object value for a '.' expression */
719 vm_obj_id_t gen_code_obj_predot(int *is_self);
720 };
721
722 /* ------------------------------------------------------------------------ */
723 /*
724 * Resolved symbol
725 */
726 class CTPNSymResolved: public CTPNSymResolvedBase
727 {
728 public:
729 CTPNSymResolved(CTcSymbol *sym)
730 : CTPNSymResolvedBase(sym) { }
731
732 /* generate code for the symbol evaluated as an rvalue */
733 void gen_code(int discard, int for_condition);
734
735 /* generate code to assign a value to the symbol */
736 int gen_code_asi(int discard, int phase, tc_asitype_t typ, const char *op,
737 CTcPrsNode *rhs,
738 int ignore_errors, int xplicit, void **ctx);
739
740 /* generate code to take the address of the symbol */
741 void gen_code_addr();
742
743 /* generate code to call the symbol */
744 void gen_code_call(int discard, int argc, int varargs,
745 struct CTcNamedArgs *named_args);
746
747 /* generate code for operator 'new' applied to this expression */
748 void gen_code_new(int discard, int argc, int varargs,
749 struct CTcNamedArgs *named_args,
750 int from_call, int is_transient);
751
752 /* evaluate a property ID */
753 vm_prop_id_t gen_code_propid(int check_only, int is_expr);
754
755 /* generate a member expression */
756 void gen_code_member(int discard,
757 class CTcPrsNode *prop_expr, int prop_is_expr,
758 int argc, int varargs,
759 struct CTcNamedArgs *named_args);
760
761 /* get the object value for a '.' expression */
762 vm_obj_id_t gen_code_obj_predot(int *is_self);
763 };
764
765 /* ------------------------------------------------------------------------ */
766 /*
767 * Resolved debugger local variable symbol
768 */
769 class CTPNSymDebugLocal: public CTPNSymDebugLocalBase
770 {
771 public:
772 CTPNSymDebugLocal(const struct tcprsdbg_sym_info *info)
773 : CTPNSymDebugLocalBase(info)
774 {
775 }
776
777 /* generate code */
778 void gen_code(int discard, int for_condition);
779
780 /* generate code for assigning into this node */
781 int gen_code_asi(int discard, int phase, tc_asitype_t typ, const char *op,
782 class CTcPrsNode *rhs,
783 int ignore_errors, int xplicit, void **ctx);
784 };
785
786 /* ------------------------------------------------------------------------ */
787 /*
788 * double-quoted string expression
789 */
790 class CTPNDstr: public CTPNDstrBase
791 {
792 public:
793 CTPNDstr(const char *str, size_t len)
794 : CTPNDstrBase(str, len) { }
795
796 void gen_code(int discard, int for_condition);
797 };
798
799 /*
800 * debug version of string
801 */
802 class CTPNDebugDstr: public CTPNDstr
803 {
804 public:
805 CTPNDebugDstr(const char *str, size_t len)
806 : CTPNDstr(str, len) { }
807
808 void gen_code(int discard, int for_condition);
809 };
810
811 /*
812 * double-quoted string embedding
813 */
814 class CTPNDstrEmbed: public CTPNDstrEmbedBase
815 {
816 public:
817 CTPNDstrEmbed(CTcPrsNode *sub);
818
819 void gen_code(int discard, int for_condition);
820 };
821
822 /* ------------------------------------------------------------------------ */
823 /*
824 * Embedded <<one of>> list in a string
825 */
826 class CTPNStrOneOf: public CTPNStrOneOfBase
827 {
828 public:
829 CTPNStrOneOf(int dstr, class CTPNList *lst, class CTcSymObj *state_obj)
830 : CTPNStrOneOfBase(dstr, lst, state_obj) { }
831
832 void gen_code(int discard, int for_condition);
833 };
834
835 /* ------------------------------------------------------------------------ */
836 /*
837 * Argument List
838 */
839 class CTPNArglist: public CTPNArglistBase
840 {
841 public:
842 CTPNArglist(int argc, class CTPNArg *list_head)
843 : CTPNArglistBase(argc, list_head) { }
844
845 void gen_code(int, int)
846 {
847 /*
848 * this isn't used - we always generate explicitly via
849 * gen_code_arglist()
850 */
851 assert(FALSE);
852 }
853
854 /* generate code for an argument list */
855 void gen_code_arglist(int *varargs, struct CTcNamedArgs &named_args);
856 };
857
858 /*
859 * Argument List Entry
860 */
861 class CTPNArg: public CTPNArgBase
862 {
863 public:
864 CTPNArg(CTcPrsNode *expr)
865 : CTPNArgBase(expr) { }
866
867 void gen_code(int discard, int for_condition);
868 };
869
870 /* ------------------------------------------------------------------------ */
871 /*
872 * Function/method call
873 */
874 class CTPNCall: public CTPNCallBase
875 {
876 public:
877 CTPNCall(CTcPrsNode *func, class CTPNArglist *arglist);
878
879 /* generate code */
880 void gen_code(int discard, int for_condition);
881
882 /* generate code for operator 'new' applied to this expression */
883 void gen_code_new(int discard, int argc, int varargs,
884 struct CTcNamedArgs *named_args,
885 int from_call, int is_transient);
886
887 /* generate code for a call to 'rand' */
888 int gen_code_rand(int discard, int for_condition);
889 };
890
891
892 /* ------------------------------------------------------------------------ */
893 /*
894 * Member expression with no arguments
895 */
896 class CTPNMember: public CTPNMemberBase
897 {
898 public:
899 CTPNMember(CTcPrsNode *lhs, CTcPrsNode *rhs, int rhs_is_expr)
900 : CTPNMemberBase(lhs, rhs, rhs_is_expr) { }
901
902 /* generate code */
903 void gen_code(int discard, int for_condition);
904
905 /* generate code to assign a value to the symbol */
906 int gen_code_asi(int discard, int phase, tc_asitype_t typ, const char *op,
907 CTcPrsNode *rhs,
908 int ignore_errors, int xplicit, void **ctx);
909 };
910
911 /*
912 * Member evaluation with argument list
913 */
914 class CTPNMemArg: public CTPNMemArgBase
915 {
916 public:
917 CTPNMemArg(CTcPrsNode *obj_expr, CTcPrsNode *prop_expr, int prop_is_expr,
918 class CTPNArglist *arglist)
919 : CTPNMemArgBase(obj_expr, prop_expr, prop_is_expr, arglist) { }
920
921 void gen_code(int discard, int for_condition);
922 };
923
924
925 /* ------------------------------------------------------------------------ */
926 /*
927 * List
928 */
929 class CTPNList: public CTPNListBase
930 {
931 public:
932 void gen_code(int discard, int for_condition);
933 };
934
935 /*
936 * List Element
937 */
938 class CTPNListEle: public CTPNListEleBase
939 {
940 public:
941 CTPNListEle(CTcPrsNode *expr)
942 : CTPNListEleBase(expr) { }
943
944 void gen_code(int discard, int for_condition);
945 };
946
947 /* ------------------------------------------------------------------------ */
948 /*
949 * Derived T3-specific symbol classes
950 */
951
952 /*
953 * undefined symbol
954 */
955 class CTcSymUndef: public CTcSymUndefBase
956 {
957 public:
958 CTcSymUndef(const char *str, size_t len, int copy)
959 : CTcSymUndefBase(str, len, copy) { }
960
961 /*
962 * generate code to evaluate the symbol; since it's undefined, this
963 * doesn't generate any code at all
964 */
965 virtual void gen_code(int) { }
966
967 /*
968 * Generate code to assign to the symbol. The symbol is undefined,
969 * so we can't generate any code; but we'll indicate to the caller
970 * that the assignment is fully processed anyway, since there's no
971 * need for the caller to try generating any code either.
972 */
973 virtual int gen_code_asi(int, int phase, tc_asitype_t, const char *,
974 class CTcPrsNode *, int, int, void **)
975 {
976 return TRUE;
977 }
978
979 /*
980 * Generate code for taking the address of the symbol. The symbol
981 * has no address, so this generates no code.
982 */
983 virtual void gen_code_addr() { }
984
985 /*
986 * generate code to call the symbol - we can't generate any code for
987 * this, but don't bother issuing an error since we will have shown
988 * an error for the undefined symbol in the first place
989 */
990 virtual void gen_code_call(int, int, int, struct CTcNamedArgs *) { }
991
992 /*
993 * generate code for operator 'new' applied to this expression - we
994 * can't generate any code, but suppress errors as usual
995 */
996 void gen_code_new(int, int, int, struct CTcNamedArgs *, int) { }
997
998 /* generate a member expression */
999 void gen_code_member(int, class CTcPrsNode *, int, int, int,
1000 struct CTcNamedArgs *) { }
1001
1002 /* get the object value for a '.' expression */
1003 vm_obj_id_t gen_code_obj_predot(int *is_self)
1004 {
1005 *is_self = FALSE;
1006 return VM_INVALID_OBJ;
1007 }
1008 };
1009
1010
1011 /*
1012 * function
1013 */
1014 class CTcSymFunc: public CTcSymFuncBase
1015 {
1016 public:
1017 CTcSymFunc(const char *str, size_t len, int copy,
1018 int argc, int opt_argc, int varargs, int has_retval,
1019 int is_multimethod, int is_mm_base,
1020 int is_extern, int has_proto)
1021 : CTcSymFuncBase(str, len, copy, argc, opt_argc, varargs, has_retval,
1022 is_multimethod, is_mm_base, is_extern, has_proto)
1023 {
1024 /*
1025 * we don't have a valid absolute address - by default, we use
1026 * the anchor
1027 */
1028 abs_addr_valid_ = FALSE;
1029 abs_addr_ = 0;
1030 }
1031
1032 /* generate code to evaluate the symbol */
1033 virtual void gen_code(int discard);
1034
1035 /* we can take the address of this symbol type */
1036 virtual void gen_code_addr();
1037
1038 /* generate a call */
1039 virtual void gen_code_call(int discard, int argc, int varargs,
1040 struct CTcNamedArgs *named_args);
1041
1042 /*
1043 * Get my code pool address. This is valid only after the linking
1044 * phase has been completed and all fixups have been applied. (The
1045 * normal use for this is to generate image file elements not
1046 * subject to fixup, such as the entrypoint record. Normally,
1047 * references to the symbol that require the code pool address would
1048 * simply generate a fixup rather than asking for the true address,
1049 * since a fixup can be generated at any time during code
1050 * generation.)
1051 */
1052 ulong get_code_pool_addr() const;
1053
1054 /* write the symbol to an image file's global symbol table */
1055 int write_to_image_file_global(class CVmImageWriter *image_writer);
1056
1057 /*
1058 * Set the absolute code pool address. This can only be used when
1059 * the symbol is loaded from a fully-linked image file; in most
1060 * cases, this routine is not needed, because the function's address
1061 * will be kept with its associated anchor to allow for relocation
1062 * of the function during the linking process.
1063 */
1064 void set_abs_addr(uint32_t addr)
1065 {
1066 /* remember the address */
1067 abs_addr_ = addr;
1068
1069 /* note that the absolute address is valid */
1070 abs_addr_valid_ = TRUE;
1071 }
1072
1073 /* add a runtime symbol table entry */
1074 void add_runtime_symbol(class CVmRuntimeSymbols *symtab);
1075
1076 protected:
1077 /*
1078 * Absolute code pool address, and a flag indicating whether the
1079 * address is valid. When we load a function symbol from a
1080 * fully-linked image file (specifically, when we load the symbol
1081 * from the debug records of an image file), the address of the
1082 * function is fully resolved and doesn't require fixups via the
1083 * anchor mechanism. In these cases, we'll simply remember the
1084 * resolved address here.
1085 */
1086 ulong abs_addr_;
1087 uint abs_addr_valid_ : 1;
1088 };
1089
1090 /*
1091 * metaclass
1092 */
1093 class CTcSymMetaclass: public CTcSymMetaclassBase
1094 {
1095 public:
1096 CTcSymMetaclass(const char *str, size_t len, int copy, int meta_idx,
1097 tctarg_obj_id_t class_obj)
1098 : CTcSymMetaclassBase(str, len, copy, meta_idx, class_obj)
1099 {
1100 }
1101
1102 /* generate code to evaluate the symbol */
1103 virtual void gen_code(int discard);
1104
1105 /* generate code for operator 'new' */
1106 void gen_code_new(int discard, int argc, int varargs,
1107 struct CTcNamedArgs *named_args,
1108 int is_transient);
1109
1110 /* generate a member expression */
1111 void gen_code_member(int discard,
1112 class CTcPrsNode *prop_expr, int prop_is_expr,
1113 int argc, int varargs,
1114 struct CTcNamedArgs *named_args);
1115
1116 /* get the object value for a '.' expression */
1117 vm_obj_id_t gen_code_obj_predot(int *is_self)
1118 {
1119 /* simply generate our code as normal */
1120 gen_code(FALSE);
1121
1122 /* indicate that the caller must use generated code */
1123 *is_self = FALSE;
1124 return VM_INVALID_OBJ;
1125 }
1126
1127 /* write the symbol to an image file's global symbol table */
1128 int write_to_image_file_global(class CVmImageWriter *image_writer);
1129
1130 /*
1131 * fix up the inheritance chain in the modifier objects - each
1132 * object file has its own independent inheritance list, so we can
1133 * only build the complete and connected list after loading them all
1134 */
1135 void fix_mod_obj_sc_list();
1136
1137 /* add a runtime symbol table entry */
1138 void add_runtime_symbol(class CVmRuntimeSymbols *symtab);
1139 };
1140
1141 /*
1142 * object
1143 */
1144 class CTcSymObj: public CTcSymObjBase
1145 {
1146 public:
1147 CTcSymObj(const char *str, size_t len, int copy, vm_obj_id_t obj_id,
1148 int is_extern, tc_metaclass_t meta, class CTcDictEntry *dict)
1149 : CTcSymObjBase(str, len, copy, obj_id, is_extern, meta, dict)
1150 {
1151 }
1152
1153 /* we have a valid object value */
1154 virtual vm_obj_id_t get_val_obj() const { return get_obj_id(); }
1155
1156 /* generate code to evaluate the symbol */
1157 virtual void gen_code(int discard);
1158
1159 /* we can take the address of this symbol type */
1160 virtual void gen_code_addr();
1161
1162 /* generate code for operator 'new' */
1163 void gen_code_new(int discard, int argc, int varargs,
1164 struct CTcNamedArgs *named_args,
1165 int is_transient);
1166
1167 /* static code to generate code for 'new' */
1168 static void s_gen_code_new(int discard, vm_obj_id_t obj_id,
1169 tc_metaclass_t meta,
1170 int argc, int varargs,
1171 struct CTcNamedArgs *named_args,
1172 int is_transient);
1173
1174 /* generate a member expression */
1175 void gen_code_member(int discard,
1176 class CTcPrsNode *prop_expr, int prop_is_expr,
1177 int argc, int varargs,
1178 struct CTcNamedArgs *named_args);
1179
1180 /* static code to generate a member expression */
1181 static void s_gen_code_member(int discard,
1182 class CTcPrsNode *prop_expr,
1183 int prop_is_expr, int argc,
1184 vm_obj_id_t obj_id,
1185 int varargs, struct CTcNamedArgs *named_args);
1186
1187 /* get the object value for a '.' expression */
1188 vm_obj_id_t gen_code_obj_predot(int *is_self);
1189
1190 /* delete a property from our modified base classes */
1191 virtual void delete_prop_from_mod_base(tctarg_prop_id_t prop_id);
1192
1193 /* mark the compiled data for the object as a 'class' object */
1194 virtual void mark_compiled_as_class();
1195
1196 /* write the symbol to an image file's global symbol table */
1197 int write_to_image_file_global(class CVmImageWriter *image_writer);
1198
1199 /* build my dictionary */
1200 virtual void build_dictionary();
1201
1202 /* add a runtime symbol table entry */
1203 void add_runtime_symbol(class CVmRuntimeSymbols *symtab);
1204 };
1205
1206 /*
1207 * Function-like object symbol. This is an object that's invokable as a
1208 * function, such as an anonymous function object or a DynamicFunc
1209 * instance. These occur in the dynamic compiler only.
1210 */
1211 class CTcSymFuncObj: public CTcSymObj
1212 {
1213 public:
1214 CTcSymFuncObj(const char *str, size_t len, int copy, vm_obj_id_t obj_id,
1215 int is_extern, tc_metaclass_t meta, class CTcDictEntry *dict)
1216 : CTcSymObj(str, len, copy, obj_id, is_extern, meta, dict)
1217 {
1218 }
1219
1220 /* generate a call */
1221 virtual void gen_code_call(int discard, int argc, int varargs,
1222 struct CTcNamedArgs *named_args);
1223 };
1224
1225 /*
1226 * property
1227 */
1228 class CTcSymProp: public CTcSymPropBase
1229 {
1230 public:
1231 CTcSymProp(const char *str, size_t len, int copy, tctarg_prop_id_t prop)
1232 : CTcSymPropBase(str, len, copy, prop) { }
1233
1234 /* generate code to evaluate the symbol */
1235 virtual void gen_code(int discard);
1236
1237 /* we can take the address of this symbol type */
1238 virtual void gen_code_addr();
1239
1240 /* assign to the property */
1241 virtual int gen_code_asi(int discard, int phase,
1242 tc_asitype_t typ, const char *op,
1243 class CTcPrsNode *rhs,
1244 int ignore_errors, int xplicit, void **ctx);
1245
1246 /* generate a call */
1247 virtual void gen_code_call(int discard, int argc, int varargs,
1248 struct CTcNamedArgs *named_args);
1249
1250 /* evaluate a property ID */
1251 vm_prop_id_t gen_code_propid(int check_only, int is_expr);
1252
1253 /* generate a member expression */
1254 void gen_code_member(int discard,
1255 class CTcPrsNode *prop_expr, int prop_is_expr,
1256 int argc, int varargs,
1257 struct CTcNamedArgs *named_args);
1258
1259 /* get the object value for a '.' expression */
1260 vm_obj_id_t gen_code_obj_predot(int *is_self)
1261 {
1262 /* simply generate our code as normal */
1263 gen_code(FALSE);
1264
1265 /* indicate that the caller must use generated code */
1266 *is_self = FALSE;
1267 return VM_INVALID_OBJ;
1268 }
1269
1270 /* write the symbol to an image file's global symbol table */
1271 int write_to_image_file_global(class CVmImageWriter *image_writer);
1272
1273 /* add a runtime symbol table entry */
1274 void add_runtime_symbol(class CVmRuntimeSymbols *symtab);
1275 };
1276
1277 /*
1278 * Enumerator
1279 */
1280 class CTcSymEnum: public CTcSymEnumBase
1281 {
1282 public:
1283 CTcSymEnum(const char *str, size_t len, int copy, ulong id, int is_token)
1284 : CTcSymEnumBase(str, len, copy, id, is_token)
1285 {
1286 }
1287
1288 /* generate code */
1289 virtual void gen_code(int discard);
1290
1291 /* write the symbol to an image file's global symbol table */
1292 int write_to_image_file_global(class CVmImageWriter *image_writer);
1293
1294 /* add a runtime symbol table entry */
1295 void add_runtime_symbol(class CVmRuntimeSymbols *symtab);
1296 };
1297
1298 /*
1299 * local variable/parameter
1300 */
1301 class CTcSymLocal: public CTcSymLocalBase
1302 {
1303 public:
1304 CTcSymLocal(const char *str, size_t len, int copy,
1305 int is_param, int var_num)
1306 : CTcSymLocalBase(str, len, copy, is_param, var_num) { }
1307
1308 /* generate code to evaluate the symbol */
1309 virtual void gen_code(int discard);
1310
1311 /* generate code to store the value at top of stack in the variable */
1312 void gen_code_setlcl_stk() { s_gen_code_setlcl_stk(var_num_, is_param_); }
1313
1314 /* generate code to get a local with a given ID */
1315 static void s_gen_code_getlcl(int local_id, int is_param);
1316
1317 /* generate code to store a local with a given ID */
1318 static void s_gen_code_setlcl_stk(int local_id, int is_param);
1319
1320 /* generate code to store the value at top of stack in the local */
1321 void gen_code_setlcl();
1322
1323 /* assign to the variable */
1324 virtual int gen_code_asi(int discard, int phase,
1325 tc_asitype_t typ, const char *op,
1326 class CTcPrsNode *rhs,
1327 int ignore_errors, int xplicit,
1328 void **ctx);
1329
1330 /*
1331 * generate a call - invoking a local as a function assumes that the
1332 * local contains a method or function pointer
1333 */
1334 virtual void gen_code_call(int discard, int argc, int varargs,
1335 struct CTcNamedArgs *named_args);
1336
1337 /* evaluate a property ID */
1338 vm_prop_id_t gen_code_propid(int check_only, int is_expr);
1339
1340 /* generate a member expression */
1341 void gen_code_member(int discard,
1342 class CTcPrsNode *prop_expr, int prop_is_expr,
1343 int argc, int varargs,
1344 struct CTcNamedArgs *named_args);
1345
1346 /* get the object value for a '.' expression */
1347 vm_obj_id_t gen_code_obj_predot(int *is_self)
1348 {
1349 /* simply generate our code as normal */
1350 gen_code(FALSE);
1351
1352 /* indicate that the caller must use generated code */
1353 *is_self = FALSE;
1354 return VM_INVALID_OBJ;
1355 }
1356
1357 /* write the symbol to a debug frame */
1358 virtual int write_to_debug_frame(int test_only);
1359 };
1360
1361 /*
1362 * Run-time dynamic code local variable symbol. This is the symbol type
1363 * for a local accessed via a StackFrameRef object, for use in DynamicFunc
1364 * compilations.
1365 */
1366 class CTcSymDynLocal: public CTcSymDynLocalBase
1367 {
1368 public:
1369 CTcSymDynLocal(const char *str, size_t len, int copy,
1370 tctarg_obj_id_t fref, int varnum, int ctxidx)
1371 : CTcSymDynLocalBase(str, len, copy, fref, varnum, ctxidx)
1372 {
1373 }
1374
1375 /* generate code */
1376 void gen_code(int discard);
1377
1378 /* generate code for assigning into this node */
1379 int gen_code_asi(int discard, int phase, tc_asitype_t typ, const char *op,
1380 class CTcPrsNode *rhs,
1381 int ignore_errors, int xplicit, void **ctx);
1382 };
1383
1384 /*
1385 * built-in function
1386 */
1387 class CTcSymBif: public CTcSymBifBase
1388 {
1389 public:
1390 CTcSymBif(const char *str, size_t len, int copy,
1391 ushort func_set_id, ushort func_idx, int has_retval,
1392 int min_argc, int max_argc, int varargs)
1393 : CTcSymBifBase(str, len, copy, func_set_id, func_idx,
1394 has_retval, min_argc, max_argc, varargs) { }
1395
1396 /* generate code to evaluate the symbol */
1397 virtual void gen_code(int discard);
1398
1399 /* generate a call */
1400 virtual void gen_code_call(int discard, int argc, int varargs,
1401 struct CTcNamedArgs *named_args);
1402
1403 /* generate code for an address '&' operator */
1404 virtual void gen_code_addr();
1405
1406 /* write the symbol to an image file's global symbol table */
1407 int write_to_image_file_global(class CVmImageWriter *image_writer);
1408
1409 /* add a runtime symbol table entry */
1410 void add_runtime_symbol(class CVmRuntimeSymbols *symtab);
1411
1412 };
1413
1414 /*
1415 * external function
1416 */
1417 class CTcSymExtfn: public CTcSymExtfnBase
1418 {
1419 public:
1420 CTcSymExtfn(const char *str, size_t len, int copy,
1421 int argc, int varargs, int has_retval)
1422 : CTcSymExtfnBase(str, len, copy, argc, varargs, has_retval) { }
1423
1424 /* generate code to evaluate the symbol */
1425 virtual void gen_code(int discard);
1426
1427 /* generate a call */
1428 virtual void gen_code_call(int discard, int argc, int varargs,
1429 struct CTcNamedArgs *named_args);
1430
1431 /* write the symbol to an image file's global symbol table */
1432 int write_to_image_file_global(class CVmImageWriter *image_writer);
1433 };
1434
1435 /*
1436 * code label
1437 */
1438 class CTcSymLabel: public CTcSymLabelBase
1439 {
1440 public:
1441 CTcSymLabel(const char *str, size_t len, int copy)
1442 : CTcSymLabelBase(str, len, copy) { }
1443
1444 /* generate code to evaluate the symbol */
1445 virtual void gen_code(int discard);
1446 };
1447
1448 /* ------------------------------------------------------------------------ */
1449 /*
1450 * Anonymous function
1451 */
1452 class CTPNAnonFunc: public CTPNAnonFuncBase
1453 {
1454 public:
1455 CTPNAnonFunc(class CTPNCodeBody *code_body, int has_retval, int is_method)
1456 : CTPNAnonFuncBase(code_body, has_retval, is_method)
1457 {
1458 }
1459
1460 /* generate code */
1461 virtual void gen_code(int discard, int for_condition);
1462 };
1463
1464 /* ------------------------------------------------------------------------ */
1465 /*
1466 * Code Body
1467 */
1468 class CTPNCodeBody: public CTPNCodeBodyBase
1469 {
1470 public:
1471 CTPNCodeBody(class CTcPrsSymtab *lcltab, class CTcPrsSymtab *gototab,
1472 class CTPNStm *stm, int argc, int opt_argc, int varargs,
1473 int varargs_list, class CTcSymLocal *varargs_list_local,
1474 int local_cnt, int self_valid,
1475 struct CTcCodeBodyRef *enclosing_code_body)
1476 : CTPNCodeBodyBase(lcltab, gototab, stm, argc, opt_argc, varargs,
1477 varargs_list, varargs_list_local,
1478 local_cnt, self_valid, enclosing_code_body)
1479 {
1480 /* presume I'm not a constructor */
1481 is_constructor_ = FALSE;
1482
1483 /* presume I won't need a 'finally' return value holder local */
1484 allocated_fin_ret_lcl_ = FALSE;
1485 fin_ret_lcl_ = 0;
1486
1487 /* presume it won't be static */
1488 is_static_ = FALSE;
1489
1490 /* no nested symbol table list yet */
1491 first_nested_symtab_ = 0;
1492
1493 /* no named argument tables yet */
1494 named_arg_tables_ = 0;
1495 }
1496
1497 /*
1498 * Mark the code body as belonging to a constructor. A constructor
1499 * must return its 'self' object as the return value.
1500 */
1501 void set_constructor(int f) { is_constructor_ = f; }
1502
1503 /*
1504 * mark the code body as static - this indicates that it is a static
1505 * initializer
1506 */
1507 void set_static() { is_static_ = TRUE; }
1508
1509 /* generate code */
1510 virtual void gen_code(int discard, int for_condition);
1511
1512 /* check locals */
1513 virtual void check_locals();
1514
1515 /*
1516 * Allocate a local variable for temporarily saving the expression
1517 * value of a 'return' statement while calling the enclosing
1518 * 'finally' block(s). Returns the variable ID. Only one such
1519 * local is needed per code body, so if we've already allocated one
1520 * for another 'return' statement, we'll just return the same one we
1521 * allocated previously.
1522 */
1523 uint alloc_fin_ret_lcl()
1524 {
1525 /* if we haven't allocated it yet, do so now */
1526 if (!allocated_fin_ret_lcl_)
1527 {
1528 /* use the next available local */
1529 fin_ret_lcl_ = local_cnt_++;
1530
1531 /* note that we've allocated it */
1532 allocated_fin_ret_lcl_ = TRUE;
1533 }
1534
1535 /* return the local ID */
1536 return fin_ret_lcl_;
1537 }
1538
1539 /*
1540 * Add a named argument table to the code body. Each call that has
1541 * named arguments requires one of these tables. We keep a list of
1542 * tables, and generate them all at the end of the method. Returns a
1543 * label that can be used to write a forward reference offset to the
1544 * table's offset in the code stream.
1545 */
1546 struct CTcCodeLabel *add_named_arg_tab(
1547 const struct CTcNamedArgs *named_args);
1548
1549 protected:
1550 /*
1551 * callback for enumerating local frame symbol table entries - write
1552 * each entry to the code stream as a debug record
1553 */
1554 static void write_local_to_debug_frame(void *ctx, class CTcSymbol *sym);
1555
1556 /*
1557 * enumerator for checking for parameter symbols that belong in the
1558 * local context
1559 */
1560 static void enum_for_param_ctx(void *ctx, class CTcSymbol *sym);
1561
1562 /* enumerator for generating named parameter bindings */
1563 static void enum_for_named_params(void *ctx, class CTcSymbol *sym);
1564
1565 /* write the debug information table to the code stream */
1566 void build_debug_table(ulong start_ofs, int include_lines);
1567
1568 /* show disassembly */
1569 void show_disassembly(unsigned long start_ofs,
1570 unsigned long code_start_ofs,
1571 unsigned long code_end_ofs);
1572
1573 /* head of list of nested symbol tables */
1574 class CTcPrsSymtab *first_nested_symtab_;
1575
1576 /* head of list of named argument tables */
1577 struct CTcNamedArgTab *named_arg_tables_;
1578
1579 /*
1580 * ID of local variable for temporarily storing the expression value
1581 * of a 'return' statement while calling the enclosing 'finally'
1582 * block(s); valid only when allocated_fin_ret_lcl_ is true
1583 */
1584 uint fin_ret_lcl_;
1585
1586 /* flag: I'm a constructor */
1587 uint is_constructor_ : 1;
1588
1589 /*
1590 * flag: I've allocated a local for saving the expression value of a
1591 * 'return' statement while calling the enclosing 'finally' block(s)
1592 */
1593 uint allocated_fin_ret_lcl_ : 1;
1594
1595 /* flag: I'm a static property initializer */
1596 uint is_static_ : 1;
1597 };
1598
1599 /* ------------------------------------------------------------------------ */
1600 /*
1601 * Compound Statement
1602 */
1603 class CTPNStmComp: public CTPNStmCompBase
1604 {
1605 public:
1606 CTPNStmComp(class CTPNStm *first_stm, class CTcPrsSymtab *symtab)
1607 : CTPNStmCompBase(first_stm, symtab) { }
1608 };
1609
1610 /* ------------------------------------------------------------------------ */
1611 /*
1612 * Null statement
1613 */
1614 class CTPNStmNull: public CTPNStmNullBase
1615 {
1616 public:
1617 CTPNStmNull() { }
1618 };
1619
1620 /* ------------------------------------------------------------------------ */
1621 /*
1622 * Expression statement
1623 */
1624 class CTPNStmExpr: public CTPNStmExprBase
1625 {
1626 public:
1627 CTPNStmExpr(class CTcPrsNode *expr)
1628 : CTPNStmExprBase(expr) { }
1629 };
1630
1631 /* ------------------------------------------------------------------------ */
1632 /*
1633 * Static property initializer statement
1634 */
1635 class CTPNStmStaticPropInit: public CTPNStmStaticPropInitBase
1636 {
1637 public:
1638 CTPNStmStaticPropInit(class CTcPrsNode *expr,
1639 tctarg_prop_id_t prop)
1640 : CTPNStmStaticPropInitBase(expr, prop) { }
1641
1642 /* generate code */
1643 virtual void gen_code(int discard, int for_condition);
1644 };
1645
1646 /* ------------------------------------------------------------------------ */
1647 /*
1648 * 'if' statement
1649 */
1650 class CTPNStmIf: public CTPNStmIfBase
1651 {
1652 public:
1653 CTPNStmIf(class CTcPrsNode *cond_expr,
1654 class CTPNStm *then_part, class CTPNStm *else_part)
1655 : CTPNStmIfBase(cond_expr, then_part, else_part) { }
1656
1657 /* generate code */
1658 virtual void gen_code(int discard, int for_condition);
1659 };
1660
1661 /* ------------------------------------------------------------------------ */
1662 /*
1663 * 'for' statement
1664 */
1665 class CTPNStmFor: public CTPNStmForBase
1666 {
1667 public:
1668 CTPNStmFor(class CTcPrsNode *init_expr,
1669 class CTcPrsNode *cond_expr,
1670 class CTcPrsNode *reinit_expr,
1671 class CTPNForIn *in_exprs,
1672 class CTcPrsSymtab *symtab,
1673 class CTPNStmEnclosing *enclosing_stm)
1674 : CTPNStmForBase(init_expr, cond_expr, reinit_expr, in_exprs,
1675 symtab, enclosing_stm)
1676 {
1677 }
1678
1679 /* generate code */
1680 virtual void gen_code(int discard, int for_condition);
1681
1682 /* generate code for 'break' */
1683 virtual int gen_code_break(const textchar_t *lbl, size_t lbl_len)
1684 { return gen_code_break_loop(break_lbl_, lbl, lbl_len); }
1685
1686 /* generate code for 'continue' */
1687 virtual int gen_code_labeled_continue()
1688 { return gen_code_continue_loop(cont_lbl_, 0, 0); }
1689
1690 /* generate code for a labeled 'continue' */
1691 virtual int gen_code_continue(const textchar_t *lbl, size_t lbl_len)
1692 { return gen_code_continue_loop(cont_lbl_, lbl, lbl_len); }
1693
1694 protected:
1695 /* our 'break' label */
1696 struct CTcCodeLabel *break_lbl_;
1697
1698 /* our 'continue' label */
1699 struct CTcCodeLabel *cont_lbl_;
1700 };
1701
1702 /* ------------------------------------------------------------------------ */
1703 /*
1704 * '<variable> in <expression>' node, for 'for' statements
1705 */
1706 class CTPNVarIn: public CTPNVarInBase
1707 {
1708 public:
1709 CTPNVarIn(class CTcPrsNode *lval, class CTcPrsNode *expr,
1710 int iter_local_id)
1711 : CTPNVarInBase(lval, expr, iter_local_id) { }
1712
1713 /* generate code */
1714 virtual void gen_code(int discard, int for_condition);
1715
1716 /* generate the condition part of the 'for' */
1717 virtual void gen_forstm_cond(struct CTcCodeLabel *endlbl);
1718
1719 /* generate the reinit part of the 'for' */
1720 virtual void gen_forstm_reinit();
1721
1722 /*
1723 * Generate the iterator initializer. This is a static method so that
1724 * it can be shared by for..in and foreach..in. 'kw' is the keyword
1725 * for the statement type that we're generating ("for" or "foreach"),
1726 * so that we can show the appropriate statement type in any error
1727 * messages.
1728 */
1729 static void gen_iter_init(class CTcPrsNode *coll_expr, int iter_local_id,
1730 const char *kw);
1731
1732 /*
1733 * Generate the iterator condition. This is a static method so that it
1734 * can be shared by for..in and foreach..in.
1735 */
1736 static void gen_iter_cond(class CTcPrsNode *lval, int iter_local_id,
1737 struct CTcCodeLabel *&endlbl, const char *kw);
1738 };
1739
1740 /*
1741 * '<variable> in <from> .. <to>' node, for 'for' statements
1742 */
1743 class CTPNVarInRange: public CTPNVarInRangeBase
1744 {
1745 public:
1746 CTPNVarInRange(class CTcPrsNode *lval,
1747 class CTcPrsNode *from_expr,
1748 class CTcPrsNode *to_expr,
1749 class CTcPrsNode *step_expr,
1750 int to_local_id, int step_local_id)
1751 : CTPNVarInRangeBase(lval, from_expr, to_expr, step_expr,
1752 to_local_id, step_local_id)
1753 { }
1754
1755 /* generate code */
1756 virtual void gen_code(int discard, int for_condition);
1757
1758 /* generate the condition part of the 'for' */
1759 virtual void gen_forstm_cond(struct CTcCodeLabel *endlbl);
1760
1761 /* generate the reinit part of the 'for' */
1762 virtual void gen_forstm_reinit();
1763 };
1764
1765
1766 /* ------------------------------------------------------------------------ */
1767 /*
1768 * 'for' statement
1769 */
1770 class CTPNStmForeach: public CTPNStmForeachBase
1771 {
1772 public:
1773 CTPNStmForeach(class CTcPrsNode *iter_expr,
1774 class CTcPrsNode *coll_expr,
1775 class CTcPrsSymtab *symtab,
1776 class CTPNStmEnclosing *enclosing_stm,
1777 int iter_local_id)
1778 : CTPNStmForeachBase(iter_expr, coll_expr, symtab, enclosing_stm,
1779 iter_local_id)
1780 {
1781 }
1782
1783 /* generate code */
1784 virtual void gen_code(int discard, int for_condition);
1785
1786 /* generate code for 'break' */
1787 virtual int gen_code_break(const textchar_t *lbl, size_t lbl_len)
1788 { return gen_code_break_loop(break_lbl_, lbl, lbl_len); }
1789
1790 /* generate code for 'continue' */
1791 virtual int gen_code_labeled_continue()
1792 { return gen_code_continue_loop(cont_lbl_, 0, 0); }
1793
1794 /* generate code for a labeled 'continue' */
1795 virtual int gen_code_continue(const textchar_t *lbl, size_t lbl_len)
1796 { return gen_code_continue_loop(cont_lbl_, lbl, lbl_len); }
1797
1798 protected:
1799 /* our 'break' label */
1800 struct CTcCodeLabel *break_lbl_;
1801
1802 /* our 'continue' label */
1803 struct CTcCodeLabel *cont_lbl_;
1804 };
1805
1806 /* ------------------------------------------------------------------------ */
1807 /*
1808 * 'break' statement
1809 */
1810 class CTPNStmBreak: public CTPNStmBreakBase
1811 {
1812 public:
1813 CTPNStmBreak() { }
1814
1815 /* generate code */
1816 virtual void gen_code(int discard, int for_condition);
1817 };
1818
1819 /* ------------------------------------------------------------------------ */
1820 /*
1821 * 'continue' statement
1822 */
1823 class CTPNStmContinue: public CTPNStmContinueBase
1824 {
1825 public:
1826 CTPNStmContinue() { }
1827
1828 /* generate code */
1829 virtual void gen_code(int discard, int for_condition);
1830 };
1831
1832 /* ------------------------------------------------------------------------ */
1833 /*
1834 * 'while' statement
1835 */
1836 class CTPNStmWhile: public CTPNStmWhileBase
1837 {
1838 public:
1839 CTPNStmWhile(class CTcPrsNode *cond_expr,
1840 class CTPNStmEnclosing *enclosing_stm)
1841 : CTPNStmWhileBase(cond_expr, enclosing_stm) { }
1842
1843 /* generate code */
1844 virtual void gen_code(int discard, int for_condition);
1845
1846 /* generate code for 'break' */
1847 virtual int gen_code_break(const textchar_t *lbl, size_t lbl_len)
1848 { return gen_code_break_loop(break_lbl_, lbl, lbl_len); }
1849
1850 /* generate code for 'continue' */
1851 virtual int gen_code_labeled_continue()
1852 { return gen_code_continue_loop(cont_lbl_, 0, 0); }
1853
1854 /* generate code for a labeled 'continue' */
1855 virtual int gen_code_continue(const textchar_t *lbl, size_t lbl_len)
1856 { return gen_code_continue_loop(cont_lbl_, lbl, lbl_len); }
1857
1858 protected:
1859 /* our 'break' label */
1860 struct CTcCodeLabel *break_lbl_;
1861
1862 /* our 'continue' label */
1863 struct CTcCodeLabel *cont_lbl_;
1864 };
1865
1866 /* ------------------------------------------------------------------------ */
1867 /*
1868 * 'do-while' statement
1869 */
1870 class CTPNStmDoWhile: public CTPNStmDoWhileBase
1871 {
1872 public:
1873 CTPNStmDoWhile(class CTPNStmEnclosing *enclosing_stm)
1874 : CTPNStmDoWhileBase(enclosing_stm) { }
1875
1876 /* generate code */
1877 virtual void gen_code(int discard, int for_condition);
1878
1879 /* generate code for 'break' */
1880 virtual int gen_code_break(const textchar_t *lbl, size_t lbl_len)
1881 { return gen_code_break_loop(break_lbl_, lbl, lbl_len); }
1882
1883 /* generate code for 'continue' */
1884 virtual int gen_code_labeled_continue()
1885 { return gen_code_continue_loop(cont_lbl_, 0, 0); }
1886
1887 /* generate code for a labeled 'continue' */
1888 virtual int gen_code_continue(const textchar_t *lbl, size_t lbl_len)
1889 { return gen_code_continue_loop(cont_lbl_, lbl, lbl_len); }
1890
1891 protected:
1892 /* our 'break' label */
1893 struct CTcCodeLabel *break_lbl_;
1894
1895 /* our 'continue' label */
1896 struct CTcCodeLabel *cont_lbl_;
1897 };
1898
1899 /* ------------------------------------------------------------------------ */
1900 /*
1901 * 'return' statement
1902 */
1903 class CTPNStmReturn: public CTPNStmReturnBase
1904 {
1905 public:
1906 CTPNStmReturn(class CTcPrsNode *expr)
1907 : CTPNStmReturnBase(expr) { }
1908
1909 /* generate code */
1910 virtual void gen_code(int discard, int for_condition);
1911 };
1912
1913 /* ------------------------------------------------------------------------ */
1914 /*
1915 * 'switch' statement
1916 */
1917 class CTPNStmSwitch: public CTPNStmSwitchBase
1918 {
1919 public:
1920 CTPNStmSwitch(class CTPNStmEnclosing *enclosing_stm)
1921 : CTPNStmSwitchBase(enclosing_stm)
1922 {
1923 /* the 'case' and 'default' slot pointers aren't valid yet */
1924 case_slot_ofs_ = 0;
1925 default_slot_ofs_ = 0;
1926 }
1927
1928 /* generate code */
1929 virtual void gen_code(int discard, int for_condition);
1930
1931 /*
1932 * Get the next case slot offset, and consume the slot. Each call
1933 * consumes one slot. This is valid only during code generation in
1934 * the switch body; 'case' labels use this to figure out where to
1935 * write their data.
1936 */
1937 ulong alloc_case_slot()
1938 {
1939 ulong ret;
1940
1941 /* note the value to return */
1942 ret = case_slot_ofs_;
1943
1944 /* move our internal counter to the next slot */
1945 case_slot_ofs_ += VMB_DATAHOLDER + VMB_UINT2;
1946
1947 /* return the allocated slot */
1948 return ret;
1949 }
1950
1951 /* get the code offset of the 'default' case slot */
1952 ulong get_default_slot() const { return default_slot_ofs_; }
1953
1954 /* generate code for 'break' */
1955 virtual int gen_code_break(const textchar_t *lbl, size_t lbl_len)
1956 {
1957 /*
1958 * if there's no label, and we don't have a 'break' label
1959 * ourselves, it must mean that we're processing an unreachable
1960 * 'break' - we can simply do nothing in this case and pretend we
1961 * succeeded
1962 */
1963 if (lbl == 0 && break_lbl_ == 0)
1964 return TRUE;
1965
1966 /* break to our break label */
1967 return gen_code_break_loop(break_lbl_, lbl, lbl_len);
1968 }
1969
1970 protected:
1971 /*
1972 * code offset of the next 'case' slot to be allocated from the
1973 * switch's case table - this is only valid during generation of the
1974 * body, because we set this up during generation of the switch
1975 * itself
1976 */
1977 ulong case_slot_ofs_;
1978
1979 /* code offset of the 'default' slot */
1980 ulong default_slot_ofs_;
1981
1982 /* our 'break' label */
1983 struct CTcCodeLabel *break_lbl_;
1984 };
1985
1986
1987 /* ------------------------------------------------------------------------ */
1988 /*
1989 * code label statement
1990 */
1991 class CTPNStmLabel: public CTPNStmLabelBase
1992 {
1993 public:
1994 CTPNStmLabel(class CTcSymLabel *lbl, class CTPNStmEnclosing *enclosing);
1995
1996 /* generate code */
1997 virtual void gen_code(int discard, int for_condition);
1998
1999 /* generate code for 'break' */
2000 virtual int gen_code_break(const textchar_t *lbl, size_t lbl_len);
2001
2002 /* generate code for 'continue' */
2003 virtual int gen_code_continue(const textchar_t *lbl, size_t lbl_len);
2004
2005 /*
2006 * Generate code for a labeled 'continue'. We'll simply generate
2007 * code for a labeled continue in our enclosed statement.
2008 *
2009 * (This is normally a routine that *we* call on our contained
2010 * statement in response to a 'continue' being targeted at this
2011 * label. This can be invoked on us, however, when a statement has
2012 * multiple labels, and the outer label is mentioned in the 'break'
2013 * -- the outer label will call this routine on the inner label,
2014 * which is us, so we simply need to pass it along to the enclosed
2015 * statement.)
2016 */
2017 virtual int gen_code_labeled_continue()
2018 { return (stm_ != 0 ? stm_->gen_code_labeled_continue() : FALSE); }
2019
2020 /* get my 'goto' label */
2021 struct CTcCodeLabel *get_goto_label();
2022
2023 protected:
2024 /* the byte label to jump to this statement */
2025 struct CTcCodeLabel *goto_label_;
2026
2027 /* the byte label to break from this statement */
2028 struct CTcCodeLabel *break_label_;
2029 };
2030
2031 /* ------------------------------------------------------------------------ */
2032 /*
2033 * 'case' label statement
2034 */
2035 class CTPNStmCase: public CTPNStmCaseBase
2036 {
2037 public:
2038 CTPNStmCase() { }
2039
2040 /* generate code */
2041 virtual void gen_code(int discard, int for_condition);
2042 };
2043
2044 /* ------------------------------------------------------------------------ */
2045 /*
2046 * 'default' label statement
2047 */
2048 class CTPNStmDefault: public CTPNStmDefaultBase
2049 {
2050 public:
2051 CTPNStmDefault() { }
2052
2053 /* generate code */
2054 virtual void gen_code(int discard, int for_condition);
2055 };
2056
2057 /* ------------------------------------------------------------------------ */
2058 /*
2059 * 'try' block
2060 */
2061 class CTPNStmTry: public CTPNStmTryBase
2062 {
2063 public:
2064 CTPNStmTry(class CTPNStmEnclosing *enclosing)
2065 : CTPNStmTryBase(enclosing)
2066 {
2067 }
2068
2069 /* generate code */
2070 virtual void gen_code(int discard, int for_condition);
2071
2072 /* generate code for 'break' */
2073 virtual int gen_code_break(const textchar_t *lbl, size_t lbl_len);
2074
2075 /* generate code for 'continue' */
2076 virtual int gen_code_continue(const textchar_t *lbl, size_t lbl_len);
2077
2078 /*
2079 * Generate the code necessary to unwind for returning. We must
2080 * generate a call to our 'finally' code, then unwind any enclosing
2081 * statements.
2082 */
2083 virtual void gen_code_unwind_for_return()
2084 {
2085 /* call 'finally' on the way out */
2086 gen_jsr_finally();
2087
2088 /* inherit default to unwind enclosing statements */
2089 CTPNStmTryBase::gen_code_unwind_for_return();
2090 }
2091
2092 /* determine if we'll generate code for unwinding from a return */
2093 virtual int will_gen_code_unwind_for_return() const
2094 {
2095 /* we'll generate a call to our 'finally' block if we have one */
2096 if (finally_stm_ != 0)
2097 return TRUE;
2098
2099 /* we'll also generate code if any enclosing statement does */
2100 return CTPNStmTryBase::will_gen_code_unwind_for_return();
2101 }
2102
2103 /* generate the code necessary to transfer out of the block */
2104 virtual void gen_code_for_transfer_out()
2105 {
2106 /* call 'finally' on the way out */
2107 gen_jsr_finally();
2108 }
2109
2110 /*
2111 * generate a local subroutine call to our 'finally' block, if we
2112 * have a 'finally' block - this should be invoked whenever code
2113 * within the protected block or a 'catch' block executes a break,
2114 * continue, return, or goto out of the protected region, or when
2115 * merely falling off the end of the protected block or a 'catch'
2116 * block.
2117 */
2118 void gen_jsr_finally();
2119
2120 /* get my 'finally' label */
2121 struct CTcCodeLabel *get_finally_lbl() const { return finally_lbl_; }
2122
2123 protected:
2124 /* our 'finally' label */
2125 struct CTcCodeLabel *finally_lbl_;
2126 };
2127
2128 /* ------------------------------------------------------------------------ */
2129 /*
2130 * 'catch'
2131 */
2132 class CTPNStmCatch: public CTPNStmCatchBase
2133 {
2134 public:
2135 CTPNStmCatch() { }
2136
2137 /* generate code */
2138 virtual void gen_code(int discard, int for_condition);
2139
2140 /* generate code for the 'catch' clause */
2141 virtual void gen_code_catch(ulong protected_start_ofs,
2142 ulong protected_end_ofs);
2143 };
2144
2145 /* ------------------------------------------------------------------------ */
2146 /*
2147 * 'finally'
2148 */
2149 class CTPNStmFinally: public CTPNStmFinallyBase
2150 {
2151 public:
2152 CTPNStmFinally(CTPNStmEnclosing *enclosing,
2153 int exc_local_id, int jsr_local_id)
2154 : CTPNStmFinallyBase(enclosing, exc_local_id, jsr_local_id)
2155 {
2156 }
2157
2158 /* generate code */
2159 virtual void gen_code(int discard, int for_condition);
2160
2161 /* generate code for the 'finally' clause */
2162 virtual void gen_code_finally(ulong protected_start_ofs,
2163 ulong protected_end_ofs,
2164 class CTPNStmTry *try_stm);
2165
2166 /* check for transfer in via 'goto' statements */
2167 virtual int check_enter_by_goto(class CTPNStmGoto *goto_stm,
2168 class CTPNStmLabel *target);
2169 };
2170
2171
2172 /* ------------------------------------------------------------------------ */
2173 /*
2174 * 'throw' statement
2175 */
2176 class CTPNStmThrow: public CTPNStmThrowBase
2177 {
2178 public:
2179 CTPNStmThrow(class CTcPrsNode *expr)
2180 : CTPNStmThrowBase(expr)
2181 {
2182 }
2183
2184 /* generate code */
2185 virtual void gen_code(int discard, int for_condition);
2186 };
2187
2188
2189 /* ------------------------------------------------------------------------ */
2190 /*
2191 * 'goto' statement
2192 */
2193 class CTPNStmGoto: public CTPNStmGotoBase
2194 {
2195 public:
2196 CTPNStmGoto(const textchar_t *lbl, size_t lbl_len)
2197 : CTPNStmGotoBase(lbl, lbl_len)
2198 {
2199 }
2200
2201 /* generate code */
2202 virtual void gen_code(int discard, int for_condition);
2203 };
2204
2205 /* ------------------------------------------------------------------------ */
2206 /*
2207 * 'dictionary' statement
2208 */
2209 class CTPNStmDict: public CTPNStmDictBase
2210 {
2211 public:
2212 CTPNStmDict(class CTcDictEntry *dict)
2213 : CTPNStmDictBase(dict)
2214 {
2215 }
2216
2217 /* generate code */
2218 virtual void gen_code(int, int) { }
2219 };
2220
2221 /* ------------------------------------------------------------------------ */
2222 /*
2223 * Object Definition
2224 */
2225 class CTPNStmObject: public CTPNStmObjectBase
2226 {
2227 public:
2228 CTPNStmObject(class CTcSymObj *obj_sym, int is_class)
2229 : CTPNStmObjectBase(obj_sym, is_class)
2230 {
2231 }
2232
2233 /* generate code */
2234 virtual void gen_code(int discard, int for_condition);
2235
2236 /* check locals */
2237 virtual void check_locals();
2238
2239 /*
2240 * given the stream offset for the start of the object data in the
2241 * stream, get information on the object from the stream data:
2242 *
2243 *. - get the number of properties in the stream data
2244 *. - set the number of properties in the stream data, updating the
2245 * stored data size in the metaclass header in the stream; returns
2246 * the new data size
2247 *. - get the number of superclasses in the stream data
2248 *. - get a superclass object ID
2249 *. - get the offset of the first property in the stream data
2250 *. - get the offset of the property at the given index
2251 *. - get the ID of the object's property at the given index
2252 *. - set the ID of the object's property at the given index
2253 *. - get the object flags from the tads-object header
2254 *. - set the object flags in the tads-object heade
2255 */
2256 static uint get_stream_prop_cnt(class CTcDataStream *stream,
2257 ulong obj_ofs);
2258 static size_t set_stream_prop_cnt(class CTcDataStream *stream,
2259 ulong obj_ofs, uint prop_cnt);
2260 static uint get_stream_sc_cnt(class CTcDataStream *stream,
2261 ulong obj_ofs);
2262 static vm_obj_id_t get_stream_sc(class CTcDataStream *stream,
2263 ulong obj_ofs, uint sc_idx);
2264 static void set_stream_sc(class CTcDataStream *stream,
2265 ulong obj_ofs, uint sc_idx, vm_obj_id_t new_sc);
2266 static ulong get_stream_first_prop_ofs(class CTcDataStream *stream,
2267 ulong obj_ofs);
2268 static ulong get_stream_prop_ofs(class CTcDataStream *stream,
2269 ulong obj_ofs, uint prop_idx);
2270 static vm_prop_id_t get_stream_prop_id(class CTcDataStream *stream,
2271 ulong obj_ofs, uint prop_idx);
2272 static enum vm_datatype_t
2273 get_stream_prop_type(class CTcDataStream *stream,
2274 ulong obj_ofs, uint prop_idx);
2275 static ulong get_stream_prop_val_ofs(class CTcDataStream *stream,
2276 ulong obj_ofs, uint prop_idx);
2277 static void set_stream_prop_id(class CTcDataStream *stream,
2278 ulong obj_ofs, uint prop_idx,
2279 vm_prop_id_t new_id);
2280 static uint get_stream_obj_flags(class CTcDataStream *stream,
2281 ulong obj_ofs);
2282 static void set_stream_obj_flags(class CTcDataStream *stream,
2283 ulong obj_ofs, uint flags);
2284 };
2285
2286 /*
2287 * Inline object definition (defined within an expression)
2288 */
2289 class CTPNInlineObject: public CTPNInlineObjectBase
2290 {
2291 public:
2292 /* generate code */
2293 virtual void gen_code(int discard, int for_condition);
2294 };
2295
2296
2297 /*
2298 * Property Value list entry
2299 */
2300 class CTPNObjProp: public CTPNObjPropBase
2301 {
2302 public:
2303 CTPNObjProp(class CTPNObjDef *objdef, class CTcSymProp *prop_sym,
2304 class CTcPrsNode *expr, class CTPNCodeBody *code_body,
2305 class CTPNAnonFunc *inline_method, int is_static)
2306 : CTPNObjPropBase(
2307 objdef, prop_sym, expr, code_body, inline_method, is_static)
2308 {
2309 }
2310
2311 /* generate code */
2312 virtual void gen_code(int discard, int for_condition);
2313
2314 /* generate code for an inline object instantiation */
2315 void gen_code_inline_obj();
2316
2317 /* check locals */
2318 void check_locals();
2319
2320 protected:
2321 /* generate a setMethod() call for inline object creation */
2322 void gen_setMethod();
2323 };
2324
2325 /*
2326 * Implicit constructor
2327 */
2328 class CTPNStmImplicitCtor: public CTPNStmImplicitCtorBase
2329 {
2330 public:
2331 CTPNStmImplicitCtor(class CTPNStmObject *obj_stm)
2332 : CTPNStmImplicitCtorBase(obj_stm)
2333 {
2334 }
2335
2336 /* generate code */
2337 virtual void gen_code(int discard, int for_condition);
2338 };
2339
2340
2341 #endif /* TCT3DRV_H */