Commit Graph

3980 Commits

Author SHA1 Message Date
Joe Pamer
f83f94d9d8 Support build and target configurations
These changes add support for build and target configurations in the compiler.
Build and target configurations, combined with the use of #if/#else/#endif allow
for conditional compilation within declaration and statement contexts.

Build configurations can be passed into the compiler via the new '-D' flag, or
set within the LangOptions class. Target configurations are implicit, and
currently only "os" and "arch" are supported.

Swift SVN r14305
2014-02-24 18:16:48 +00:00
Dmitri Hrybenko
06be7781f8 Fix code completion for 'inout' by completing '&' in the function argument
Partially addresses rdar://15999689


Swift SVN r14299
2014-02-24 12:48:56 +00:00
Argyrios Kyrtzidis
bb4b57c053 [IDE] Introduce ide::printDeclUSR() which uses the mangler to provide a USR for a swift symbol.
Swift SVN r14279
2014-02-23 06:54:48 +00:00
John McCall
10ac15ed0d Lex $notAllDigits as an identifier and diagnose it in the lexer
outside of debugger-support mode.  Rip out the existing special-case
code when parsing expr-identifier.

This means that the Lexer needs a LangOptions.  Doug and I
talked about just adding that as a field of SourceMgr, but
decided that it was worth it to preserve the possibility of
parsing different dialects in different source files.

By design, the lexer doesn't tokenize fundamentally differently
in different language modes; it might decide something is invalid,
or it might (eventually) use a different token kind for the
same consumed text, but we don't want it deciding to consume more or
less of the stream per token.

Note that SIL mode does make that kind of difference, and that
arguably means that various APIs for tokenizing need to take a
"is SIL mode" flag, but we're getting away with it because we
just don't really care about fidelity of SIL source files.

rdar://14899000

Swift SVN r13896
2014-02-14 01:54:17 +00:00
Chris Lattner
9ee7d99a46 switch a few things off of argument patterns, onto body patterns.
Swift SVN r13891
2014-02-14 01:33:14 +00:00
Jordan Rose
cbcf17f9bd Stop leaking memory from Module and FileUnit.
Also, disallow creating Modules and FileUnits on the stack. They must always
live as long as the ASTContext.

<rdar://problem/15596964>

Swift SVN r13671
2014-02-08 02:12:57 +00:00
Dmitri Hrybenko
07d3fc3505 Coding style fix
Swift SVN r13574
2014-02-06 09:27:56 +00:00
Chris Lattner
827acad533 Various inout improvements:
- purge @inout from comments in the compiler except for places talking about
   the SIL argument convention.
 - change diagnostics to not refer to @inout
 - Change the astprinter to print InoutType without the @, so it doesn't show
   up in diagnostics or in closure argument types in code completion.
 - Implement type parsing support for the new inout syntax (before we just 
   handled patterns).
 - Switch the last couple of uses in the stdlib (in types) to inout.
 - Various testcase updates (more to come).



Swift SVN r13564
2014-02-06 06:22:27 +00:00
Chris Lattner
79cbda7f88 convert a heck of a lot of tests to use the new inout syntax (yay for regex's),
and implement code completion and ast-printer support for the new syntax.



Swift SVN r13562
2014-02-06 05:35:36 +00:00
Doug Gregor
04475c6a85 Use @unchecked optionals for member references into AnyObject/AnyClass.
This eliminates the need for a number of !'s when dealing with
Objective-C APIs. Now with actual executable behavior!


Swift SVN r13483
2014-02-05 07:58:18 +00:00
Dmitri Hrybenko
b2938db915 Code completion: simplify code using the new getInnermostMethodContext() function
Swift SVN r13430
2014-02-04 11:36:19 +00:00
Argyrios Kyrtzidis
d073e3026c [IDE] Add a convenient overload for ide::isSourceInputComplete that accepts a StringRef.
Swift SVN r13318
2014-02-02 06:49:59 +00:00
Argyrios Kyrtzidis
8758451a43 [Parser/IDE] Introduce ide::isSourceInputComplete() which returns true if the input source is fully formed,
or false if, for example, a closing brace is missing.

This is useful for the REPL.
rdar://15948039

Swift SVN r13313
2014-02-02 03:14:33 +00:00
Argyrios Kyrtzidis
48023490de [AST] Move AccessorKind enum to top-level so it can be forward declared.
No functionality change.

Swift SVN r13299
2014-02-01 08:50:15 +00:00
Argyrios Kyrtzidis
55c02e0cf0 [IDE] Handle observing accessors for syntax and semantic annotations.
Swift SVN r13295
2014-02-01 06:22:21 +00:00
Argyrios Kyrtzidis
1d6fdcbe97 [IDE] Code-completion: References to types should not mention ".metatype"
rdar://15805275

Swift SVN r13062
2014-01-28 19:38:42 +00:00
Argyrios Kyrtzidis
6e1d1c0b10 [IDE] Adding ".metatype" is not a valid completion in an expression context but it is valid in
a type context.

Swift SVN r13061
2014-01-28 19:38:40 +00:00
Argyrios Kyrtzidis
dc258df962 [IDE] Make sure the constructor reference in a [super/self].init is reported by the SourceEntityWalker.
Swift SVN r12957
2014-01-26 05:13:50 +00:00
Doug Gregor
d52cec4b20 Eliminate a pile of literal identifiers for self, init, destructor, etc.
... because I can't stomach adding another one of these.


Swift SVN r12687
2014-01-22 01:09:49 +00:00
Argyrios Kyrtzidis
84e20a0620 [AST] Break down IdentTypeRepr to different subtypes.
This makes memory allocation for it more efficient and it's more convenient to handle.

Swift SVN r12541
2014-01-18 20:19:09 +00:00
John McCall
1ccf23487e Remove unnecessary ASTContext& argument from getOptionalObjectType().
Swift SVN r12344
2014-01-15 21:00:58 +00:00
Argyrios Kyrtzidis
b49950fa80 [IDE] Enhance attribute annotation by splitting the related syntax nodes to:
AttributeId: Any occurence of '@<attribute-name>' anywhere.
AttributeBuiltin: A "resolved/active" attribute. Mis-applied attributes will be AttributeId.

This provides more options for coloring attributes in a way that one can easily spot
attributes that are not applied correctly.

Swift SVN r12194
2014-01-11 02:17:09 +00:00
Argyrios Kyrtzidis
952ac3cd3d [IDE] ModelASTWalker already has a SourceManager object to use.
Swift SVN r12184
2014-01-11 01:09:33 +00:00
Argyrios Kyrtzidis
a17b8a2d15 [IDE] SyntaxModelContext is intended to be used on a SourceFile not a module.
Swift SVN r12183
2014-01-11 01:09:32 +00:00
Sonny Falk
d1f0d9f7c6 [IDE] Give @attributes their own dedicated SyntaxNodeKind::Attribute.
Swift SVN r12138
2014-01-10 22:23:42 +00:00
Sonny Falk
e55342165f [IDE] Teach the syntax model about known @attributes, and treat them as keyword token nodes for syntax coloring.
This addresses <rdar://problem/15599911>.

Swift SVN r12109
2014-01-10 00:46:15 +00:00
Argyrios Kyrtzidis
cb6a006f19 [IDE] Fix crash during code-completion with invalid code.
Swift SVN r12093
2014-01-09 09:47:23 +00:00
Sonny Falk
2c3e2d469f [IDE] Add TypeRange to SyntaxStructureNode, and vend the type name for instance variables.
Swift SVN r12028
2014-01-08 01:33:33 +00:00
Chris Lattner
d2a33362dc Fix getRValueType() to not strip off @inout types, only @lvalue types.
- Introduce a new TypeBase::getInOutObjectType() that strips off @inout types
- Switch stuff that is calling getRValueType() to call getInOutObjectType()
  when they are stripping @inout, not @lvalue (this is primarily around
  stuff working with self)
- Update testcases, some diagnostics improve around & handling.

This fixes rdar://15708430 and rdar://15729093.



Swift SVN r11794
2014-01-01 18:56:44 +00:00
Sonny Falk
7eb5b62154 [IDE] Skip out of order non-token nodes.
This fixes <rdar://problem/15535058> and a crash in Xcode <rdar://problem/15642501>.

Swift SVN r11609
2013-12-23 20:52:26 +00:00
Dmitri Hrybenko
537e1259f8 Code completion: annotate associated types with concrete style while completing expressions
Swift SVN r11537
2013-12-21 04:11:22 +00:00
Dmitri Hrybenko
8c76b4c0b4 Code completion: when reporting associated type aliases, try to annotate them with concrete types
Swift SVN r11536
2013-12-21 02:59:42 +00:00
Chris Lattner
b29748a6be remove the ASTContext argument from Type::transform,
(various) FunctionType::get's, ArrayType::get,
ArraySliceType::get, OptionalType::get, and a few
other places.

There is more to be done here, but this is all I plan to do
for now.


Swift SVN r11497
2013-12-20 02:23:21 +00:00
Joe Groff
017440165e Fix the weird capitalization of MetaTypeType.
Swift SVN r11475
2013-12-19 18:43:08 +00:00
John McCall
7173cec9db Thread contextual information about parsing the top-level
through various bits and use that to globally discriminate.

Swift SVN r11379
2013-12-17 04:31:40 +00:00
John McCall
dfe138fdc4 Build and register the PDB earlier, removing the need for a
special case in code-completion.

Swift SVN r11179
2013-12-12 03:36:30 +00:00
John McCall
342a8b35db Parse default-argument expressions in an initializer context.
Swift SVN r11178
2013-12-12 03:36:27 +00:00
Dmitri Hrybenko
6a776132d2 Code completion: don't substitute generic parameters if the actual parameters
are just canonical generic types

Fixes rdar://15588242 using a different approach than suggested in the radar.


Swift SVN r10904
2013-12-06 02:15:23 +00:00
Jordan Rose
417b5d3982 Merge TranslationUnit into Module, and eliminate the term "translation unit".
This completes the FileUnit refactoring. A module consists of multiple
FileUnits, which provide decls from various file-like sources. I say
"file-like" because the Builtin module is implemented with a single
BuiltinUnit, and imported Clang modules are just a single FileUnit source
within a module.

Most modules, therefore, contain a single file unit; only the main module
will contain multiple source files (and eventually partial AST files).

The term "translation unit" has been scrubbed from the project. To refer
to the context of declarations outside of any other declarations, use
"top-level" or "module scope". To refer to a .swift file or its DeclContext,
use "source file". To refer to a single unit of compilation, use "module",
since the model is that an entire module will be compiled with a single
driver call. (It will still be possible to compile a single source file
through the direct-to-frontend interface, but only in the context of the
whole module.)

Swift SVN r10837
2013-12-05 01:51:15 +00:00
Dmitri Hrybenko
e2b8312797 Code completion: try to substitute generic arguments when completing
a constructor reference


Swift SVN r10820
2013-12-04 23:54:42 +00:00
Dmitri Hrybenko
b3cf7d7a08 Code completion: remove redundant parentheses that were being shown in the
types of the implicitly curried instance functions


Swift SVN r10807
2013-12-04 23:07:18 +00:00
Dmitri Hrybenko
25d0ab2c3a Code completion: substitute generic parameters in references to members of metatypes
Swift SVN r10801
2013-12-04 22:44:00 +00:00
Dmitri Hrybenko
6d3f2f9f45 Code completion: when completing a reference to a variable that comes from a
generic nominal, substitute known generic parameters if possible


Swift SVN r10788
2013-12-04 19:31:00 +00:00
Dmitri Hrybenko
541c04f7af Code completion: switch constructor completion from using argument patterns to
use type of the constructor member


Swift SVN r10787
2013-12-04 18:51:05 +00:00
Dmitri Hrybenko
d076501cca Don't repeat Context.getIdentifier("self") everywhere in the code base
Swift SVN r10786
2013-12-04 18:42:34 +00:00
Sonny Falk
c350114862 [IDE] Fix a typo that caused a crash. <rdar://problem/15580756> Crash in ModelASTWalker::walkToDeclPre() when opening a document in Xcode
Swift SVN r10775
2013-12-04 02:45:33 +00:00
Dmitri Hrybenko
e974992039 Code completion: when completing a call to a function that comes from a generic
nominal, substitute known generic parameters if possible

This should improve code completion experience for generic containers a lot:

(swift) var a = Array<Float>()
// a : Array<Float> = []
(swift) a.
...
  Decl[InstanceMethod]/CurrNominal:   append({#val: Float#})[#Void#]
...
  Decl[InstanceMethod]/CurrNominal:   each({#f: (Float) -> Void#})[#Void#]
...
  Decl[InstanceMethod]/CurrNominal:   enumerate()[#Array<Float>#]
...
  Decl[InstanceMethod]/CurrNominal:   next()[#Float?#]
...
  Decl[InstanceMethod]/CurrNominal:   sort({#pred: (Float, Float) -> Bool#})[#Void#]
...

Only implemented for functions.  Constructors and subscripts coming soon.


Swift SVN r10774
2013-12-04 02:33:16 +00:00
Dmitri Hrybenko
12c525a4d1 Code completion: add parentheses in all cases when completing enum elements
with payloads


Swift SVN r10773
2013-12-04 02:02:28 +00:00
Sonny Falk
69a4cfb866 [IDE] Add InheritedTypeRanges to SyntaxStructureNode.
Add tests to cover name source range and inherited types to the structure tests.

Swift SVN r10767
2013-12-04 00:00:23 +00:00
Dmitri Hrybenko
4d827aa7d5 Replace an unnamed namespace with a static specifier on the function
Swift SVN r10766
2013-12-03 23:39:30 +00:00