Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/porting.md

    r54e41b3 r1e97287  
    66  * specialization: strong pointer `ast::ptr<T>` is used for an ownership relationship
    77  * specialization: weak pointer `ast::readonly<T>` is used for an observation relationship
    8 * added `ast::ptr_base<T,R>::as<S>()` with same semantics as `dynamic_cast<S*>(p)`
    9 * added `N * ast::ptr_base<N,R>::set_and_mutate( const N * n )`
    10   * takes ownership of `n`, then returns a mutable version owned by this pointer
    11   * Some debate on whether this is a good approach:
    12     * makes an easy path to cloning, which we were trying to eliminate
    13       * counter-point: these are all mutating clones rather than lifetime-preserving clones, and thus "necessary" (for some definition)
    14     * existing uses:
    15       * `VariableExpr::VariableExpr`, `UntypedExpr::createDeref`
    16         * both involve grabbing a type from elsewhere and making an `lvalue` copy of it
    17         * could potentially be replaced by a view class something like this:
    18           ```
    19           template<unsigned Quals>
    20           class AddQualifiersType final : public Type {
    21             readonly<Type> base;
    22             // ...
    23           };
    24           ```
    25           * requires all `qualifiers` use (and related helpers) to be virtual, non-zero overhead
    26           * also subtle semantic change, where mutations to the source decl now change the viewing expression
     8  * added `ast::ptr_base<T,R>::as<S>()` with same semantics as `dynamic_cast<S*>(p)`
    279
    2810## Visitors ##
     
    5436* allows compiler to optimize virtual calls to static calls if given static type
    5537
    56 Pulled `FuncSpecifiers`, `StorageClasses`, `CVQualifiers` out of `Type` into their own headers
     38Pulled `FuncSpecifiers` and `StorageClasses` out of `Type` into their own headers
    5739* Made `BFCommon` a `MakeBitfield` macro in its own header
    5840  * added default and field-init constructors to macro
     
    8870        * `Initializer` => `ast::Init`
    8971    * `Statement` => `ast::Stmt`
    90         * any field names should follow a similar renaming
    9172  * because they don't really belong to `Type` (and for consistency with `Linkage::Spec`):
    9273    * `Type::StorageClasses` => `ast::Storage::Classes`
    9374          * `Type::Extern` etc. => `ast::Storage::Extern` etc.
    94         * `Type::FuncSpecifiers` => `ast::Function::Specs`
    95           * `Type::Inline` etc. => `ast::Function::Inline` etc.
    96         * `Type::Qualifiers` => `ast::CV::Qualifiers`
    97           * `Type::Const` etc. => `ast::CV::Const`
    98           * couldn't break name-dependency loop without pulling `Qualifiers` out of `Type`
    9975        * `LinkageSpec::Spec` => `ast::Linkage::Spec`
    10076          * `LinkageSpec::Mangle` etc. => `ast::Linkage::Mangle` etc.
     
    10379          * `LinkageSpec::isMangled(Spec)` etc. => `Spec.is_mangled` etc.
    10480          * `LinkageSpec::Intrinsic` etc. => `ast::Linkage::Intrinsic` etc.
    105 * Boolean constructor parameters get replaced with a dedicated flag enum:
    106   * e.g. `bool isVarLen;` => `enum LengthFlag { FixedLen, VariableLen };` `LengthFlag isVarLen;`
    107   * field can be *read* in the existing boolean contexts, but requires documentation to write
    108   * suggest naming all flag enums `FooFlag` to hint at boolean nature
    10981
    11082## Specific Nodes ##
     
    12496  * allows `newObject` as just default settings
    12597
    126 `NamedTypeDecl`
    127 * `parameters` => `params`
    128 
    12998`TypeDecl`
    130 * moved `TypeDecl::Kind` to `ast::TypeVar::Kind`
    131 
    132 `AggregateDecl`
    133 * `parameters` => `params`
     99* stripped `isComplete()` accessor in favour of direct access to `sized`
    134100
    135101`EnumDecl`
     
    139105* Merged `inferParams`/`resnSlots` into union, as suggested by comment in old version
    140106  * does imply get_/set_ API, and some care about moving backward
    141 * added constructor that sets result, for benefit of types that set it directly
    142 
    143 `ApplicationExpr`
    144 * `function` => `func`
    145 
    146 `UntypedExpr`
    147 * `function` => `func`
    148 * removed `begin_args()` in favour of `args.begin()`
    149 
    150 `MemberExpr`
    151 * **TODO** port setup of `result` in constructor
    152 
    153 `ConstantExpr`
    154 * inlined features of `Constant`, never used elsewhere, so removed `Constant`
    155   * `Constant Constant::from_int(int)` etc. => `ConstantExpr * ConstantExpr::from_int(CodeLocation, int)`
    156     * allocates new `ConstantExpr`, consistent with all existing uses
    157 
    158 `SizeofExpr`, `AlignofExpr`
    159 * `isType` deprecated in favour of boolean check on `type`
    160   * all existing uses assume `type` set if true and don't use `expr`
    161 
    162 `AttrExpr`
    163 * did not port due to feature deprecation (e.g. `expr@attribute`)
    164 
    165 `LogicalExpr`
    166 * un-defaulted constructor parameter determining `&&` or `||`
    167 
    168 `Init`
    169 * `bool maybeConstruct` => `enum ConstructFlag { DoConstruct, MaybeConstruct }`
    170107
    171108`Label`
     
    192129* **TODO** port copy operator
    193130  * Needs to be an almost-shallow clone, where the declarations are cloned only if needed
    194   * **TODO** port `DeclReplacer`
     131  * **TODO** port DeclReplacer
    195132* Still a `std::list` for children, rather than `std::vector`
    196133  * allows more-efficient splicing for purposes of later code generation
    197134
    198135`Type`
    199 * `CV::Qualifiers` moved to end of constructor parameter list, defaulted to `{}`
    200   * removed getter, setter in favour of public `qualifiers` field
    201   * `ReferenceToType` puts a defaulted list of attributes after qualifiers
    202136* `forall` field split off into `ParameterizedType` subclass
    203137  * any type that needs it can inherit from `ParameterizedType`
    204     * currently `FunctionType`, `ReferenceToType`
    205138* `get_qualifiers()` replaced with accessor `qualifiers()` and mutator `set_qualifiers()`
    206   * `get_const()` etc. replaced with `is_const()` etc. variants
    207 * `referenceDepth()` now returns `unsigned` rather than `int`
     139  * `get_CV()` replaced with `is_CV()` variants
    208140* A number of features only supported on aggregates pushed down to `ReferenceToType`:
    209141  * `attributes`: per docs [1] GCC only supports type attributes on aggregates and typedefs
    210142    * suggest adding a `TypeWithAttributes` wrapper type if this proves insufficient
    211   * `getAggr()` => `aggr()`
    212     * also now returns `const AggregateDecl *`
    213 * `genericSubstitution()` moved to own visitor in `AST/GenericSubstitution.hpp` **TODO** write
     143  * `getAggr()`
     144  * `genericSubstitution()`
    214145
    215146`BasicType`
     147* does not inherit from `Type` to allow pointer inlining
     148* moved `Kind` before qualifiers in constructor to allow for default
    216149* **TODO** move `kind`, `typeNames` into code generator
    217 
    218 `ReferenceToType`
    219 * deleted `get_baseParameters()` from children
    220   * replace with `aggr() ? aggr()->params : nullptr`
    221 * `parameters` => `params`
    222 * hoisted `lookup` implementation into parent, made non-virtual
    223   * also changed to return vector rather than filling; change back if any great win for reuse
    224 * `baseStruct` etc. renamed to `base`
    225 
    226 `PointerType`/`ArrayType`
    227 * `is_array()` => `isArray()`
    228 * `bool isVarLen;` => `enum LengthFlag { FixedLen, VariableLen }; LengthFlag isVarLen;`
    229 * `bool isStatic;` => `enum DimensionFlag { DynamicDim, StaticDim }; DimensionFlag isStatic;`
    230 
    231 `FunctionType`
    232 * `returnVals` => `returns`
    233 * `parameters` => `params`
    234 * `bool isVarArgs;` => `enum ArgumentFlag { FixedArgs, VariableArgs }; ArgumentFlag isVarArgs;`
    235 
    236 `TypeInstType`
    237 * `bool isFtype` => `TypeVar::Kind kind`
    238 
    239 `TypeofType`
    240 * `bool is_basetypeof` => `enum Kind { Typeof, Basetypeof } kind;`
    241 
    242 `TupleType`
    243 * removed `value_type` typedef due to likely error
    244   * if readded, should be `const Type *`
    245 
    246 `AttrType`
    247 * did not port due to deprecation of feature
    248   * feature is `type@thing` e.g. `int@MAX`
    249150
    250151[1] https://gcc.gnu.org/onlinedocs/gcc-9.1.0/gcc/Type-Attributes.html#Type-Attributes
Note: See TracChangeset for help on using the changeset viewer.