Commit Graph

22474 Commits

Author SHA1 Message Date
Eli Friedman
a2c6150c13 Error recovery for the REPL. Seems to be working reasonably well. <rdar://problem/11269380>.
Swift SVN r1523
2012-04-20 01:14:39 +00:00
Eli Friedman
be602fcd05 Get rid of the implicit BraceStmt for the TranslationUnit; instead, have the TranslationUnit directly store a list of decls.
Swift SVN r1521
2012-04-20 00:17:13 +00:00
Eli Friedman
596f494f51 Add missing getLocStart() implementation for TopLevelCodeDecl.
Swift SVN r1520
2012-04-20 00:13:11 +00:00
Doug Gregor
6122a9f5e3 Introduce an overloaded subscript expression type, to cope with cases
where overloading based on the indices is insufficient to select an
overload candidate. Implement type coercion for overloaded subscript
expressions, so that the context can help push overload resolution
along.


Swift SVN r1516
2012-04-19 23:43:44 +00:00
Doug Gregor
cd43490fb3 Implement semantic analysis for subscript expressions, using overload
resolution to pick the best subscript getter/setter pair. Does not yet
allow type coercion to influence overload resolution.



Swift SVN r1515
2012-04-19 23:01:04 +00:00
Doug Gregor
cd7be4edf1 Add an AST for subscript expressions; no real type checking yet.
Swift SVN r1512
2012-04-19 22:07:42 +00:00
Eli Friedman
6a088458e8 Add a big doxygen comment for TopLevelCodeDecl.
Swift SVN r1511
2012-04-19 22:07:34 +00:00
Chris Lattner
cbc1eac438 irgen parser and sema support for for statements.
Swift SVN r1505
2012-04-19 21:43:46 +00:00
Eli Friedman
d5e7784010 Get rid of isModuleScope bit, since we don't like scattering bits across the AST; as a replacement, introduce TopLevelCodeDecl, which provides a DeclContext for all expressions and statements at the top level. <rdar://problem/11259941>.
Swift SVN r1503
2012-04-19 21:22:12 +00:00
John McCall
4c15635046 Finish type-checking for new[] expressions.
Swift SVN r1502
2012-04-19 21:05:43 +00:00
John McCall
66318f5e12 First round of type-checking for new-expressions: form
the appropriate slice type and check the bounds.  The
first bound must be a literal or a type with a
getArrayBoundValue method, which has the same recursive
nature as getLogicValue (i.e. it can return a type that
has a getArrayBoundValue that returns an integral type,
but that's it;  it's capped at one hop).  The rest
of the bounds must be empty (meaning a slice) or
constant under the same conditions as fixed-size
array types.

Swift SVN r1501
2012-04-19 21:05:37 +00:00
Doug Gregor
8ff3075ce4 Teach getter/setter functions about their corresponding subscript
declaration, so they can mangle themselves appropriately.


Swift SVN r1499
2012-04-19 20:56:22 +00:00
Doug Gregor
846aa7e162 Diagnose attempts to declare subscript operations outside of a type context.
Swift SVN r1497
2012-04-19 20:41:42 +00:00
Doug Gregor
06881faea2 Introduce an AST node for subscript declarations, and verify that the bodies of the getter and setter are being type-checked.
Swift SVN r1496
2012-04-19 20:29:48 +00:00
Chris Lattner
df74bc03c0 lang ref and parser support for for statements. AST and sema next.
Swift SVN r1493
2012-04-19 18:25:48 +00:00
Ted Kremenek
e161141731 Per Doug's feedback, refine diagnostics when we cannot find a unary or
binary operator for a given set of argument types.  When the argument types
are not dependent or error types, include them in a short single error
diagnostic, and not separated in a separate note.

Swift SVN r1488
2012-04-19 04:31:21 +00:00
Eli Friedman
acc17d69aa Initial implementation of the "print" part of the REPL.
Swift SVN r1484
2012-04-19 01:13:37 +00:00
Doug Gregor
6897b6ab44 Add support for parsing a subscripting declaration, e.g.,
subscript (i : Int) -> Double {
    get { /* get ith element of something */ }
    set { /* set ith element of something to value*/ }
  }



Swift SVN r1476
2012-04-18 21:43:54 +00:00
Doug Gregor
c99e526ae8 Refactor var-get-set grammar to a more general get-set grammar, to
prepare for re-use in subscripting. No functionality change (yet).



Swift SVN r1475
2012-04-18 20:54:58 +00:00
Doug Gregor
b7b8f171b3 Treat a function application A(b) as a coercion of the expression 'b'
to the type named by A (when A is in fact a direct reference to a
type). If that coercion would fail, then fall back to invoking a
constructor. Fixes <rdar://problem/11272190>.



Swift SVN r1472
2012-04-18 17:04:34 +00:00
John McCall
71157c65d5 Add parsing support, but no type-checking or IR-generation,
for new expressions.

Swift SVN r1466
2012-04-18 08:09:18 +00:00
John McCall
6133630544 When type-checking a slice type, "desugar" it to a type that is
generic over the type of the base.  By "generic" I mean that it's
looked up by prepending the word "Slice" to the name of the base
type.

Swift SVN r1464
2012-04-18 08:09:10 +00:00
Eli Friedman
ecb0f2bba4 Add a little bit of missing error-checking for libraries.
Swift SVN r1455
2012-04-18 01:50:24 +00:00
Ted Kremenek
9cc9c3358f Enhance diagnostic for failed overload resolution with operator calls by
printing the operator, adjusting the diagnostic to point to the operator
and not the second operand, properly highlighting the ranges of the operands,
and printing out the types of the operands when appropriate.

Printing out the types is very useful when trying to understand the mismatch.

Note: I only partially know what I am doing at this stage.  This feels a bit
kludgy, as the "cast<>"s reek of not enough implicit invariants being documented
in the ASTs themselves.

Fixes <rdar://problem/11266762>

Swift SVN r1449
2012-04-17 22:31:09 +00:00
Doug Gregor
3243108518 Introduce an new expression, MemberRefExpr, that refers to a
member of an object. This expression kind is currently used to refer
to properties within an object, but will eventually be extended to
refer to fields as well (once we make StructDecl real).


Swift SVN r1445
2012-04-17 00:35:06 +00:00
Eli Friedman
6a001efbbb Make "..", "*^.^*", etc. into overloadable operators. Make 1..10 construct a Range.
This has the side-effect that you can't explicitly refer to an operator* with "swift.*", etc., but per discussion with Doug, that's probably okay.



Swift SVN r1443
2012-04-17 00:21:38 +00:00
Eli Friedman
37de44a35d Implement changes to parsing/sema/etc so that we can implement a REPL and the main module parses the same way as a REPL.
Next step: implement an actual REPL.



Swift SVN r1441
2012-04-16 23:52:01 +00:00
Doug Gregor
83c1611852 VarDecls, even property VarDecls, are always lvalues. Make it so.
Swift SVN r1438
2012-04-16 23:18:48 +00:00
Doug Gregor
970d3d2564 A property is only an lvalue when there is a setter.
Swift SVN r1437
2012-04-16 17:57:00 +00:00
Chris Lattner
4f4c8b1455 add initial support for Builtin cast instructions, patch #1/2.
Swift SVN r1433
2012-04-14 00:56:35 +00:00
Doug Gregor
4fc32fd9b4 For a function that is either a getter or setter for a variable,
provide a mapping back to that variable. Teach the mangler to provide
a special mangling for such functions (__getVarName,
__setVarName). The mangling will undoubtedly change later, but the
point is that it will need to match the functions generated for
a resilient variable.


Swift SVN r1432
2012-04-14 00:11:04 +00:00
Chris Lattner
868eccff76 implement a new Builtin.gep operation which maps to the LLVM Getelementptr instruction,
used for pointer offseting.  We can figure out inbounds later.  This is to be used by
UnsafePointerInt


Swift SVN r1429
2012-04-13 23:10:42 +00:00
Doug Gregor
0fdb4d00fc When we parse a 'var' declaration, we add all of the VarDecls and the
PatternBindingDecl to the DeclContext. Do the same for the get/set
functions for a property, so we don't need to perform 'deep' setting
of the DeclContext. This is simpler, although it makes pretty-printing
the AST a bit more difficult.



Swift SVN r1428
2012-04-13 22:22:17 +00:00
Chris Lattner
c7c61ecc01 remove the unary neg/not builtins. They're not needed and don't match LLVM IR.
Swift SVN r1425
2012-04-13 21:59:56 +00:00
Doug Gregor
bbd5dfcfdf Allow variables with a getter or setter to be declared in a
struct/oneof/class extension, making them instance methods. Normal
variables are still not allowed in these contexts, however.

The fact that we set DeclContexts late causes some consternation here,
because it's not clear just how far we need to recurse in
DeclContext. I've done enough to make properties work, but I'm still
rather uneasy about the current state of affairs.


Swift SVN r1423
2012-04-13 21:45:27 +00:00
Eli Friedman
9bf8dcf0f1 Delete some dead code.
Swift SVN r1412
2012-04-13 01:05:12 +00:00
Doug Gregor
7823cd48eb Wire properties into the AST for VarDecl, and add dumping support. No
tests until we start type-checking something.


Swift SVN r1410
2012-04-13 00:27:22 +00:00
Doug Gregor
6ce55acfc4 Parse getters and setters for variables.
Swift SVN r1408
2012-04-12 23:59:53 +00:00
Chris Lattner
2599a55231 add ~ as an operator.
Swift SVN r1407
2012-04-12 23:24:11 +00:00
Chris Lattner
c92cf52358 since we allow utf8 source files, start validating utf8 characters in string literals
and test that they continue to work.  Part of rdar://11220029


Swift SVN r1401
2012-04-12 21:47:12 +00:00
Doug Gregor
ba56d2c0b1 Implement support for lookup of members of the current
oneof/struct/protocol within a static method. The lookup is performed
on the metatype (as one would get when using qualified syntax
Type.member). Add tests to verify that this provides proper
overloading behavior.

As a drive-by, actually set the type of the implicit 'this' variable
during name binding for a non-static method.



Swift SVN r1394
2012-04-11 18:22:53 +00:00
Doug Gregor
548c2e50c2 Fix the beginning source ranges for dot expressions where the object
argument is the implicit 'this' argument. Add a number of overloading
tests for overloaded member access, which naturally exercises these
source locations.


Swift SVN r1390
2012-04-11 16:17:22 +00:00
Doug Gregor
7e9b7da0ca Remove the general diagnostic-suppression mechanism. Instead,
introduce a simple suppression mechanism into the type-coercion code,
which is the only place we should need it.


Swift SVN r1388
2012-04-11 14:31:40 +00:00
Eli Friedman
361481835c Introduce a notion of module scope declarations; use it where appropriate instead of checking for a local declcontext.
Swift SVN r1380
2012-04-11 02:52:40 +00:00
Chris Lattner
cedf889440 ASTWalker has virtual methods, its dtor should be virtual as well.
Swift SVN r1375
2012-04-10 23:57:20 +00:00
Chris Lattner
cac963c6d6 reject unicode encodings for surrogate pairs, and reject \x80 and above.
This completes unicode validation for \x, \u, and \U.


Swift SVN r1369
2012-04-10 23:26:46 +00:00
Doug Gregor
a3c34c5dbd Introduce an AST node (OverloadedMemberRefExpr) that represents dot
syntax when name lookup finds multiple candidates. Overload resolution
is then used to select the best candidate and map the overloaded
member reference expression down to DotSyntaxCallExpr or
DotSyntaxBaseIgnoredExpr, as appropriate.

This implements part of <rdar://problem/11071641>, so that simple
overload resolution works, but there is still a bit of cleanup to do.



Swift SVN r1366
2012-04-10 22:52:41 +00:00
Chris Lattner
4ff016d0a8 start diagnosing invalid UTF encodings, more to follow.
Swift SVN r1365
2012-04-10 22:02:57 +00:00
Chris Lattner
1bb2443498 document and lex the basic and unicode escape characters.
IRGen after lunch.



Swift SVN r1361
2012-04-10 19:30:18 +00:00
John McCall
0cd849b19c Complete the pattern-matching IR emission logic,
at least for exhaustive patterns.

Swift SVN r1359
2012-04-10 08:28:31 +00:00