source: src/AST/Init.cpp @ 9131e54

arm-ehcleanup-dtorsjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-expr
Last change on this file since 9131e54 was 9131e54, checked in by Aaron Moss <a3moss@…>, 3 years ago

Added Init for new AST

  • Property mode set to 100644
File size: 1.3 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// Init.cpp --
8//
9// Author           : Aaron B. Moss
10// Created On       : Fri May 10 10:30:00 2019
11// Last Modified By : Aaron B. Moss
12// Created On       : Fri May 10 10:30:00 2019
13// Update Count     : 1
14//
15
16#include "Init.hpp"
17
18#include <cassert>
19#include <utility>  // for move
20#include <vector>
21
22namespace ast {
23
24ListInit::ListInit( const CodeLocation& loc, std::vector<ptr<Init>>&& is, 
25        std::vector<ptr<Designation>>&& ds, bool mc)
26: Init( loc, mc ), initializers( std::move(is) ), designations( std::move(ds) ) {
27        // handle common case where ListInit is created without designations by making an
28        // equivalent-length empty list
29        if ( designations.empty() ) {
30                for ( unsigned i = 0; i < initializers.size(); ++i ) {
31                        designations.emplace_back( new Designation{ loc } );
32                }
33        }
34       
35        assertf( initializers.size() == designations.size(), "Created ListInit with mismatching "
36                "initializers (%zd) and designations (%zd)", initializers.size(), designations.size() );
37}
38
39}
40
41// Local Variables: //
42// tab-width: 4 //
43// mode: c++ //
44// compile-command: "make install" //
45// End: //
Note: See TracBrowser for help on using the repository browser.