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
RevLine 
[0dd3a2f]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//
[40e636a]7// FixFunction.cc --
[0dd3a2f]8//
9// Author : Richard C. Bilson
10// Created On : Sun May 17 16:19:49 2015
[1931bb01]11// Last Modified By : Andrew Beach
12// Last Modified On : Tue Jul 12 14:28:00 2022
13// Update Count : 7
[0dd3a2f]14//
15
[51b73452]16#include "FixFunction.h"
[30f9072]17
18#include <list> // for list
19
[c1ed2ee]20#include "AST/Decl.hpp"
21#include "AST/Pass.hpp"
22#include "AST/Type.hpp"
[9feb34b]23#include "Common/utility.h" // for copy
[51b73452]24
25namespace SymTab {
[c1ed2ee]26
27namespace {
[0bd3faf]28 struct FixFunction final : public ast::WithShortCircuiting {
[c1ed2ee]29 bool isVoid = false;
30
[c408483]31 void previsit( const ast::FunctionDecl * ) { visit_children = false; }
[c1ed2ee]32
[c408483]33 const ast::DeclWithType * postvisit( const ast::FunctionDecl * func ) {
[b2ecd48]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,
[c1ed2ee]38 func->storage, func->linkage, nullptr, copy( func->attributes ) };
39 }
40
[c408483]41 void previsit( const ast::ArrayType * ) { visit_children = false; }
[c1ed2ee]42
[c408483]43 const ast::Type * postvisit( const ast::ArrayType * array ) {
[b2ecd48]44 return new ast::PointerType{
45 array->base, array->dimension, array->isVarLen, array->isStatic,
[c1ed2ee]46 array->qualifiers };
47 }
48
[1931bb01]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
[c408483]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; }
[c1ed2ee]68 };
69} // anonymous namespace
70
71const ast::DeclWithType * fixFunction( const ast::DeclWithType * dwt, bool & isVoid ) {
[0bd3faf]72 ast::Pass< FixFunction > fixer;
[c1ed2ee]73 dwt = dwt->accept( fixer );
[7ff3e522]74 isVoid |= fixer.core.isVoid;
[c1ed2ee]75 return dwt;
76}
77
[1931bb01]78const ast::Type * fixFunction( const ast::Type * type, bool & isVoid ) {
[0bd3faf]79 ast::Pass< FixFunction > fixer;
[1931bb01]80 type = type->accept( fixer );
81 isVoid |= fixer.core.isVoid;
82 return type;
83}
84
[51b73452]85} // namespace SymTab
[0dd3a2f]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.