- Timestamp:
- Jun 23, 2017, 4:20:33 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 74e58ea3, 7bbba76
- Parents:
- e1c1829 (diff), 88177cf (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- doc
- Files:
-
- 5 edited
-
LaTeXmacros/common.tex (modified) (3 diffs)
-
proposals/tagged-struct.txt (modified) (3 diffs)
-
rob_thesis/intro.tex (modified) (2 diffs)
-
rob_thesis/thesis.tex (modified) (1 diff)
-
working/exception/translate.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
doc/LaTeXmacros/common.tex
re1c1829 r4c03e63 11 11 %% Created On : Sat Apr 9 10:06:17 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Mon May 15 18:03:29201714 %% Update Count : 3 0213 %% Last Modified On : Sun Jun 18 20:32:32 2017 14 %% Update Count : 319 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 36 36 % Names used in the document. 37 37 38 \newcommand{\CFA}{\textrm{C}\raisebox{\depth}{\rotatebox{180}{\textsf{A}}}\xspace} % Cforall symbolic name 38 \newcommand{\CFAIcon}{\textrm{C}\raisebox{\depth}{\rotatebox{180}{\textsf{A}}}\xspace} % Cforall symbolic name 39 \newcommand{\CFA}{\protect\CFAIcon} % safe for section/caption 39 40 \newcommand{\CFL}{\textrm{Cforall}\xspace} % Cforall symbolic name 40 41 \newcommand{\Celeven}{\textrm{C11}\xspace} % C11 symbolic name … … 241 242 belowskip=3pt, 242 243 % replace/adjust listing characters that look bad in sanserif 243 literate={-}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.8ex}{0. 075ex}}}}1 {^}{\raisebox{0.6ex}{$\scriptscriptstyle\land\,$}}1244 literate={-}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.8ex}{0.1ex}}}}1 {^}{\raisebox{0.6ex}{$\scriptscriptstyle\land\,$}}1 244 245 {~}{\raisebox{0.3ex}{$\scriptstyle\sim\,$}}1 {`}{\ttfamily\upshape\hspace*{-0.1ex}`}1 245 {__}{\_\,\_}2 {<-}{$\leftarrow$}2 {=>}{$\Rightarrow$}2 {->}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.8ex}{0.075ex}}}\kern-0.2ex\textgreater}2 246 {___}{\_\,\_\,\_}3, 246 {<-}{$\leftarrow$}2 {=>}{$\Rightarrow$}2 {->}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.8ex}{0.075ex}}}\kern-0.2ex\textgreater}2, 247 247 moredelim=**[is][\color{red}]{®}{®}, % red highlighting ®...® (registered trademark symbol) emacs: C-q M-. 248 248 moredelim=**[is][\color{blue}]{ß}{ß}, % blue highlighting ß...ß (sharp s symbol) emacs: C-q M-_ -
doc/proposals/tagged-struct.txt
re1c1829 r4c03e63 14 14 say which of the possible values is currently stored in the union. The idea 15 15 here is similar, however the possibilities are more open ended. 16 17 Alternate names include virtual structure and abstract structure. 16 18 17 19 … … 36 38 their parent's fields to their field list so they can be upcast. 37 39 40 The type field may be public, if it is then it can be accessed through a 41 simple field access "instance.type". The type field would then be able to be 42 used to access the type object, which contains the information for the type. 43 It may just be a pointer to the type object "*instance.type", although a 44 lookup function could also be used. 45 46 47 Usage: 48 49 The central feature for tagged structs is a checked cast between pointer types 50 to the structures. A cast is successful if the true type of the pointed object 51 is of the type being cast to or any of its children, otherwise the cast 52 returns null. 53 54 The type field should also allow for equality comparison of types. 55 56 Currently, with only these operations (and similar features) the type field 57 could be hidden and the operations given through helper functions. However 58 if the type object has more complex (or even open ended) information in it 59 than providing direct access becomes very valuable. 60 38 61 39 62 Implemenation: 40 63 41 Adding to the field list is a simple matter, should be doable during 42 translation. The type field is just a pointer to a type object. With proper 43 linking we can create a single unique instance of the type object for each 44 declared tagged struct. The instance's address is used as an id for the type. 45 It also holds data about the type, such as its parent's id/a pointer to the 46 parent type object. 64 Adding to the field list would have to be handled during translation. The 65 simple act of adding declarations should not be difficult, althought it might 66 take a bit of work to find the parent's declarations. 47 67 48 The type field could be hidden (as best as C can hide it) or it could be 49 visible to the user with easy access to allow the user to examine the type 50 object directly. 51 52 Direct access is more useful if the data on the type-objects can change, other 53 wise the build in function could handle all cases. Perhaps each root object 54 can specify a type object to use or the type objects are themselves tagged, 55 although there may not be a base case with the latter. 56 57 In the simplest case the type object is a pointer to the parent type object. 58 Additional data could be added, such as a name, or a function pointer to the 59 destructor. 68 Type objects are also simple in to generate, they should just be global 69 (program lifetime) structures. Getting there to be exactly one instance of 70 each allows the pointer to the structure to be used as the type id, and that 71 should be possible to do during linking. 60 72 61 73 … … 94 106 If unions are declared tagged instead of creating a new tagged type, all 95 107 possible values of the union must be of that tagged type or a child type. 108 109 110 Custom Type Objects (Extention): 111 112 Some method to define type objects used within a tree of types. One option is 113 to allow the tree's type object to be specified by the tree root. It would 114 then have to be filled in for each type in the tree, including the root. 115 116 The only required field is the parent field, a pointer to the type object's 117 type. (This is also the only required field on the tagged structure itself.) 118 119 A further extention could allow expanding type objects, so child types could 120 append fields to their parent's feild list. They might need their own type 121 objects at that point, or maybe static checks will be enough to see the 122 minimum field list. -
doc/rob_thesis/intro.tex
re1c1829 r4c03e63 3 3 %====================================================================== 4 4 5 \section{\ CFA Background}5 \section{\protect\CFA Background} 6 6 \label{s:background} 7 7 \CFA \footnote{Pronounced ``C-for-all'', and written \CFA or Cforall.} is a modern non-object-oriented extension to the C programming language. … … 370 370 \end{tabular} 371 371 \end{center} 372 \caption{\label{table:types} The different kinds of type parameters in \ CFA}372 \caption{\label{table:types} The different kinds of type parameters in \protect\CFA} 373 373 \end{table} 374 374 -
doc/rob_thesis/thesis.tex
re1c1829 r4c03e63 66 66 % ,monochrome % toggle black and white mode 67 67 }{xcolor} 68 \PassOptionsToPackage{pdftex}{graphicx} 68 69 \documentclass[letterpaper,12pt,titlepage,oneside,final]{book} 69 70 -
doc/working/exception/translate.c
re1c1829 r4c03e63 1 1 /* Translation rules for exception handling code, from Cforall to C. 2 2 * 3 * Note that these are not final. Names, syntax and the exact translation 4 * will be updated. The first section is the shared definitions, not generated 5 * by the local translations but used by the translated code. 3 * Reminder: This is not final. Besides names and things it is also going very 4 * much for correctness and simplisity over efficiency. 5 * 6 * The first section is the shared definitions, not generated by the local 7 * translations but used by the translated code. 6 8 * 7 9 * Most of these exist only after translation (in C code). The first (the … … 16 18 typedef int exception; 17 19 20 // Will have to be availibe to user. Consider new name. Requires tagged types. 21 forall(dtype parent | tagged(parent), dtype child | tagged(child)) 22 parent *dynamic_cast(child *); 23 18 24 void __throw_terminate(exception except) __attribute__((noreturn)); 19 25 void __rethrow_terminate() __attribute__((noreturn)); … … 116 122 } 117 123 int match1(exception except) { 118 OtherException inner_except; 119 if (dynamic_cast__SomeException(except)) { 120 return 1; 121 } 122 else if ( (inner_except = dynamic_cast__OtherException(except)) && 123 inner_except.priority > 3) { 124 return 2; 125 } 126 else return 0; 124 { 125 if (dynamic_cast__SomeException(except)) { 126 return 1; 127 } 128 } 129 { 130 OtherException err; 131 if ( (err = dynamic_cast__OtherException(except)) && 132 err.priority > 3) { 133 return 2; 134 } 135 } 136 return 0; 127 137 } 128 138 __try_terminate(try1, catch1, match1); … … 151 161 { 152 162 bool handle1(exception except) { 153 OtherException inner_except; 154 if (dynamic_cast__SomeException(except)) { 155 fiddleThing(); 156 return true; 157 } else if (dynamic_cast__OtherException(except) && 158 inner_except.priority > 3) { 159 twiddleWidget(); 160 return true; 161 } else { 162 return false; 163 } 163 { 164 if (dynamic_cast__SomeException(except)) { 165 fiddleThing(); 166 return true; 167 } 168 } 169 { 170 OtherException err; 171 if ( ( err = dynamic_cast__OtherException(except) ) && 172 err.priority > 3) { 173 twiddleWidget(); 174 return true; 175 } 176 } 177 return false; 164 178 } 165 179 struct __try_resume_node data = … … 230 244 } 231 245 bool handle1(exception except) { 232 if (dynamic_cast__SomeException(except)) { 233 fiddleThing(); 234 return true; 235 } else { 236 return false; 237 } 246 { 247 if (dynamic_cast__SomeException(except)) { 248 fiddleThing(); 249 return true; 250 } 251 } 252 return false; 238 253 } 239 254 struct __cleanup_hook generated_name … … 273 288 { 274 289 bool handle1() { 275 if (dynamic_cast__OtherException(except)) { 276 twiddleWidget(); 277 return true; 290 { 291 if (dynamic_cast__OtherException(except)) { 292 twiddleWidget(); 293 return true; 294 } 278 295 } 279 296 return false; … … 297 314 } 298 315 int match1(exception except) { 299 if (dynamic_cast__SomeException(except)) { 300 return 1; 316 { 317 if (dynamic_cast__SomeException(except)) { 318 return 1; 319 } 301 320 } 302 321 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.