Commit Graph

10384 Commits

Author SHA1 Message Date
Alexander Udalov 1eeaaad05d Refactor method/constructor calls in codegen
- use ResolvedCall where possible
- 'call' parameter to invokeMethodWithArguments was used only to generate
  callee, e.g. in "A()" where A is an expression which can be invoke()'d.
  In case of constructors and enum entry delegation specifiers there's no need
  to generate callee, so 'call' is made Nullable with a subsequent assert
- remove generateJavaConstructorCall() method, since it did no useful work.
  Java constructor invocation is broken anyway and needs to be fixed (KT-3532)
- minor code style / formatting issues fixed, several methods renamed to better
  reflect semantics
2013-04-22 17:59:32 +04:00
Alexander Udalov db65237989 Refactor ClosureCodegen
- make several commonly used parameters ClosureCodegen's fields
- take an arbitrary strategy for closure function body codegen
- don't make extra binding context lookups
2013-04-22 17:59:31 +04:00
Alexander Udalov 80b78f0f6d invokeinterface FunctionN.invoke()
Instead of invokevirtual on FunctionImpl class, do invokeinterface on a
Function trait. This will allow to invoke functions on classes which don't
inherit from FunctionImpl classes.

Also rename the method to the more sensible name
2013-04-22 17:59:31 +04:00
Alexander Udalov 141b996709 Minor refactoring in ExpressionCodegen
Inline useless method, factor out resolveToCallableMethod logic from
resolveToCallable
2013-04-22 17:59:31 +04:00
Alexander Udalov f509407852 Extract static helpers to FunctionTypesUtil
Also move 'getInternalClassName' method from CodegenUtil to FunctionTypesUtil,
since it's related to function types
2013-04-22 17:59:31 +04:00
Alexander Udalov 121cb13883 Minor refactoring in CodegenBinding
- CLASS_FOR_FUNCTION slice was used for two purposes: to record closure classes
  for functions and for scripts. Separate this slice into two slices:
  CLASS_FOR_FUNCTION and CLASS_FOR_SCRIPT
- add classNameForAnonymousClass() overloaded method to CodegenBinding, taking
  a function descriptor (not a PSI element)
2013-04-22 17:59:31 +04:00
Alexander Udalov f907d008e7 Refactor ClosureCodegen
Extract some methods, replace types with more generic (ExpressionCodegen ->
LocalLookup), make more stuff fields instead of parameters passed to every
method, annotate with Nullable/NotNull
2013-04-22 17:59:31 +04:00
Alexander Udalov fee7846c7e LHS of callable reference can't be a type parameter 2013-04-22 17:59:31 +04:00
Alexander Udalov d40906a690 Disallow references to extensions in classes
It's not clear in which order should the two receiver arguments be passed to
them, and there's no corresponding K*FunctionN class for now

 #KT-1183 In Progress
2013-04-22 17:59:31 +04:00
Alexander Udalov c4b4fa750c Resolve callable reference expressions
#KT-1183 In Progress
2013-04-22 17:59:31 +04:00
Alexander Udalov 1db026aac5 Add CheckValueArgumentsMode to call resolver
Now it's ENABLED everywhere. DISABLED will be used for resolving callable
reference expressions, since there won't be any arguments near the function
call to check

 #KT-1183 In Progress
2013-04-22 17:59:30 +04:00
Alexander Udalov 1d07068c7c Minor refactoring in CallExpressionResolver
Kill useless parameters
2013-04-22 17:59:30 +04:00
Alexander Udalov 77ef20a51e Generate KFunction/KMemberFunction/KExtensionFunction
#KT-1183 In Progress
2013-04-22 17:59:30 +04:00
Alexander Udalov b343e94ea5 Refactor GenerateFunctions
Extract some methods && constants, inline some useless methods, replace
PrintStream with PrintWriter, make some methods non-static
2013-04-22 17:59:30 +04:00
Alexander Udalov dac0d77e90 Parse simple callable reference expressions
#KT-1183 In Progress
2013-04-22 17:59:30 +04:00
Alexander Udalov a6e242d166 Add new token COLONCOLON (::) for callable reference
#KT-1183 In Progress
2013-04-22 17:59:30 +04:00
Alexander Udalov d566250b18 Introduce JetCallableReferenceExpression
Reuse the obsolete hash qualified expression as a newly born callable reference
expression: Foo::bar. It's not a qualified expression anymore, since the
receiver part is now a JetTypeReference and it also can be empty ("::bar")

 #KT-1183 In Progress
2013-04-22 17:59:30 +04:00
Alexander Udalov b7671d8af2 Delete unused method
It was only used in parsing tuples, which are dropped
2013-04-22 17:59:30 +04:00
Alexander Udalov 76fa9642f0 toString() for FunctionN classes
It's implemented as if the types were reified: getting the real type parameters
of the corresponding FunctionN class
2013-04-22 17:59:29 +04:00
Alexander Udalov 0ec1f20140 Write generic signature for closure FunctionN superclass
ClosureCodegen.appendType() now appends any Type as a type parameter correctly
2013-04-22 17:59:29 +04:00
Alexander Udalov 974df0ed8e Use FunctionImplN instead of FunctionN in codegen
Superclass of closures should now be FunctionImplN instead of FunctionN. Since
these -Impl classes are needed only in JVM, the corresponding descriptors and
types are created in the back-end only.
2013-04-22 17:59:29 +04:00
Alexander Udalov 6f6cb03549 Make FunctionN interfaces
FunctionN and ExtensionFunctionN are now interfaces, with the corresponding
implementations in FunctionImplN and ExtensionFunctionImplN

Update test data
2013-04-22 17:59:29 +04:00
Alexander Udalov 34470ec89a Regenerate FunctionN and ExtensionFunctionN classes
GenerateFunctions now also generates Java classes in runtime/src/jet/
directory, and they have the matching declarations to those in
compiler/src/jet/

Delete ExtensionFunctionN's protected constructor, as it wasn't needed

Delete toString(), a more useful version will be implemented soon
2013-04-22 17:59:29 +04:00
Alexander Udalov 5c777a2f3a Refactor GenerateFunctions
Introduce FunctionKind enum to store differences between functions and
extension functions (and possible future function-like classes)

Also remove some useless checks
2013-04-22 17:59:29 +04:00
Alexander Udalov 5150eb1eea Fix newlines in FunctionN generator
Use println() instead of print('\n')
2013-04-22 17:59:29 +04:00
Nikolay Krasko ea52c6f717 KT-3508 Use a relative path for Kotlin bundled libraries instead of absolute path
#KT-3508 Fixed
2013-04-22 13:28:02 +04:00
Wojciech Lopata cd0e1b7508 RmoveUnnecessaryParenthesesIntention 2013-04-19 08:41:31 +02:00
Wojciech Lopata 3e76fc2902 Rename method 2013-04-19 08:21:00 +02:00
Nikolay Krasko 5df85f6100 KT-3525 Duplicate inner class name not detected
#KT-3525 Fixed
2013-04-19 01:10:54 +04:00
Nikolay Krasko 37f25f2ee1 KT-2258 Plugin does not suggest to import objects
#KT-2258 Fixed
2013-04-19 01:10:53 +04:00
Nikolay Krasko e1b1252657 Refactoring: rename auto import fix 2013-04-19 01:10:52 +04:00
Nikolay Krasko 2b8cac44bb Test for KT-1322 There's no autoimport suggested for traits
#KT-1322 Fixed
2013-04-19 01:10:52 +04:00
Mohammad Shamsi 296bda2e3a Fixed #KT-3379 jet.String.trimLeading and trimTrailing default whitespace trim 2013-04-19 01:10:51 +04:00
Evgeny Gerashchenko 622c1c3790 Reverted optimizing imports. 2013-04-18 22:33:06 +04:00
Evgeny Gerashchenko 7133f20247 Added tests with type parameter of class in SAM adapter. 2013-04-18 22:02:04 +04:00
Evgeny Gerashchenko 8c4e45de9a Supported SAM adapters with type parameters. 2013-04-18 22:01:26 +04:00
Evgeny Gerashchenko db8d285b25 Extracted method recreating type parameters. 2013-04-18 22:01:26 +04:00
Evgeny Gerashchenko f4994969c0 Added tests with type parameter of class in SAM adapter. 2013-04-18 22:01:26 +04:00
Evgeny Gerashchenko e554228a73 Added tests with mixture of SAM and non-SAM parameters. 2013-04-18 22:01:26 +04:00
Evgeny Gerashchenko 7bd11718de Supported simplest cases of SAM adapter in backend. 2013-04-18 22:01:26 +04:00
Evgeny Gerashchenko c5b9c6a7dc Minor. Removed index counter. Renamed variable. 2013-04-18 21:59:49 +04:00
Evgeny Gerashchenko 8f8d284fe1 Added Kotlin external annotations to codegen tests with Java. 2013-04-18 21:59:49 +04:00
Evgeny Gerashchenko be0238a61e Loading SAM adapters with wildcard types. 2013-04-18 21:59:49 +04:00
Evgeny Gerashchenko c8e02f75b0 Supported simplest cases of SAM adapter. 2013-04-18 21:59:49 +04:00
Evgeny Gerashchenko 37eccdb01f Saving "SAM interface" mark when resolving Java class. 2013-04-18 21:59:49 +04:00
Evgeny Gerashchenko 0ae0941e43 Minor. Used util method. 2013-04-18 21:59:48 +04:00
Mikhael Bogdanov 82d7f07cb3 Fixed bug in fix for KT 3492: Bug in bytecode generation for labeled super call from inner class & Property generation refactoring 2013-04-18 18:33:25 +04:00
Andrey Breslav fe4dd2f661 Fix tests (by extracting a method and calling it multiple times) 2013-04-18 17:36:30 +04:00
Andrey Breslav 140382e280 PSI getter fixed: left-hand side of a binary expression can now be null
EA-35976 - IAE: FqNameUnsafe.validateFqName
2013-04-18 16:34:10 +04:00
Mikhael Bogdanov c69e7f059d Duplicated JetTypeMapper.mapSignature removed 2013-04-18 15:03:43 +04:00