Changeset 77a3f41


Ignore:
Timestamp:
May 9, 2019, 5:53:29 PM (2 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
arm-eh, cleanup-dtors, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr
Children:
14cebb7a
Parents:
3e46cc8
Message:

Added ObjectDecl? to new AST

Location:
src/AST
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Decl.hpp

    r3e46cc8 r77a3f41  
    3434class Attribute;
    3535class Expr;
     36class Init;
    3637class TypeDecl;
    3738
     
    8485
    8586        /// Get type of this declaration. May be generated by subclass
    86         virtual const Type* type() const = 0;
     87        virtual const Type* get_type() const = 0;
    8788        /// Set type of this declaration. May be verified by subclass
    8889        virtual void set_type(Type*) = 0;
     
    9192private:
    9293        virtual DeclWithType* clone() const override = 0;
     94};
     95
     96/// Object declaration `Foo foo = 42;`
     97class ObjectDecl final : public DeclWithType {
     98public:
     99        ptr<Type> type;
     100        ptr<Init> init;
     101        ptr<Expr> bitfieldWidth;
     102
     103        ObjectDecl( const CodeLocation& loc, const std::string& name, Type* type, Init* init = nullptr,
     104                Storage::Classes storage = {}, Linkage::Spec linkage = Linkage::C, Expr* bitWd = nullptr,
     105                std::vector<ptr<Attribute>>&& attrs = {}, Function::Specs fs = {})
     106        : DeclWithType( loc, name, storage, linkage, std::move(attrs), fs ), type( type ),
     107          init( init ), bitfieldWidth( bitWd ) {}
     108       
     109        const Type* get_type() const override { return type; }
     110        void set_type( Type* ty ) override { type = ty; }
     111
     112        DeclWithType* accept( Visitor& v ) override { return v.visit( this ); }
     113private:
     114        ObjectDecl* clone() const override { return new ObjectDecl{ *this }; }
    93115};
    94116
  • src/AST/porting.md

    r3e46cc8 r77a3f41  
    8282* When `SymTab::Validate::Pass2` is rewritten, update comment on `mangleName` with new name of pass
    8383* `get_scopedMangleName()` => `scopedMangleName()`
    84 * `get_type()` => `type()`
    85   * now returns `const Type*` so can't be inadvertently mutated
     84* `get_type()` now returns `const Type*` so can't be inadvertently mutated
     85  * still with `get_` name so it doesn't conflict with subclass field names
     86
     87`ObjectDecl`
     88* changed constructor parameter order for better defaults
     89  * allows `newObject` as just default settings
    8690
    8791`EnumDecl`
Note: See TracChangeset for help on using the changeset viewer.