Changeset d63eeb0 for src/SynTree


Ignore:
Timestamp:
Feb 9, 2016, 3:25:05 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
7528ba1
Parents:
771b3c3 (diff), bd85400 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into ctor

Conflicts:

src/CodeGen/CodeGenerator.cc
src/GenPoly/Box.cc
src/Makefile.in
src/Parser/ParseNode.h
src/Parser/parser.cc
src/Parser/parser.yy
src/SymTab/Validate.cc
src/SynTree/Initializer.h
src/SynTree/ObjectDecl.cc
src/SynTree/Visitor.h
src/main.cc

Location:
src/SynTree
Files:
31 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/AddressExpr.cc

    r771b3c3 rd63eeb0  
    1616#include "Expression.h"
    1717#include "Type.h"
    18 #include "utility.h"
     18#include "Common/utility.h"
    1919
    2020AddressExpr::AddressExpr( Expression *arg, Expression *_aname ) : Expression( _aname ), arg( arg ) {
  • src/SynTree/AggregateDecl.cc

    r771b3c3 rd63eeb0  
    1616#include "Declaration.h"
    1717#include "Type.h"
    18 #include "utility.h"
     18#include "Common/utility.h"
    1919
    2020
  • src/SynTree/ApplicationExpr.cc

    r771b3c3 rd63eeb0  
    2020#include "Type.h"
    2121#include "TypeSubstitution.h"
    22 #include "utility.h"
     22#include "Common/utility.h"
    2323
    2424
  • src/SynTree/ArrayType.cc

    r771b3c3 rd63eeb0  
    1616#include "Type.h"
    1717#include "Expression.h"
    18 #include "utility.h"
     18#include "Common/utility.h"
    1919
    2020
  • src/SynTree/AttrType.cc

    r771b3c3 rd63eeb0  
    1616#include "Type.h"
    1717#include "Expression.h"
    18 #include "utility.h"
     18#include "Common/utility.h"
    1919
    2020
  • src/SynTree/CommaExpr.cc

    r771b3c3 rd63eeb0  
    1616#include "Expression.h"
    1717#include "Type.h"
    18 #include "utility.h"
     18#include "Common/utility.h"
    1919
    2020CommaExpr::CommaExpr( Expression *arg1, Expression *arg2, Expression *_aname )
  • src/SynTree/CompoundStmt.cc

    r771b3c3 rd63eeb0  
    1515
    1616#include "Statement.h"
    17 #include "utility.h"
     17#include "Common/utility.h"
    1818#include <algorithm>
    1919#include <functional>
  • src/SynTree/DeclStmt.cc

    r771b3c3 rd63eeb0  
    1616#include "Statement.h"
    1717#include "Declaration.h"
    18 #include "utility.h"
     18#include "Common/utility.h"
    1919
    2020DeclStmt::DeclStmt( std::list<Label> labels, Declaration *decl ) : Statement( labels ), decl( decl ) {
  • src/SynTree/Declaration.cc

    r771b3c3 rd63eeb0  
    2020#include "Initializer.h"
    2121#include "Type.h"
    22 #include "utility.h"
     22#include "Common/utility.h"
    2323
    2424static UniqueId lastUniqueId = 0;
  • src/SynTree/DeclarationWithType.cc

    r771b3c3 rd63eeb0  
    1616#include "Declaration.h"
    1717#include "Type.h"
    18 #include "utility.h"
     18#include "Common/utility.h"
    1919
    2020DeclarationWithType::DeclarationWithType( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage )
  • src/SynTree/Expression.cc

    r771b3c3 rd63eeb0  
    2626#include "Statement.h"
    2727#include "TypeSubstitution.h"
    28 #include "utility.h"
     28#include "Common/utility.h"
    2929
    3030
     
    103103SizeofExpr::SizeofExpr( Expression *expr_, Expression *_aname ) :
    104104                Expression( _aname ), expr(expr_), type(0), isType(false) {
    105         add_result( new BasicType( Type::Qualifiers(), BasicType::UnsignedInt ) );
     105        add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    106106}
    107107
    108108SizeofExpr::SizeofExpr( Type *type_, Expression *_aname ) :
    109109                Expression( _aname ), expr(0), type(type_), isType(true) {
    110         add_result( new BasicType( Type::Qualifiers(), BasicType::UnsignedInt ) );
     110        add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    111111}
    112112
     
    134134AlignofExpr::AlignofExpr( Expression *expr_, Expression *_aname ) :
    135135                Expression( _aname ), expr(expr_), type(0), isType(false) {
    136         add_result( new BasicType( Type::Qualifiers(), BasicType::UnsignedInt ) );
     136        add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    137137}
    138138
    139139AlignofExpr::AlignofExpr( Type *type_, Expression *_aname ) :
    140140                Expression( _aname ), expr(0), type(type_), isType(true) {
    141         add_result( new BasicType( Type::Qualifiers(), BasicType::UnsignedInt ) );
     141        add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
    142142}
    143143
     
    158158        else
    159159                expr->print(os, indent + 2);
     160
     161        os << std::endl;
     162        Expression::print( os, indent );
     163}
     164
     165UntypedOffsetofExpr::UntypedOffsetofExpr( Type *type_, const std::string &member_, Expression *_aname ) :
     166                Expression( _aname ), type(type_), member(member_) {
     167        add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
     168}
     169
     170UntypedOffsetofExpr::UntypedOffsetofExpr( const UntypedOffsetofExpr &other ) :
     171        Expression( other ), type( maybeClone( other.type ) ), member( other.member ) {}
     172
     173UntypedOffsetofExpr::~UntypedOffsetofExpr() {
     174        delete type;
     175}
     176
     177void UntypedOffsetofExpr::print( std::ostream &os, int indent) const {
     178        os << std::string( indent, ' ' ) << "Untyped Offsetof Expression on member " << member << " of ";
     179
     180        if ( type ) {
     181                type->print(os, indent + 2);
     182        } else {
     183                os << "<NULL>";
     184        }
     185
     186        os << std::endl;
     187        Expression::print( os, indent );
     188}
     189
     190OffsetofExpr::OffsetofExpr( Type *type_, DeclarationWithType *member_, Expression *_aname ) :
     191                Expression( _aname ), type(type_), member(member_) {
     192        add_result( new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt ) );
     193}
     194
     195OffsetofExpr::OffsetofExpr( const OffsetofExpr &other ) :
     196        Expression( other ), type( maybeClone( other.type ) ), member( maybeClone( other.member ) ) {}
     197
     198OffsetofExpr::~OffsetofExpr() {
     199        delete type;
     200        delete member;
     201}
     202
     203void OffsetofExpr::print( std::ostream &os, int indent) const {
     204        os << std::string( indent, ' ' ) << "Offsetof Expression on member ";
     205
     206        if ( member ) {
     207                os << member->get_name();
     208        } else {
     209                os << "<NULL>";
     210        }
     211
     212        os << " of ";
     213
     214        if ( type ) {
     215                type->print(os, indent + 2);
     216        } else {
     217                os << "<NULL>";
     218        }
    160219
    161220        os << std::endl;
  • src/SynTree/Expression.h

    r771b3c3 rd63eeb0  
    319319};
    320320
     321/// UntypedOffsetofExpr represents an offsetof expression before resolution
     322class UntypedOffsetofExpr : public Expression {
     323  public:
     324        UntypedOffsetofExpr( Type *type, const std::string &member, Expression *_aname = 0 );
     325        UntypedOffsetofExpr( const UntypedOffsetofExpr &other );
     326        virtual ~UntypedOffsetofExpr();
     327
     328        std::string get_member() const { return member; }
     329        void set_member( const std::string &newValue ) { member = newValue; }
     330        Type *get_type() const { return type; }
     331        void set_type( Type *newValue ) { type = newValue; }
     332
     333        virtual UntypedOffsetofExpr *clone() const { return new UntypedOffsetofExpr( *this ); }
     334        virtual void accept( Visitor &v ) { v.visit( this ); }
     335        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     336        virtual void print( std::ostream &os, int indent = 0 ) const;
     337  private:
     338        Type *type;
     339        std::string member;
     340};
     341
     342/// OffsetofExpr represents an offsetof expression
     343class OffsetofExpr : public Expression {
     344  public:
     345        OffsetofExpr( Type *type, DeclarationWithType *member, Expression *_aname = 0 );
     346        OffsetofExpr( const OffsetofExpr &other );
     347        virtual ~OffsetofExpr();
     348
     349        Type *get_type() const { return type; }
     350        void set_type( Type *newValue ) { type = newValue; }
     351        DeclarationWithType *get_member() const { return member; }
     352        void set_member( DeclarationWithType *newValue ) { member = newValue; }
     353
     354        virtual OffsetofExpr *clone() const { return new OffsetofExpr( *this ); }
     355        virtual void accept( Visitor &v ) { v.visit( this ); }
     356        virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     357        virtual void print( std::ostream &os, int indent = 0 ) const;
     358  private:
     359        Type *type;
     360        DeclarationWithType *member;
     361};
     362
    321363/// AttrExpr represents an @attribute expression (like sizeof, but user-defined)
    322364class AttrExpr : public Expression {
  • src/SynTree/FunctionDecl.cc

    r771b3c3 rd63eeb0  
    1919#include "Statement.h"
    2020#include "Type.h"
    21 #include "utility.h"
     21#include "Common/utility.h"
    2222
    2323FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn )
  • src/SynTree/FunctionType.cc

    r771b3c3 rd63eeb0  
    1818#include "Type.h"
    1919#include "Declaration.h"
    20 #include "utility.h"
     20#include "Common/utility.h"
    2121
    2222FunctionType::FunctionType( const Type::Qualifiers &tq, bool isVarArgs ) : Type( tq ), isVarArgs( isVarArgs ) {
  • src/SynTree/Initializer.cc

    r771b3c3 rd63eeb0  
    1616#include "Initializer.h"
    1717#include "Expression.h"
    18 #include "utility.h"
     18#include "Common/utility.h"
    1919
    2020Initializer::Initializer( bool maybeConstructed ) : maybeConstructed( maybeConstructed ) {}
  • src/SynTree/Initializer.h

    r771b3c3 rd63eeb0  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Jan 13 15:29:53 2016
    13 // Update Count     : 17
     12// Last Modified On : Tue Feb 09 14:40:15 2016
     13// Update Count     : 19
    1414//
    1515
     
    5858class SingleInit : public Initializer {
    5959  public:
    60         SingleInit( Expression *value, std::list< Expression *> &designators, bool maybeConstructed );
     60        SingleInit( Expression *value, std::list< Expression *> &designators, bool maybeConstructed = false );
    6161        SingleInit( const SingleInit &other );
    6262        virtual ~SingleInit();
     
    8383  public:
    8484        ListInit( std::list<Initializer*> &,
    85                           std::list<Expression *> &designators, bool maybeConstructed );
     85                          std::list<Expression *> &designators, bool maybeConstructed = false );
    8686        virtual ~ListInit();
    8787
  • src/SynTree/Mutator.cc

    r771b3c3 rd63eeb0  
    2222#include "Expression.h"
    2323#include "Constant.h"
    24 #include "utility.h"
     24#include "Common/utility.h"
    2525
    2626Mutator::Mutator() {}
     
    259259        }
    260260        return alignofExpr;
     261}
     262
     263Expression *Mutator::mutate( UntypedOffsetofExpr *offsetofExpr ) {
     264        mutateAll( offsetofExpr->get_results(), *this );
     265        offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) );
     266        return offsetofExpr;
     267}
     268
     269Expression *Mutator::mutate( OffsetofExpr *offsetofExpr ) {
     270        mutateAll( offsetofExpr->get_results(), *this );
     271        offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) );
     272        offsetofExpr->set_member( maybeMutate( offsetofExpr->get_member(), *this ) );
     273        return offsetofExpr;
    261274}
    262275
  • src/SynTree/Mutator.h

    r771b3c3 rd63eeb0  
    1616
    1717#include "SynTree.h"
    18 #include "SemanticError.h"
     18#include "Common/SemanticError.h"
    1919
    2020#ifndef MUTATOR_H
     
    6565        virtual Expression* mutate( SizeofExpr *sizeofExpr );
    6666        virtual Expression* mutate( AlignofExpr *alignofExpr );
     67        virtual Expression* mutate( UntypedOffsetofExpr *offsetofExpr );
     68        virtual Expression* mutate( OffsetofExpr *offsetofExpr );
    6769        virtual Expression* mutate( AttrExpr *attrExpr );
    6870        virtual Expression* mutate( LogicalExpr *logicalExpr );
  • src/SynTree/NamedTypeDecl.cc

    r771b3c3 rd63eeb0  
    1616#include "Declaration.h"
    1717#include "Type.h"
    18 #include "utility.h"
     18#include "Common/utility.h"
    1919
    2020NamedTypeDecl::NamedTypeDecl( const std::string &name, DeclarationNode::StorageClass sc, Type *base )
  • src/SynTree/ObjectDecl.cc

    r771b3c3 rd63eeb0  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Jan 13 16:11:19 2016
    13 // Update Count     : 29
     12// Last Modified On : Tue Feb 09 13:21:03 2016
     13// Update Count     : 30
    1414//
    1515
     
    1818#include "Initializer.h"
    1919#include "Expression.h"
    20 #include "utility.h"
     20#include "Common/utility.h"
    2121#include "Statement.h"
    2222
  • src/SynTree/PointerType.cc

    r771b3c3 rd63eeb0  
    1616#include "Type.h"
    1717#include "Expression.h"
    18 #include "utility.h"
     18#include "Common/utility.h"
    1919
    2020PointerType::PointerType( const Type::Qualifiers &tq, Type *base )
  • src/SynTree/ReferenceToType.cc

    r771b3c3 rd63eeb0  
    2121#include "Expression.h"
    2222#include "TypeSubstitution.h"
    23 #include "utility.h"
     23#include "Common/utility.h"
    2424
    2525ReferenceToType::ReferenceToType( const Type::Qualifiers &tq, const std::string &name ) : Type( tq ), name( name ) {
  • src/SynTree/SynTree.h

    r771b3c3 rd63eeb0  
    7070class SizeofExpr;
    7171class AlignofExpr;
     72class UntypedOffsetofExpr;
     73class OffsetofExpr;
    7274class AttrExpr;
    7375class LogicalExpr;
  • src/SynTree/TupleExpr.cc

    r771b3c3 rd63eeb0  
    1515
    1616#include "Expression.h"
    17 #include "utility.h"
     17#include "Common/utility.h"
    1818
    1919TupleExpr::TupleExpr( Expression *_aname ) : Expression( _aname ) {
  • src/SynTree/TupleType.cc

    r771b3c3 rd63eeb0  
    1515
    1616#include "Type.h"
    17 #include "utility.h"
     17#include "Common/utility.h"
    1818
    1919TupleType::TupleType( const Type::Qualifiers &tq ) : Type( tq ) {
  • src/SynTree/Type.cc

    r771b3c3 rd63eeb0  
    1818#include "Type.h"
    1919#include "Declaration.h"
    20 #include "utility.h"
     20#include "Common/utility.h"
    2121
    2222const char *BasicType::typeNames[BasicType::NUMBER_OF_BASIC_TYPES] = {
  • src/SynTree/TypeDecl.cc

    r771b3c3 rd63eeb0  
    1616#include "Declaration.h"
    1717#include "Type.h"
    18 #include "utility.h"
     18#include "Common/utility.h"
    1919
    2020TypeDecl::TypeDecl( const std::string &name, DeclarationNode::StorageClass sc, Type *type, Kind kind ) : Parent( name, sc, type ), kind( kind ) {
  • src/SynTree/TypeExpr.cc

    r771b3c3 rd63eeb0  
    1616#include "Expression.h"
    1717#include "Type.h"
    18 #include "utility.h"
     18#include "Common/utility.h"
    1919
    2020TypeExpr::TypeExpr( Type *type ) : type( type ) {
  • src/SynTree/TypeofType.cc

    r771b3c3 rd63eeb0  
    1616#include "Type.h"
    1717#include "Expression.h"
    18 #include "utility.h"
     18#include "Common/utility.h"
    1919
    2020TypeofType::TypeofType( const Type::Qualifiers &tq, Expression *expr ) : Type( tq ), expr( expr ) {
  • src/SynTree/Visitor.cc

    r771b3c3 rd63eeb0  
    219219}
    220220
     221void Visitor::visit( UntypedOffsetofExpr *offsetofExpr ) {
     222        acceptAll( offsetofExpr->get_results(), *this );
     223        maybeAccept( offsetofExpr->get_type(), *this );
     224}
     225
     226void Visitor::visit( OffsetofExpr *offsetofExpr ) {
     227        acceptAll( offsetofExpr->get_results(), *this );
     228        maybeAccept( offsetofExpr->get_type(), *this );
     229        maybeAccept( offsetofExpr->get_member(), *this );
     230}
     231
    221232void Visitor::visit( AttrExpr *attrExpr ) {
    222233        acceptAll( attrExpr->get_results(), *this );
  • src/SynTree/Visitor.h

    r771b3c3 rd63eeb0  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Jan 13 15:24:05 2016
    13 // Update Count     : 5
     12// Last Modified On : Tue Feb 09 13:20:48 2016
     13// Update Count     : 6
    1414//
    1515
     
    1818
    1919#include "SynTree.h"
    20 #include "SemanticError.h"
    21 #include "CompilerError.h"
     20#include "Common/SemanticError.h"
     21#include "Common/CompilerError.h"
    2222
    2323class Visitor {
     
    6565        virtual void visit( SizeofExpr *sizeofExpr );
    6666        virtual void visit( AlignofExpr *alignofExpr );
     67        virtual void visit( UntypedOffsetofExpr *offsetofExpr );
     68        virtual void visit( OffsetofExpr *offsetofExpr );
    6769        virtual void visit( AttrExpr *attrExpr );
    6870        virtual void visit( LogicalExpr *logicalExpr );
Note: See TracChangeset for help on using the changeset viewer.