source: src/Parser/InitializerNode.h @ e72fc60

Last change on this file since e72fc60 was dc3fbe5, checked in by Andrew Beach <ajbeach@…>, 8 months ago

Factored out the ParseNode?'s next field into a new child type. This is only type safe when used in the given one level curiously reoccurring template pattern, as it is now. This allowed most of the intermedate helpers to be removed.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// InitializerNode.h --
8//
9// Author           : Andrew Beach
10// Created On       : Wed Apr  5 11:31:00 2023
11// Last Modified By : Andrew Beach
12// Last Modified On : Wed Apr  5 11:48:00 2023
13// Update Count     : 0
14//
15
16#pragma once
17
18#include "ParseNode.h"
19
20struct InitializerNode final : public ParseList<InitializerNode> {
21        InitializerNode( ExpressionNode *, bool aggrp = false, ExpressionNode * des = nullptr );
22        InitializerNode( InitializerNode *, bool aggrp = false, ExpressionNode * des = nullptr );
23        InitializerNode( bool isDelete );
24        ~InitializerNode();
25        virtual InitializerNode * clone() const { assert( false ); return nullptr; }
26
27        ExpressionNode * get_expression() const { return expr; }
28
29        InitializerNode * set_designators( ExpressionNode * des ) { designator = des; return this; }
30        ExpressionNode * get_designators() const { return designator; }
31
32        InitializerNode * set_maybeConstructed( bool value ) { maybeConstructed = value; return this; }
33        bool get_maybeConstructed() const { return maybeConstructed; }
34
35        bool get_isDelete() const { return isDelete; }
36
37        InitializerNode * next_init() const { return kids; }
38
39        void print( std::ostream & os, int indent = 0 ) const;
40        void printOneLine( std::ostream & ) const;
41
42        virtual ast::Init * build() const;
43private:
44        ExpressionNode * expr;
45        bool aggregate;
46        ExpressionNode * designator;                        // may be list
47        InitializerNode * kids;
48        bool maybeConstructed;
49        bool isDelete;
50}; // InitializerNode
Note: See TracBrowser for help on using the repository browser.