source: src/Parser/StatementNode.hpp @ 08e0d65

Last change on this file since 08e0d65 was d3aa55e9, checked in by JiadaL <j82liang@…>, 5 months ago
  1. Disallow implicit conversion from cfa enum to int during on the function call site; 2. implement the reverse enum loop
  • Property mode set to 100644
File size: 5.5 KB
RevLine 
[c468150]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//
[c92bdcc]7// StatementNode.hpp --
[c468150]8//
9// Author           : Andrew Beach
10// Created On       : Wed Apr  5 11:42:00 2023
[f259682]11// Last Modified By : Peter A. Buhr
12// Last Modified On : Fri Aug 11 11:44:07 2023
13// Update Count     : 2
[c468150]14//
15
16#pragma once
17
[c92bdcc]18#include "ParseNode.hpp"
[c468150]19
[dc3fbe5]20struct StatementNode final : public ParseList<StatementNode> {
[6611177]21        StatementNode() : stmt( nullptr ) {}
22        StatementNode( ast::Stmt * stmt ) : stmt( stmt ) {}
[c468150]23        StatementNode( DeclarationNode * decl );
24        virtual ~StatementNode() {}
25
26        virtual StatementNode * clone() const final { assert( false ); return nullptr; }
[6611177]27        ast::Stmt * build() { return stmt.release(); }
[c468150]28
29        StatementNode * add_label(
30                        const CodeLocation & location,
31                        const std::string * name,
[6611177]32                        DeclarationNode * attr = nullptr );
[c468150]33
34        virtual void print( std::ostream & os, __attribute__((unused)) int indent = 0 ) const override {
35                os << stmt.get() << std::endl;
36        }
37
38        std::unique_ptr<ast::Stmt> stmt;
39}; // StatementNode
40
[dc3fbe5]41struct ClauseNode final : public ParseList<ClauseNode> {
[6611177]42        ClauseNode( ast::StmtClause * clause ) : clause( clause ) {}
43        virtual ~ClauseNode() {}
44
45        virtual ClauseNode * clone() const final { assert( false ); return nullptr; }
46        ast::StmtClause * build() { return clause.release(); }
47
48        virtual ClauseNode * append_last_case( StatementNode * );
49
50        std::unique_ptr<ast::StmtClause> clause;
51};
52
[c468150]53ast::Stmt * build_expr( CodeLocation const &, ExpressionNode * ctl );
54
55struct CondCtl {
56        CondCtl( DeclarationNode * decl, ExpressionNode * condition ) :
57                init( decl ? new StatementNode( decl ) : nullptr ), condition( condition ) {}
58
59        StatementNode * init;
60        ExpressionNode * condition;
61};
62
63struct ForCtrl {
64        ForCtrl( StatementNode * stmt, ExpressionNode * condition, ExpressionNode * change ) :
[525f7ad]65                init( stmt ), condition( condition ), change( change ), range_over( nullptr ) {}
[d3aa55e9]66        ForCtrl( StatementNode * decl, ExpressionNode * range_over, OperKinds kind ) :
67                init( decl ), condition( nullptr ), change( nullptr ),  range_over( range_over ), kind( kind ) {}
[c468150]68
69        StatementNode * init;
70        ExpressionNode * condition;
71        ExpressionNode * change;
[525f7ad]72        ExpressionNode * range_over;
[d3aa55e9]73        OperKinds kind;
[c468150]74};
75
76ast::Stmt * build_if( const CodeLocation &, CondCtl * ctl, StatementNode * then, StatementNode * else_ );
[6611177]77ast::Stmt * build_switch( const CodeLocation &, bool isSwitch, ExpressionNode * ctl, ClauseNode * stmt );
78ast::CaseClause * build_case( const CodeLocation &, ExpressionNode * ctl );
[c468150]79ast::CaseClause * build_default( const CodeLocation & );
80ast::Stmt * build_while( const CodeLocation &, CondCtl * ctl, StatementNode * stmt, StatementNode * else_ = nullptr );
81ast::Stmt * build_do_while( const CodeLocation &, ExpressionNode * ctl, StatementNode * stmt, StatementNode * else_ = nullptr );
82ast::Stmt * build_for( const CodeLocation &, ForCtrl * forctl, StatementNode * stmt, StatementNode * else_ = nullptr );
83ast::Stmt * build_branch( const CodeLocation &, ast::BranchStmt::Kind kind );
84ast::Stmt * build_branch( const CodeLocation &, std::string * identifier, ast::BranchStmt::Kind kind );
85ast::Stmt * build_computedgoto( ExpressionNode * ctl );
86ast::Stmt * build_return( const CodeLocation &, ExpressionNode * ctl );
87ast::Stmt * build_throw( const CodeLocation &, ExpressionNode * ctl );
88ast::Stmt * build_resume( const CodeLocation &, ExpressionNode * ctl );
89ast::Stmt * build_resume_at( ExpressionNode * ctl , ExpressionNode * target );
[6611177]90ast::Stmt * build_try( const CodeLocation &, StatementNode * try_, ClauseNode * catch_, ClauseNode * finally_ );
[c468150]91ast::CatchClause * build_catch( const CodeLocation &, ast::ExceptionKind kind, DeclarationNode * decl, ExpressionNode * cond, StatementNode * body );
92ast::FinallyClause * build_finally( const CodeLocation &, StatementNode * stmt );
93ast::Stmt * build_compound( const CodeLocation &, StatementNode * first );
94StatementNode * maybe_build_compound( const CodeLocation &, StatementNode * first );
[32d6fdc]95ast::Stmt * build_asm( const CodeLocation &, bool is_volatile, ExpressionNode * instruction, ExpressionNode * output = nullptr, ExpressionNode * input = nullptr, ExpressionNode * clobber = nullptr, LabelNode * gotolabels = nullptr );
[c468150]96ast::Stmt * build_directive( const CodeLocation &, std::string * directive );
97ast::SuspendStmt * build_suspend( const CodeLocation &, StatementNode *, ast::SuspendStmt::Kind );
98ast::WaitForStmt * build_waitfor( const CodeLocation &, ast::WaitForStmt * existing, ExpressionNode * when, ExpressionNode * targetExpr, StatementNode * stmt );
99ast::WaitForStmt * build_waitfor_else( const CodeLocation &, ast::WaitForStmt * existing, ExpressionNode * when, StatementNode * stmt );
100ast::WaitForStmt * build_waitfor_timeout( const CodeLocation &, ast::WaitForStmt * existing, ExpressionNode * when, ExpressionNode * timeout, StatementNode * stmt );
[6e1e2d0]101ast::WaitUntilStmt::ClauseNode * build_waituntil_clause( const CodeLocation &, ExpressionNode * when, ExpressionNode * targetExpr, StatementNode * stmt );
102ast::WaitUntilStmt::ClauseNode * build_waituntil_else( const CodeLocation &, ExpressionNode * when, StatementNode * stmt );
103ast::WaitUntilStmt * build_waituntil_stmt( const CodeLocation &, ast::WaitUntilStmt::ClauseNode * root );
[c468150]104ast::Stmt * build_with( const CodeLocation &, ExpressionNode * exprs, StatementNode * stmt );
105ast::Stmt * build_mutex( const CodeLocation &, ExpressionNode * exprs, StatementNode * stmt );
[eb779d5]106ast::Stmt * build_corun( const CodeLocation &, StatementNode * stmt );
[3d9d017]107ast::Stmt * build_cofor( const CodeLocation & location, ForCtrl * forctl, StatementNode * stmt );
Note: See TracBrowser for help on using the repository browser.