Chris Lattner
4814530f79
rework validateType to be more conventional: not updating types in place.
...
Swift SVN r516
2011-08-12 05:54:44 +00:00
John McCall
9f2ca5e4cc
Remove juxtaposition handling from the type-checker and put it
...
in the parser. Implement the grammar which permits this.
Enforce that binary operators have to, well, operators.
Swift SVN r515
2011-08-12 05:49:30 +00:00
Chris Lattner
1dc200c973
introduce an official ErrorType. This is to be used when a type is incorrectly
...
constructed. When put on a decl, this should cause all uses of the decl to
collapse away into badness during type checking.
Swift SVN r514
2011-08-12 05:42:20 +00:00
Chris Lattner
10f5c2fc66
remove the UnresolvedType, representing it with a null Type() instead. There is no need to
...
have two different ways to represent the same thing. This has the pleasant bonus that stuff
crashes when you do things with unresolved types.
Swift SVN r513
2011-08-12 05:19:52 +00:00
Chris Lattner
452308129e
fix a case where Sema installed a non-null type. This isn't needed, we like null types
...
coming out of the parser.
Swift SVN r512
2011-08-12 04:57:50 +00:00
Chris Lattner
9e6817b3cd
implement lexer, parser, and dox support for while loops, everything is hooked up now.
...
Swift SVN r502
2011-08-11 20:47:33 +00:00
Chris Lattner
ce6f6a83cd
add AST support for WhileStmt. This isn't important, but is easy to add.
...
Swift SVN r501
2011-08-11 20:33:34 +00:00
Chris Lattner
433d6de807
implement AST and parser support for 'return'. We're still not doing a conversion
...
to a return type yet though. We happily diagnose thigns like this as an error:
func foo() -> int {
return 4 5
}
Swift SVN r493
2011-08-03 23:19:24 +00:00
Chris Lattner
ba773ca617
make unbound sequences of expressions that are not in a BraceStmt be an error.
...
This makes (0 1) an error, since 0 is dead.
Swift SVN r489
2011-08-03 22:18:14 +00:00
Chris Lattner
6e872fe562
when type checking of a sequence expr has completed, if that sequence expr is in
...
a bracestmt context, inline the sequence into the brace. No particular
behavior change other than an adapted AST.
Swift SVN r488
2011-08-03 21:58:32 +00:00
Chris Lattner
c86e786ab5
switch langref to new func syntax, switch implementation to use FuncExpr instead of LambdaExpr.
...
Swift SVN r487
2011-08-03 00:32:15 +00:00
Chris Lattner
0265e3cbd1
make 'else if' a special case, disallowing things like "else ;".
...
Swift SVN r482
2011-08-02 21:31:31 +00:00
Chris Lattner
350b89e6e4
Represent assignments as their own AssignStmt, preserving the model we had
...
before, but removing the hack where we'd represent them as a binary operator
with a null operator function. We still have no clear semantics for what
is valid or not.
Swift SVN r478
2011-08-01 17:45:21 +00:00
Chris Lattner
ebc33d306f
add AST support for semicolon statements and clean up the parser. While noone cares, it is trivial
...
to support and good for completeness.
Swift SVN r475
2011-07-31 21:09:23 +00:00
Chris Lattner
fb8621f53a
introduce DeclVisitor, ExprVisitor, and StmtVisitor template typedefs.
...
Swift SVN r472
2011-07-31 20:46:12 +00:00
Chris Lattner
d5523fa257
rename ExprStmtVisitor to ASTVisitor.
...
Swift SVN r471
2011-07-31 20:41:11 +00:00
Chris Lattner
93ac2b3cb9
rename FuncExpr to LambdaExpr.
...
Swift SVN r468
2011-07-31 20:15:56 +00:00
Chris Lattner
a8e2788184
implement semantic analysis for FuncExpr and have the parser lower func decls
...
to func exprs. All the tests pass again. Now we have a strict equality
between:
func foo(a : int) -> int { a+1 }
and
var foo = func(a : int) -> int { a+1 }
except we don't support the later syntax yet. We also really need return, though
we're getting closer to being able to usefully support it.
Swift SVN r466
2011-07-31 19:33:27 +00:00
Chris Lattner
d232974df1
introduce a new FuncExpr AST node. No clients yet though.
...
Swift SVN r465
2011-07-31 18:10:24 +00:00
Chris Lattner
f7c873507b
rename ExprVisitor to ExprStmtVisitor, since it can visit either kind.
...
Swift SVN r464
2011-07-31 17:46:16 +00:00
Chris Lattner
8148b8cd1d
fix the expr side of the visitor to follow the naming convention.
...
Swift SVN r463
2011-07-31 17:43:47 +00:00
Chris Lattner
63ce0be641
make the big switch: {} are now statements, not expressions. This removes some
...
annoying things from the grammar (like expr-non-brace), and makes it so that
the body/else of an if is just a statement.
This patch has a fairly serious caveat that we just drop function bodies on the
floor now, since we have no "stmtexpr" sort of thing to represent the syntactic
sugar that is func. We'll fix that soon.
Swift SVN r462
2011-07-31 17:39:13 +00:00
Chris Lattner
72260c7cad
add name binding support for statements at top-level.
...
Swift SVN r461
2011-07-31 17:36:26 +00:00
Chris Lattner
30b878c5d6
add support for walking statements properly, dissolving some hacks.
...
Swift SVN r459
2011-07-31 07:40:13 +00:00
Chris Lattner
382f33ec74
introduce statements, make if (and ;) a statement. This includes a
...
few horrible hacks, but is the right direction to go.
Swift SVN r457
2011-07-31 06:52:11 +00:00
Chris Lattner
0fc77abf5c
Per discussion on swift-dev, unify 'meth' and 'func' syntax into just 'func' syntax
...
where you can optionally declare a receiver type. This is cleaner both conceptually
and in implementation, and eliminates drug references. :)
Swift SVN r444
2011-07-24 20:11:35 +00:00
Chris Lattner
3a059605e7
convert TypeKind and WalkOrder to scoped enums
...
Swift SVN r441
2011-07-24 19:24:55 +00:00
Chris Lattner
e122365134
switch ExprKind to be a scoped enum. This required renaming
...
IntegerLiteral to IntegerLiteralExpr, which is good for consistency anyway.
Swift SVN r440
2011-07-24 18:49:23 +00:00
Chris Lattner
123c200953
switch more stuff to use enum class, C++'0x needs a :foo operator :)
...
Swift SVN r438
2011-07-24 18:28:52 +00:00
Chris Lattner
259fab4238
adopt a few more '0x features.
...
Swift SVN r437
2011-07-24 00:45:51 +00:00
Chris Lattner
096a3e16bc
switch to range-based for loops where possible. I'm actually surprised how many
...
places are blocked by needing an index exposed for other purposes. Not having a
MutableArrayRef doesn't help either.
Swift SVN r434
2011-07-23 20:47:13 +00:00
Chris Lattner
4f29cc0e8c
convert TheUnresolvedType/TheDependentType and the empty tuple type
...
to be accessors on their respective classes, for consistency.
Swift SVN r429
2011-07-19 06:41:42 +00:00
Chris Lattner
c9ec409046
Context.getNewOneOfType -> OneOfType::getNew
...
Swift SVN r428
2011-07-19 06:28:36 +00:00
Chris Lattner
a39857ab85
migrate ASTContext::getTupleType -> TupleType::get
...
Swift SVN r427
2011-07-19 06:26:55 +00:00
Chris Lattner
649a577059
move from ASTContext::getArrayType -> ArrayType::get
...
Swift SVN r426
2011-07-19 06:22:04 +00:00
Chris Lattner
e106d336cb
while I'm in a cleanup mood, move the factory functions from
...
types off of ASTContext onto the types themselves. This
never made sense for clang, and makes the same amount of sense
for swift. Start with function types.
Swift SVN r425
2011-07-19 06:17:26 +00:00
Chris Lattner
3af81cccbe
raw_ostream and NullablePtr. While there are more types that
...
could be handled in similar ways, this gets the most of them.
Swift SVN r424
2011-07-19 06:09:31 +00:00
Chris Lattner
10017bef15
ArrayRef and SmallVector[Impl]
...
Swift SVN r423
2011-07-19 06:03:26 +00:00
Chris Lattner
7275ca527a
pull in StringRef and Twine.
...
Swift SVN r422
2011-07-19 06:00:20 +00:00
Chris Lattner
19dbcaa171
pull the casting operators into LLVM.h
...
Swift SVN r421
2011-07-19 05:57:01 +00:00
Chris Lattner
e647b29339
stop the llvm-namespace-qualification-insanity by caving in and
...
adding a new swift/AST/LLVM.h file which forward declares and imports
common llvm classes, starting with SMLoc.
Swift SVN r420
2011-07-19 05:49:43 +00:00
Chris Lattner
d6cf48a22d
add a "using llvm::SMLoc" to simplify some code,
...
move "-> ()" inference into Sema. The boundary
between Parser and Sema* is nebulous at best.
Swift SVN r419
2011-07-19 05:39:06 +00:00
Chris Lattner
434f369023
fix a bunch of failing testcases. I didn't notice this because
...
lit is not interacting with cmake properly.
Swift SVN r418
2011-07-19 05:38:22 +00:00
Chris Lattner
79b312cfe3
reduce duplication in type checking. Vars/func/method's are all
...
conceptually the same, vardecl just requires checking the name
specifier.
Swift SVN r417
2011-07-19 05:29:37 +00:00
Chris Lattner
9e8c82435a
implement AST and sema support for methods. The example method in the
...
testcase now AST's to:
(methdecl 'print2' type='(this : rect) -> (os : ostream) -> ()'
(closure_expr type='(this : rect) -> (os : ostream) -> ()'
(closure_expr type='(os : ostream) -> ()'
(brace_expr type='()'
(apply_expr type='int'
(declref_expr type='(r : rect) -> int' decl=area)
(tuple_expr type='(r : rect)'
(declref_expr type='rect' decl=this)))))))
which seems right. Some cleanups are pending.
Swift SVN r416
2011-07-19 05:26:51 +00:00
Chris Lattner
96103cab95
use the new llvm::TinyPtrVector class, which was derived from this code.
...
Swift SVN r408
2011-07-18 02:13:37 +00:00
Doug Gregor
50323196b3
Teach module lookup to look first in the directory where the importing
...
module is located, and then fall back to the current directory if
nothing was found there. This allows us to run the Swift regression
tests from a directory other than "test" (e.g., in the build
directory, as is currently needed by CMake).
The implementation itself is a temporary hack that will eventually
need to be replaced with a proper virtual file system + module
manager.
Swift SVN r405
2011-07-14 19:16:45 +00:00
Doug Gregor
86ab76d624
Introduce a CMake build system for Swift.
...
This CMake-based build system is based on the one in Clang, simplified
and tweaked slightly to better support building a smaller Xcode
project that links against an existing LLVM (rather than importing all
of LLVM into this project).
Swift SVN r403
2011-07-14 17:58:33 +00:00
Chris Lattner
f72055598a
improve diagnostic from:
...
error: invalid conversion from type 'int' to '__builtin_int1_type'
to:
error: expression of type 'int' is not legal in a condition
Swift SVN r398
2011-06-05 04:09:56 +00:00
Chris Lattner
464d255a2d
Implement AST building and type checking for if expressions, these now work per-documentation, though the diagnostics are awful.
...
Swift SVN r397
2011-06-05 04:02:24 +00:00