Changes in / [b81096f:13ca524]


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/RemoveInit.cc

    rb81096f r13ca524  
    99// Author           : Rodolfo G. Esteves
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue May 19 16:39:32 2015
    13 // Update Count     : 1
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Mon Nov 16 16:58:36 2015
     13// Update Count     : 30
    1414//
    1515
     
    2121#include "SynTree/Initializer.h"
    2222#include "SynTree/Mutator.h"
     23
     24// changes to Validate:
     25// -check that ctor/dtor has >= 1 argument
     26// -check that first argument to ctor/dtor has pointer type
     27// -check that return type is void (0 return types)
     28// -transform ctor to return its first argument
     29// -generate ctors and dtors alongside ?=? for aggregate types
     30
     31// idea: modify this pass to decide whether an object declaration is
     32// POD type.
     33// - If it is not POD-type, initialization should be changed into
     34//   a constructor call.
     35// - If it is a POD type, then check that there are no designations.
     36//   It is probably easiest to leave the declaration in C-initializer
     37//   form and resolve as normal, since we don't want to actually incur
     38//   the cost of a constructor unless we have to.
     39
     40// change indexer to remove all constructors for a type once a user-defined one appears?
     41
     42// question: if a destructor is declared before the scope of a variable ends,
     43// should it be destructed? Or should we decide this at declaration point?
     44
     45
     46// alternative (that I think I like better, if there aren't any flaws)
     47//   --flaw appears to be the exponential blowup in the number of ctors described below
     48// change into constructor form if no designations
     49// if not POD type, error out if there are designations
     50// if there are designations, handle them in the resolver
     51
     52// ==MAYBE== even possible to rewrite designations not as ?=?, but as ?{} (see initialization.txt)
     53// there may be some transformation that's required to bring this back into a reasonable form
     54// for codegen, it'll depend on exactly what the expressions that are fed to the resolver look like
     55// e.g.
     56
     57// struct A {
     58//   struct B { int x; } b;
     59//   struct C { int x, y, z } c;
     60//   struct D { int x; } d;
     61// }
     62//
     63// A a = { 1, 2, 3, 4, 5 };
     64// => struct A a;
     65//    ?{}(&a.b, (struct B){ 1 } );
     66//    ?{}(&a.c, (struct C){ 2, 3, 4 } );
     67//    ?{}(&a.d, (struct D){ 5 } );
     68// (it obviously shouldn't look like this, but what should it look like??)
     69//
     70// (perhaps this?)
     71// => struct A a;
     72//    ?{}(&a, (struct B){ 1 }, (struct C){ 2, 3, 4 }, (struct D){ 5 });
     73// (of course, this requires me to do the grouping found here,
     74//  and remember that parts might be missing! That said, I'm essentially
     75//  already doing this in the resolver, so whatever I guess?)
     76// (note this requires an alternative finder, because these may be
     77//  function calls, not just simple literals)
     78// (this is a bit of a recursive problem - in order to know how to group
     79//  the expressions into a struct to be an argument to a constructor, I need to
     80//  know what the constructor's signature looks like - but in order to figure out
     81//  which constructor is being used (and thus what its signature looks like), I need
     82//  to group the values into a struct type)
     83// (this seems to imply (to me, anyway) that C initializers can't be represented as
     84//  constructors without an exponential blowup in the number of constructors present)
    2385
    2486namespace InitTweak {
Note: See TracChangeset for help on using the changeset viewer.