Changeset 7cd23d5
- Timestamp:
- Nov 26, 2015, 6:06:12 PM (9 years ago)
- 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, string, with_gc
- Children:
- ed1065c
- Parents:
- 13ca524
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/RemoveInit.cc
r13ca524 r7cd23d5 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Mon Nov 16 16:58:36201513 // Update Count : 3011 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue May 19 16:39:32 2015 13 // Update Count : 1 14 14 // 15 15 … … 21 21 #include "SynTree/Initializer.h" 22 22 #include "SynTree/Mutator.h" 23 24 // changes to Validate:25 // -check that ctor/dtor has >= 1 argument26 // -check that first argument to ctor/dtor has pointer type27 // -check that return type is void (0 return types)28 // -transform ctor to return its first argument29 // -generate ctors and dtors alongside ?=? for aggregate types30 31 // idea: modify this pass to decide whether an object declaration is32 // POD type.33 // - If it is not POD-type, initialization should be changed into34 // 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-initializer37 // form and resolve as normal, since we don't want to actually incur38 // 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 below48 // change into constructor form if no designations49 // if not POD type, error out if there are designations50 // if there are designations, handle them in the resolver51 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 form54 // for codegen, it'll depend on exactly what the expressions that are fed to the resolver look like55 // 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 essentially75 // already doing this in the resolver, so whatever I guess?)76 // (note this requires an alternative finder, because these may be77 // function calls, not just simple literals)78 // (this is a bit of a recursive problem - in order to know how to group79 // the expressions into a struct to be an argument to a constructor, I need to80 // know what the constructor's signature looks like - but in order to figure out81 // which constructor is being used (and thus what its signature looks like), I need82 // to group the values into a struct type)83 // (this seems to imply (to me, anyway) that C initializers can't be represented as84 // constructors without an exponential blowup in the number of constructors present)85 23 86 24 namespace InitTweak {
Note: See TracChangeset
for help on using the changeset viewer.