source: src/SymTab/FixFunction.cc@ 8d182b1

Last change on this file since 8d182b1 was 0bd3faf, checked in by Andrew Beach <ajbeach@…>, 23 months ago

Removed forward declarations missed in the BaseSyntaxNode removal. Removed code and modified names to support two versions of the ast.

  • Property mode set to 100644
File size: 2.9 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// FixFunction.cc --
8//
9// Author : Richard C. Bilson
10// Created On : Sun May 17 16:19:49 2015
11// Last Modified By : Andrew Beach
12// Last Modified On : Tue Jul 12 14:28:00 2022
13// Update Count : 7
14//
15
16#include "FixFunction.h"
17
18#include <list> // for list
19
20#include "AST/Decl.hpp"
21#include "AST/Pass.hpp"
22#include "AST/Type.hpp"
23#include "Common/utility.h" // for copy
24
25namespace SymTab {
26
27namespace {
28 struct FixFunction final : public ast::WithShortCircuiting {
29 bool isVoid = false;
30
31 void previsit( const ast::FunctionDecl * ) { visit_children = false; }
32
33 const ast::DeclWithType * postvisit( const ast::FunctionDecl * func ) {
34 // Cannot handle cases with asserions.
35 assert( func->assertions.empty() );
36 return new ast::ObjectDecl{
37 func->location, func->name, new ast::PointerType( func->type ), nullptr,
38 func->storage, func->linkage, nullptr, copy( func->attributes ) };
39 }
40
41 void previsit( const ast::ArrayType * ) { visit_children = false; }
42
43 const ast::Type * postvisit( const ast::ArrayType * array ) {
44 return new ast::PointerType{
45 array->base, array->dimension, array->isVarLen, array->isStatic,
46 array->qualifiers };
47 }
48
49 void previsit( const ast::FunctionType * ) { visit_children = false; }
50
51 const ast::Type * postvisit( const ast::FunctionType * type ) {
52 return new ast::PointerType( type );
53 }
54
55 void previsit( const ast::VoidType * ) { isVoid = true; }
56
57 void previsit( const ast::BasicType * ) { visit_children = false; }
58 void previsit( const ast::PointerType * ) { visit_children = false; }
59 void previsit( const ast::StructInstType * ) { visit_children = false; }
60 void previsit( const ast::UnionInstType * ) { visit_children = false; }
61 void previsit( const ast::EnumInstType * ) { visit_children = false; }
62 void previsit( const ast::TraitInstType * ) { visit_children = false; }
63 void previsit( const ast::TypeInstType * ) { visit_children = false; }
64 void previsit( const ast::TupleType * ) { visit_children = false; }
65 void previsit( const ast::VarArgsType * ) { visit_children = false; }
66 void previsit( const ast::ZeroType * ) { visit_children = false; }
67 void previsit( const ast::OneType * ) { visit_children = false; }
68 };
69} // anonymous namespace
70
71const ast::DeclWithType * fixFunction( const ast::DeclWithType * dwt, bool & isVoid ) {
72 ast::Pass< FixFunction > fixer;
73 dwt = dwt->accept( fixer );
74 isVoid |= fixer.core.isVoid;
75 return dwt;
76}
77
78const ast::Type * fixFunction( const ast::Type * type, bool & isVoid ) {
79 ast::Pass< FixFunction > fixer;
80 type = type->accept( fixer );
81 isVoid |= fixer.core.isVoid;
82 return type;
83}
84
85} // namespace SymTab
86
87// Local Variables: //
88// tab-width: 4 //
89// mode: c++ //
90// compile-command: "make install" //
91// End: //
Note: See TracBrowser for help on using the repository browser.