Changeset ec71a50
- Timestamp:
- Sep 21, 2018, 11:26:31 PM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- 3b1825b, fcc57ba
- Parents:
- 031a88a9 (diff), 371ef1d (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. - Files:
-
- 2 added
- 1 deleted
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/aaron_moss_PhD/phd/Makefile
r031a88a9 rec71a50 1 LATEX = pdflatex -interaction=nonstopmode 2 BIBTEX = bibtex 1 BUILD = build 2 BIBDIR = ../../../bibliography 3 TEXLIB = .:${BUILD}:${BIBDIR}: 4 5 LATEX = TEXINPUTS=${TEXLIB} && export TEXINPUTS && pdflatex -interaction= -output-directory=${BUILD} 6 BIBTEX = BIBINPUTS=${TEXLIB} && export BIBINPUTS && bibtex 3 7 4 8 BASE = thesis 5 9 DOCUMENT = ${BASE}.pdf 6 AUX = ${BASE}.aux ${BASE}.bbl ${BASE}.blg ${BASE}.log ${BASE}.out ${BASE}.toc 10 BIBFILE = ${BIBDIR}/pl.bib 7 11 8 12 SOURCES = ${addsuffix .tex, \ … … 23 27 24 28 clean : 25 @rm -f rv ${DOCUMENT} ${AUX}29 @rm -fv ${BUILD}/* 26 30 27 31 wc : 28 32 wc ${SOURCES} 29 33 30 ${DOCUMENT} : ${SOURCES} 34 ${DOCUMENT} : ${SOURCES} ${BUILD} 31 35 ${LATEX} ${BASE} 32 36 ${LATEX} ${BASE} 33 37 34 rebuild-refs : ${SOURCES} aaron-thesis.bib38 rebuild-refs : ${SOURCES} ${BIBFILE} ${BUILD} 35 39 ${LATEX} ${BASE} 36 ${BIBTEX} ${B ASE}40 ${BIBTEX} ${BUILD}/${BASE} 37 41 ${LATEX} ${BASE} 38 42 ${LATEX} ${BASE} 43 44 ${BUILD}: 45 mkdir -p ${BUILD} -
doc/theses/aaron_moss_PhD/phd/background.tex
r031a88a9 rec71a50 1 \chapter{ Background}1 \chapter{\CFA{}} 2 2 3 3 \CFA{} adds a number of features to C, some of them providing significant increases to the expressive power of the language, but all designed to maintain the existing procedural programming paradigm of C and to be as orthogonal as possible to each other. … … 21 21 It is important to note that \CFA{} is not an object-oriented language. 22 22 This is a deliberate choice intended to maintain the applicability of the mental model and language idioms already possessed by C programmers. 23 This choice is in marked contrast to \CC{}, which, though it has backward-compatibility with C on the source code level, is a much larger and more complex language, and requires extensive developer re-training before they canwrite idiomatic, efficient code in \CC{}'s object-oriented paradigm.23 This choice is in marked contrast to \CC{}, which, though it has backward-compatibility with C on the source code level, is a much larger and more complex language, and requires extensive developer re-training to write idiomatic, efficient code in \CC{}'s object-oriented paradigm. 24 24 25 25 \CFA{} does have a system of implicit type conversions derived from C's ``usual arithmetic conversions''; while these conversions may be thought of as something like an inheritance hierarchy, the underlying semantics are significantly different and such an analogy is loose at best. … … 62 62 struct counter { int x; }; 63 63 64 counter& `++?`(counter& c) { ++c.x; return c; } $\C {// pre-increment}$65 counter `?++`(counter& c) { $\C {// post-increment}$64 counter& `++?`(counter& c) { ++c.x; return c; } $\C[2in]{// pre-increment}$ 65 counter `?++`(counter& c) { $\C[2in]{// post-increment}$ 66 66 counter tmp = c; ++c; return tmp; 67 67 } 68 bool `?<?`(const counter& a, const counter& b) { $\C {// comparison}$68 bool `?<?`(const counter& a, const counter& b) { $\C[2in]{// comparison}$ 69 69 return a.x < b.x; 70 70 } … … 73 73 Together, \CFA{}'s backward-compatibility with C and the inclusion of this operator overloading feature imply that \CFA{} must select among function overloads using a method compatible with C's ``usual arithmetic conversions''\cit{}, so as to present user programmers with only a single set of overloading rules. 74 74 75 \subsection{Polymorphic Functions} 75 \subsubsection{Special Literal Types} 76 77 Literal !0! is also used polymorphically in C; it may be either integer zero or the null value of any pointer type. 78 \CFA{} provides a special type for the !0! literal, !zero_t!, so that users can define a zero value for their own types without being forced to create a conversion from an integer or pointer type (though \CFA{} also includes implicit conversions from !zero_t! to the integer and pointer types for backward compatibility). 79 80 According to the C standard\cit{}, !0! is the only false value; any value that compares equal to zero is false, while any value that does not is true. 81 By this rule, boolean contexts such as !if ( x )! can always be equivalently rewritten as \lstinline{if ( (x) != 0 )}. 82 \CFACC{} applies this rewriting in all boolean contexts, so any type !T! can be made ``truthy'' (that is, given a boolean interpretation) in \CFA{} by defining an operator overload \lstinline{int ?!=?(T, zero_t)}; unlike \CC{} prior to the addition of explicit casts in \CCeleven{}, this design does not add comparability or convertablity to arbitrary integer types. 83 84 \CFA{} also includes a special type for !1!, !one_t!; like !zero_t!, !one_t! has built-in implicit conversions to the various integral types so that !1! maintains its expected semantics in legacy code. 85 The addition of !one_t! allows generic algorithms to handle the unit value uniformly for types where it is meaningful; a simple example of this is that polymorphic functions\footnote{discussed in Section~\ref{poly-func-sec}} in the \CFA{} prelude define !++x! and !x++! in terms of !x += 1!, allowing users to idiomatically define all forms of increment for a type !T! by defining the single function !T& ?+=?(T&, one_t)!; analogous overloads for the decrement operators are also present, and programmers can override any of these functions for a particular type if desired. 86 87 \CFA{} previously allowed !0! and !1! to be the names of polymorphic variables, with separate overloads for !int 0!, !int 1!, and !forall(dtype T) T* 0!. 88 As revealed in my own work on generic types (Chapter~\ref{generic-chap}), the parameteric polymorphic zero variable was not generalizable to other types; though all null pointers have the same in-memory representation, the same cannot be said of the zero values of arbitrary types. 89 As such, variables that could represent !0! and !1! were phased out in favour of functions that could generate those values for a given type as appropriate. 90 91 \subsection{Polymorphic Functions} \label{poly-func-sec} 76 92 77 93 The most significant feature \CFA{} adds is parametric-polymorphic functions. … … 91 107 One benefit of this design is that it allows polymorphic functions to be separately compiled. 92 108 The forward declaration !forall(otype T) T identity(T);! uniquely defines a single callable function, which may be implemented in a different file. 93 The fact that there is only one implementation of each polymorphic function also reduces compile times relative to the template-expansion approach taken by \CC{}, as well as reducing binary sizes and runtime pressure on instruction cache atby re-using a single version of each function.109 The fact that there is only one implementation of each polymorphic function also reduces compile times relative to the template-expansion approach taken by \CC{}, as well as reducing binary sizes and runtime pressure on instruction cache by re-using a single version of each function. 94 110 95 111 \subsubsection{Type Assertions} … … 117 133 118 134 This version of !twice! works for any type !S! that has an addition operator defined for it, and it could be used to satisfy the type assertion on !four_times!. 119 \CFACC{} accomplishes this by creating a wrapper function calling !twice //(2)! with !S! bound to !double!, then providing this wrapper function to !four_times!\footnote{\lstinline{twice // (2)} could also have had a type parameter named \lstinline{T}; \CFA{} specifies renaming of the type parameters, which would avoid the name conflict with the type variable \lstinline{T} of \lstinline{four_times}}.120 121 Finding appropriate functions to satisfy type assertions is essentially a recursive case of expression resolution, as it takes a name (that of the type assertion) and attempts to match it to a suitable declaration \emph{in the current scope}.122 If a polymorphic function can be used to satisfy one of its own type assertions, this recursion may not terminate, as it is possible that that function is examined as a candidate for its own typeassertion unboundedly repeatedly.135 \CFACC{} accomplishes this by creating a wrapper function calling !twice//(2)! with !S! bound to !double!, then providing this wrapper function to !four_times!\footnote{\lstinline{twice // (2)} could also have had a type parameter named \lstinline{T}; \CFA{} specifies renaming of the type parameters, which would avoid the name conflict with the type variable \lstinline{T} of \lstinline{four_times}}. 136 137 Finding appropriate functions to satisfy type assertions is essentially a recursive case of expression resolution, as it takes a name (that of the type assertion) and attempts to match it to a suitable declaration in the current scope. 138 If a polymorphic function can be used to satisfy one of its own type assertions, this recursion may not terminate, as it is possible that that function is examined as a candidate for its own assertion unboundedly repeatedly. 123 139 To avoid such infinite loops, \CFACC{} imposes a fixed limit on the possible depth of recursion, similar to that employed by most \CC{} compilers for template expansion; this restriction means that there are some semantically well-typed expressions that cannot be resolved by \CFACC{}. 124 \TODO{Update this with final state} One contribution made in the course of this thesis was modifying \CFACC{} to use the more flexible expression resolution algorithm for assertion matching, rather than the previous simplerapproach of unification on the types of the functions.140 \TODO{Update this with final state} One contribution made in the course of this thesis was modifying \CFACC{} to use the more flexible expression resolution algorithm for assertion matching, rather than the simpler but limited previous approach of unification on the types of the functions. 125 141 126 142 \subsubsection{Deleted Declarations} … … 175 191 \begin{cfa} 176 192 trait pointer_like(`otype Ptr, otype El`) { 177 El& *?(Ptr); $\C{ Ptr can be dereferenced to El}$193 El& *?(Ptr); $\C{// Ptr can be dereferenced to El}$ 178 194 }; 179 195 180 196 struct list { 181 197 int value; 182 list* next; $\C{ may omit struct on type names}$198 list* next; $\C{// may omit struct on type names}$ 183 199 }; 184 200 … … 200 216 201 217 In addition to the multiple interpretations of an expression produced by name overloading and polymorphic functions, for backward compatibility \CFA{} must support all of the implicit conversions present in C, producing further candidate interpretations for expressions. 202 As mentioned above, C does not have an inheritance hierarchy of types, but the C standard's rules for the ``usual arithmetic conversions' '\cit{} define which of the built-in tyhpes are implicitly convertable to which other types, and the relative cost of any pair of such conversions from a single source type.203 \CFA{} adds to the usual arithmetic conversions rules defining the cost of binding a polymorphic type variable in a function call; such bindings are cheaper than any \emph{unsafe} (narrowing) conversion, \eg{} !int! to !char!, but more expensive than any \emph{safe} (widening) conversion, \eg{} !int! to !double!.218 As mentioned above, C does not have an inheritance hierarchy of types, but the C standard's rules for the ``usual arithmetic conversions'\cit{} define which of the built-in types are implicitly convertible to which other types, and the relative cost of any pair of such conversions from a single source type. 219 \CFA{} adds rules to the usual arithmetic conversions defining the cost of binding a polymorphic type variable in a function call; such bindings are cheaper than any \emph{unsafe} (narrowing) conversion, \eg{} !int! to !char!, but more expensive than any \emph{safe} (widening) conversion, \eg{} !int! to !double!. 204 220 One contribution of this thesis, discussed in Section \TODO{add to resolution chapter}, is a number of refinements to this cost model to more efficiently resolve polymorphic function calls. 205 221 … … 208 224 Note that which subexpression interpretation is minimal-cost may require contextual information to disambiguate. 209 225 For instance, in the example in Section~\ref{overloading-sec}, !max(max, -max)! cannot be unambiguously resolved, but !int m = max(max, -max)! has a single minimal-cost resolution. 210 While the interpretation !int m = (int)max((double)max, -(double)max)! is also a valid interpretation, it is not minimal-cost due to the unsafe cast from the !double! result of !max! to the!int!\footnote{The two \lstinline{double} casts function as type ascriptions selecting \lstinline{double max} rather than casts from \lstinline{int max} to \lstinline{double}, and as such are zero-cost.}.211 These contextual effects make the expression resolution problem for \CFA{} both theoretically and practically difficult, but the observation driving the work in Chapter~\ref{resolution-chap} is that of the many top-level expressions in a given program, most will likely be straightforward and idiomatic so that programmers writing and maintaining the code can easily understand them; it follows that effective heuristics for common cases can bring down compiler runtime enough that a small proportion of harder-to-resolve expressions should not increase compiler runtime or memory usage inordinately.226 While the interpretation !int m = (int)max((double)max, -(double)max)! is also a valid interpretation, it is not minimal-cost due to the unsafe cast from the !double! result of !max! to !int!\footnote{The two \lstinline{double} casts function as type ascriptions selecting \lstinline{double max} rather than casts from \lstinline{int max} to \lstinline{double}, and as such are zero-cost.}. 227 These contextual effects make the expression resolution problem for \CFA{} both theoretically and practically difficult, but the observation driving the work in Chapter~\ref{resolution-chap} is that of the many top-level expressions in a given program, most are straightforward and idiomatic so that programmers writing and maintaining the code can easily understand them; it follows that effective heuristics for common cases can bring down compiler runtime enough that a small proportion of harder-to-resolve expressions does not inordinately increase overall compiler runtime or memory usage. 212 228 213 229 \subsection{Type Features} \label{type-features-sec} 214 230 231 The name overloading and polymorphism features of \CFA{} have the greatest effect on language design and compiler runtime, but there are a number of other features in the type system which have a smaller effect but are useful for code examples. 232 These features are described here. 233 215 234 \subsubsection{Reference Types} 216 235 217 % TODO mention contribution on reference rebind 218 219 \subsubsection{Lifetime Management} 220 221 \subsubsection{0 and 1 Literals} 236 One of the key ergonomic improvements in \CFA{} is reference types, designed and implemented by Robert Schluntz\cite{Schluntz17}. 237 Given some type !T!, a !T&! (``reference to !T!'') is essentially an automatically dereferenced pointer. 238 These types allow seamless pass-by-reference for function parameters, without the extraneous dereferencing syntax present in C; they also allow easy easy aliasing of nested values with a similarly convenient syntax. 239 A particular improvement is removing syntactic special cases for operators which take or return mutable values; for example, the use !a += b! of a compound assignment operator now matches its signature, !int& ?+=?(int&, int)!, as opposed to the previous syntactic special cases to automatically take the address of the first argument to !+=! and to mark its return value as mutable. 240 241 The C standard makes heavy use of the concept of \emph{lvalue}, an expression with a memory address; its complement, \emph{rvalue} (a non-addressable expression) is not explicitly named. 242 In \CFA{}, the distinction between lvalue and rvalue can be reframed in terms of reference and non-reference types, with the benefit of being able to express the difference in user code. 243 \CFA{} references preserve the existing qualifier-dropping implicit lvalue-to-rvalue conversion from C (\eg{} a !const volatile int&! can be implicitly copied to a bare !int!) 244 To make reference types more easily usable in legacy pass-by-value code, \CFA{} also adds an implicit rvalue-to-lvalue conversion, implemented by storing the value in a fresh compiler-generated temporary variable and passing a reference to that temporary. 245 To mitigate the ``!const! hell'' problem present in \CC{}, there is also a qualifier-dropping lvalue-to-lvalue conversion, also implemented by copying into a temporary: 246 247 \begin{cfa} 248 const int magic = 42; 249 250 void inc_print( int& x ) { printf("%d\n", ++x); } 251 252 print_inc( magic ); $\C{// legal; implicitly generated code in red below:}$ 253 254 `int tmp = magic;` $\C{// to safely strip const-qualifier}$ 255 `print_inc( tmp );` $\C{// tmp is incremented, magic is unchanged}$ 256 \end{cfa} 257 258 Despite the similar syntax, \CFA{} references are significantly more flexible than \CC{} references. 259 The primary issue with \CC{} references is that it is impossible to extract the address of the reference variable rather than the address of the referred-to variable. 260 This breaks a number of the usual compositional properties of the \CC{} type system, \eg{} a reference cannot be re-bound to another variable, nor is it possible to take a pointer to, array of, or reference to a reference. 261 \CFA{} supports all of these use cases \TODO{test array} without further added syntax. 262 The key to this syntax-free feature support is an observation made by the author that the address of a reference is a lvalue. 263 In C, the address-of operator !&x! can only be applied to lvalue expressions, and always produces an immutable rvalue; \CFA{} supports reference re-binding by assignment to the address of a reference, and pointers to references by repeating the address-of operator: 264 265 \begin{cfa} 266 int x = 2, y = 3; 267 int& r = x; $\C{// r aliases x}$ 268 &r = &y; $\C{// r now aliases y}$ 269 int** p = &&r; $\C{// p points to r}$ 270 \end{cfa} 271 272 For better compatibility with C, the \CFA{} team has chosen not to differentiate function overloads based on top-level reference types, and as such their contribution to the difficulty of \CFA{} expression resolution is largely restricted to the implementation details of normalization conversions and adapters. 273 274 \subsubsection{Resource Management} 275 276 \CFA{} also supports the RAII (``Resource Acquisition is Initialization'') idiom originated by \CC{}, thanks to the object lifetime work of Robert Schluntz\cite{Schluntz17}. 277 This idiom allows a safer and more principled approach to resource management by tying acquisition of a resource to object initialization, with the corresponding resource release executed automatically at object finalization. 278 A wide variety of conceptual resources may be conveniently managed by this scheme, including heap memory, file handles, and software locks. 279 280 \CFA{}'s implementation of RAII is based on special constructor and destructor operators, available via the !x{ ... }! constructor syntax and !^x{ ... }! destructor syntax. 281 Each type has an overridable compiler-generated zero-argument constructor, copy constructor, assignment operator, and destructor, as well as a field-wise constructor for each appropriate prefix of the member fields of !struct! types. 282 For !struct! types the default versions of these operators call their equivalents on each field of the !struct!. 283 The main implication of these object lifetime functions for expression resolution is that they are all included as implicit type assertions for !otype! type variables, with a secondary effect being an increase in code size due to the compiler-generated operators. 284 Due to these implicit type assertions, assertion resolution is pervasive in \CFA{} polymorphic functions, even those without explicit type assertions. 285 Implicitly-generated code is shown in red in the following example: 286 287 \begin{cfa} 288 struct kv { 289 int key; 290 char* value; 291 }; 292 293 `void ?{} (kv& this) {` $\C[3in]{// default constructor}$ 294 ` this.key{};` $\C[3in]{// call recursively on members}$ 295 ` this.value{}; 296 } 297 298 void ?{} (kv& this, int key) {` $\C[3in]{// partial field constructor}$ 299 ` this.key{ key }; 300 this.value{};` $\C[3in]{// default-construct missing fields}$ 301 `} 302 303 void ?{} (kv& this, int key, char* value) {` $\C[3in]{// complete field constructor}$ 304 ` this.key{ key }; 305 this.value{ value }; 306 } 307 308 void ?{} (kv& this, kv that) {` $\C[3in]{// copy constructor}$ 309 ` this.key{ that.key }; 310 this.value{ that.value }; 311 } 312 313 kv ?=? (kv& this, kv that) {` $\C[3in]{// assignment operator}$ 314 ` this.key = that.key; 315 this.value = that.value; 316 } 317 318 void ^?{} (kv& this) {` $\C[3in]{// destructor}$ 319 ` ^this.key{}; 320 ^this.value{}; 321 }` 322 323 forall(otype T `| { void ?{}(T&); void ?{}(T&, T); T ?=?(T&, T); void ^?{}(T&); }`) 324 void foo(T); 325 \end{cfa} 326 327 \subsubsection{Tuple Types} 328 329 \CFA{} adds \emph{tuple types} to C, a syntactic facility for referring to lists of values anonymously or with a single identifier. 330 An identifier may name a tuple, a function may return one, and a tuple may be implicitly \emph{destructured} into its component values. 331 The implementation of tuples in \CFACC{}'s code generation is based on the generic types introduced in Chapter~\ref{generic-chap}, with one compiler-generated generic type for each tuple arity. 332 This allows tuples to take advantage of the same runtime optimizations available to generic types, while reducing code bloat. 333 An extended presentation of the tuple features of \CFA{} can be found in \cite{Moss18}, but the following example shows the basics: 334 335 \begin{cfa} 336 [char, char] x = ['!', '?']; $\C{// (1); tuple type and expression syntax}$ 337 int x = 2; $\C{// (2)}$ 338 339 forall(otype T) 340 [T, T] swap( T a, T b ) { $\C{// (3)}$ 341 return [b, a]; $\C{// one-line swap syntax}$ 342 } 343 344 x = swap( x ); $\C{// destructure [char, char] x into two elements}$ 345 $\C{// cannot use int x, not enough arguments}$ 346 347 void swap( int, char, char ); $\C{// (4)}$ 348 349 swap( x, x ); $\C{// (4) on (2), (1)}$ 350 $\C{// not (3) on (2), (2) due to polymorphism cost}$ 351 \end{cfa} 352 353 Tuple destructuring breaks the one-to-one relationship between identifiers and values. 354 This precludes some argument-parameter matching strategies for expression resolution, as well as cheap interpretation filters based on comparing number of parameters and arguments. 355 As an example, in the call to !swap( x, x )! above, the second !x! can be resolved starting at the second or third parameter of !swap!, depending which interpretation of !x! was chosen for the first argument. -
doc/theses/aaron_moss_PhD/phd/cfa-macros.tex
r031a88a9 rec71a50 20 20 \newcommand{\LstCommentStyle}[1]{{\lst@basicstyle{\lst@commentstyle{#1}}}} 21 21 22 \newcommand{\C}[2][ 2in]{\hfill\makebox[#1][l]{\LstCommentStyle{#2}}}22 \newcommand{\C}[2][3.5in]{\hfill\makebox[#1][l]{\LstCommentStyle{#2}}} 23 23 24 24 % CFA programming language, based on ANSI C (with some gcc additions) -
doc/theses/aaron_moss_PhD/phd/generic-types.tex
r031a88a9 rec71a50 4 4 Talk about generic types. Pull from Moss~\etal\cite{Moss18}. 5 5 6 % TODO discuss layout function algorithm, application to separate compilation 7 % TODO put a static const field in for _n_fields for each generic, describe utility for separate compilation 8 6 9 % TODO mention impetus for zero_t design 7 10 8 11 % TODO mention use in tuple-type implementation 12 13 % TODO pull benchmarks from Moss et al. -
doc/theses/aaron_moss_PhD/phd/thesis.tex
r031a88a9 rec71a50 141 141 \addcontentsline{toc}{chapter}{\textbf{References}} 142 142 143 \bibliography{ aaron-thesis}143 \bibliography{pl} 144 144 % Tip 5: You can create multiple .bib files to organize your references. 145 145 % Just list them all in the \bibliogaphy command, separated by commas (no spaces). -
libcfa/configure
r031a88a9 rec71a50 1959 1959 1960 1960 1961 1961 1962 am__api_version='1.15' 1962 1963 -
src/CodeTools/module.mk
r031a88a9 rec71a50 16 16 17 17 SRC += CodeTools/DeclStats.cc \ 18 CodeTools/ResolvProtoDump.cc \ 18 19 CodeTools/TrackLoc.cc -
src/CompilationState.cc
r031a88a9 rec71a50 30 30 parsep = false, 31 31 resolvep = false, 32 resolvprotop = false, 32 33 symtabp = false, 33 34 treep = false, -
src/CompilationState.h
r031a88a9 rec71a50 31 31 parsep, 32 32 resolvep, 33 resolvprotop, 33 34 symtabp, 34 35 treep, -
src/Makefile.in
r031a88a9 rec71a50 221 221 CodeGen/FixNames.$(OBJEXT) CodeGen/FixMain.$(OBJEXT) \ 222 222 CodeGen/OperatorTable.$(OBJEXT) CodeTools/DeclStats.$(OBJEXT) \ 223 CodeTools/ResolvProtoDump.$(OBJEXT) \ 223 224 CodeTools/TrackLoc.$(OBJEXT) Concurrency/Keywords.$(OBJEXT) \ 224 225 Concurrency/Waitfor.$(OBJEXT) Common/SemanticError.$(OBJEXT) \ … … 520 521 CodeGen/FixNames.cc CodeGen/FixMain.cc \ 521 522 CodeGen/OperatorTable.cc CodeTools/DeclStats.cc \ 522 CodeTools/TrackLoc.cc Concurrency/Keywords.cc \ 523 Concurrency/Waitfor.cc Common/SemanticError.cc \ 524 Common/UniqueName.cc Common/DebugMalloc.cc Common/Assert.cc \ 525 Common/Heap.cc Common/Eval.cc ControlStruct/LabelGenerator.cc \ 523 CodeTools/ResolvProtoDump.cc CodeTools/TrackLoc.cc \ 524 Concurrency/Keywords.cc Concurrency/Waitfor.cc \ 525 Common/SemanticError.cc Common/UniqueName.cc \ 526 Common/DebugMalloc.cc Common/Assert.cc Common/Heap.cc \ 527 Common/Eval.cc ControlStruct/LabelGenerator.cc \ 526 528 ControlStruct/LabelFixer.cc ControlStruct/MLEMutator.cc \ 527 529 ControlStruct/Mutate.cc ControlStruct/ForExprMutator.cc \ … … 999 1001 CodeTools/DeclStats.$(OBJEXT): CodeTools/$(am__dirstamp) \ 1000 1002 CodeTools/$(DEPDIR)/$(am__dirstamp) 1003 CodeTools/ResolvProtoDump.$(OBJEXT): CodeTools/$(am__dirstamp) \ 1004 CodeTools/$(DEPDIR)/$(am__dirstamp) 1001 1005 CodeTools/TrackLoc.$(OBJEXT): CodeTools/$(am__dirstamp) \ 1002 1006 CodeTools/$(DEPDIR)/$(am__dirstamp) … … 1101 1105 @AMDEP_TRUE@@am__include@ @am__quote@CodeGen/$(DEPDIR)/OperatorTable.Po@am__quote@ 1102 1106 @AMDEP_TRUE@@am__include@ @am__quote@CodeTools/$(DEPDIR)/DeclStats.Po@am__quote@ 1107 @AMDEP_TRUE@@am__include@ @am__quote@CodeTools/$(DEPDIR)/ResolvProtoDump.Po@am__quote@ 1103 1108 @AMDEP_TRUE@@am__include@ @am__quote@CodeTools/$(DEPDIR)/TrackLoc.Po@am__quote@ 1104 1109 @AMDEP_TRUE@@am__include@ @am__quote@Common/$(DEPDIR)/Assert.Po@am__quote@ -
src/Parser/LinkageSpec.cc
r031a88a9 rec71a50 10 10 // Created On : Sat May 16 13:22:09 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Fri Jul 7 11:11:00 201713 // Update Count : 2 512 // Last Modified On : Thr Spt 12 15:59:00 2018 13 // Update Count : 26 14 14 // 15 15 … … 23 23 24 24 namespace LinkageSpec { 25 26 Spec linkageCheck( CodeLocation location, const string * spec ) {27 assert( spec );28 unique_ptr<const string> guard( spec ); // allocated by lexer29 if ( *spec == "\"Cforall\"" ) {30 return Cforall;31 } else if ( *spec == "\"C\"" ) {32 return C;33 } else if ( *spec == "\"BuiltinC\"" ) {34 return BuiltinC;35 } else {36 SemanticError( location, "Invalid linkage specifier " + *spec );37 } // if38 }39 25 40 26 Spec linkageUpdate( CodeLocation location, Spec old_spec, const string * cmd ) { -
src/Parser/LinkageSpec.h
r031a88a9 rec71a50 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 13:24:28 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Mon Jul 2 07:46:49201813 // Update Count : 1 611 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr Spt 13 15:59:00 2018 13 // Update Count : 17 14 14 // 15 15 … … 41 41 42 42 43 Spec linkageCheck( CodeLocation location, const std::string * );44 // Returns the Spec with the given name (limited to C, Cforall & BuiltinC)45 43 Spec linkageUpdate( CodeLocation location, Spec old_spec, const std::string * cmd ); 46 44 /* If cmd = "C" returns a Spec that is old_spec with is_mangled = false -
src/main.cc
r031a88a9 rec71a50 34 34 #include "CodeGen/Generate.h" // for generate 35 35 #include "CodeTools/DeclStats.h" // for printDeclStats 36 #include "CodeTools/ResolvProtoDump.h" // for dumpAsResolvProto 36 37 #include "CodeTools/TrackLoc.h" // for fillLocations 37 38 #include "Common/CompilerError.h" // for CompilerError … … 271 272 CodeTools::fillLocations( translationUnit ); 272 273 274 if ( resolvprotop ) { 275 CodeTools::dumpAsResolvProto( translationUnit ); 276 return 0; 277 } 278 273 279 PASS( "resolve", ResolvExpr::resolve( translationUnit ) ); 274 280 if ( exprp ) { … … 376 382 377 383 void parse_cmdline( int argc, char * argv[], const char *& filename ) { 378 enum { Ast, Bbox, Bresolver, CtorInitFix, DeclStats, Expr, ExprAlt, Grammar, LibCFA, Linemarks, Nolinemarks, Nopreamble, Parse, PreludeDir, Prototypes, Resolver, Symbol, Tree, TupleExpansion, Validate, };384 enum { Ast, Bbox, Bresolver, CtorInitFix, DeclStats, Expr, ExprAlt, Grammar, LibCFA, Linemarks, Nolinemarks, Nopreamble, Parse, PreludeDir, Prototypes, Resolver, ResolvProto, Symbol, Tree, TupleExpansion, Validate, }; 379 385 380 386 static struct option long_opts[] = { … … 395 401 { "no-prototypes", no_argument, 0, Prototypes }, 396 402 { "resolver", no_argument, 0, Resolver }, 403 { "resolv-proto", no_argument, 0, ResolvProto }, 397 404 { "symbol", no_argument, 0, Symbol }, 398 405 { "tree", no_argument, 0, Tree }, … … 407 414 bool Wsuppress = false, Werror = false; 408 415 int c; 409 while ( (c = getopt_long( argc, argv, "abBcCdefgGlLmnNpqr stTvwW:yzZD:F:", long_opts, &long_index )) != -1 ) {416 while ( (c = getopt_long( argc, argv, "abBcCdefgGlLmnNpqrRstTvwW:yzZD:F:", long_opts, &long_index )) != -1 ) { 410 417 switch ( c ) { 411 418 case Ast: … … 479 486 case 'r': // print resolver steps 480 487 resolvep = true; 488 break; 489 case 'R': // dump resolv-proto instance 490 resolvprotop = true; 481 491 break; 482 492 case Symbol: -
tools/cfa.nanorc
r031a88a9 rec71a50 2 2 ## WIP 3 3 4 syntax "cfa" "\. cfa"4 syntax "cfa" "\.(c|h)fa" 5 5 6 6 # Macros … … 9 9 # Types 10 10 color green "\<(forall|trait|(o|d|f|t)type|mutex|_Bool|volatile|virtual)\>" 11 color green "\<(float|double|bool|char|int|short|long| sizeof|enum|void|auto)\>"12 color green "\<(static|const| struct|union|typedef|extern|(un)?signed|inline)\>"11 color green "\<(float|double|bool|char|int|short|long|enum|void|auto)\>" 12 color green "\<(static|const|extern|(un)?signed|inline)\>" "\<(sizeof)\>" 13 13 color green "\<((s?size)|one|zero|((u_?)?int(8|16|32|64|ptr)))_t\>" 14 14 … … 19 19 # Control Flow Structures 20 20 color brightyellow "\<(if|else|while|do|for|switch|choose|case|default)\>" 21 color brightyellow "\<(disable|enable|waitfor|when|timeout)\>" 21 22 color brightyellow "\<(try|catch(Resume)?|finally)\>" 22 23 23 24 # Control Flow Statements 24 25 color magenta "\<(goto|return|break|continue|fallthr(u|ough)|throw(Resume)?)\>" 26 27 # Escaped Keywords, now Identifiers. 28 color white "`\w+`" 25 29 26 30 # Operator Names
Note: See TracChangeset
for help on using the changeset viewer.