source: translator/initialization.txt @ 1db2c5be

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since 1db2c5be was 51b7345, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

initial commit

  • Property mode set to 100644
File size: 1.4 KB
RevLine 
[51b7345]1From the refrat (5.5) we have our specification:
2
3    \section{Initialization} An expression that is used as an
4    \nonterm{initializer} is treated as being cast to the type of the
5    object being initialized.  An expression used in an
6    \nonterm{initializer-list} is treated as being cast to the type of
7    the aggregate member that it initializes.  In either case the cast
8    must have a single unambiguous
9    interpretation\index{interpretations}.
10
11Steps:
12
13- add a member function "void Resolver::visit( SynTree::DeclStmt
14*declStmt )"; for each DeclStmt:
15
16- do what you need to do to establish correspondences between
17expressions in the initializer and pieces of the object to be
18initialized
19
20- for each initializer expression, construct a cast expression that
21casts the value of the expression to the type of the corresponding
22sub-object
23
24- invoke the resolver recursively on each cast expression; it's an invariant
25of the resolver that attempting to resolve a cast expression results either
26in a single resolved expression (corresponding to the unambiguous interpretation
27referred to above) or a thrown SemanticError.
28
29- construct a new initializer from the resolved expressions
30
31You'll undoubtedly have to play with the CodeGen stuff a bit; I
32hacked it to spit out unresolved initializers for file-scope
33declarations so that real programs would compile.  You'll want to make
34sure that resolved initializers for all declarations are being
35generated.
Note: See TracBrowser for help on using the repository browser.