Commit Graph

160 Commits

Author SHA1 Message Date
Ivan Kylchik 2f2e608502 Expand the possibilities of object's interpretation
It is possible to create object in interpreter even if its
receiver symbol came from function parameter instead of object's class.
#KT-48174 Fixed
2021-08-13 16:18:36 +03:00
Ivan Kylchik 492b8acf93 Rename some methods in interpreter's stack to make their purpose clearer 2021-08-13 16:18:34 +03:00
Ivan Kylchik 69fe7e66a5 Introduce some helpful type aliases in interpreter 2021-08-13 16:18:32 +03:00
Ivan Kylchik 1808f14677 Switch from using of MutableList to ArrayDeque in interpreter's stack 2021-08-13 16:18:32 +03:00
Ivan Kylchik ac2dffa74e Speed up interpreter's stack by using map of variables instead of list 2021-08-13 16:18:31 +03:00
Ivan Kylchik a630273af2 Speed up interpreter's intrinsic check by introducing map of handlers 2021-08-13 16:18:30 +03:00
Ivan Kylchik 23b315446f Support sam conversion in ir interpreter 2021-08-13 16:18:28 +03:00
Ivan Kylchik b85a796492 Support interpretation for floorDiv and mod functions 2021-08-13 16:18:28 +03:00
Ivan Kylchik f9607292b5 Add additional useful ir classes into IrInterpreterEnvironment 2021-08-13 16:18:26 +03:00
Ivan Kylchik b46a42be33 Drop toIrConst function with IrBuiltIns parameter 2021-08-13 16:18:25 +03:00
Tianyu Geng 684ef871ee FIR: unify common special names scattered around the code base 2021-08-06 22:57:17 +03:00
Ivan Kylchik 44e1b61e6c Move static cache from Wrapper into non-static container in environment
By this change it is possible to run multiple test in parallel
without running out of memory.
2021-08-06 13:33:32 +03:00
Ivan Kylchik 3932acf843 Fix interpretation of default varargs 2021-08-06 13:33:30 +03:00
Ivan Kylchik 0ce3dd117e Drop unnecessary check for not static initializer in interpreter
Apparently initializers can become static only in lowering
2021-08-06 13:33:30 +03:00
Ivan Kylchik 0af918be4f Use IrFactory to create IrFunction in interpreter 2021-08-06 13:33:29 +03:00
Ivan Kylchik 1002d076b3 Use StandardNames whenever it is possible in Wrapper 2021-08-06 13:33:28 +03:00
Ivan Kylchik 3cf4b8b108 Combine two caches from interpreter environment into single one 2021-08-06 13:33:28 +03:00
Ivan Kylchik 3fc5405d57 Implement simple cache for dynamically created wrapper for defaults 2021-08-06 13:33:27 +03:00
Ivan Kylchik 09c31b0900 Implement simple cache for dynamically created wrapper for lambda 2021-08-06 13:33:25 +03:00
Ivan Kylchik 524189132b Introduce new property fqName to make it easier to take element's name 2021-08-06 13:33:24 +03:00
Ivan Kylchik 295638b26e Allow to interpret non const properties of compile time object 2021-08-06 13:33:22 +03:00
Ivan Kylchik a9abf3b9b6 Drop redundant frames after some of exceptions in interpreter
Drop only last frame because it is pointing on function itself.
2021-08-06 13:33:21 +03:00
Ivan Kylchik 334d518aba Change the way of getting name and ordinal for enum entry in interpreter
For now IrProperty doesn't have corresponding overridden symbol, so
it must be taken from getter.
2021-08-06 13:33:20 +03:00
Ivan Kylchik f815f63fc5 Replace UNDEFINED_OFFSET with SYNTHETIC_OFFSET in IrTreeBuildUtils
This change is needed to avoid exception in `getLineNumber` method.
2021-08-06 13:33:20 +03:00
Ivan Kylchik 0c5fca31ec Support early return from constructor interpretation 2021-08-06 13:33:19 +03:00
Ivan Kylchik 96cc74a752 Fix enum interpretation in case when primary constructor is missing 2021-08-06 13:33:18 +03:00
Ivan Kylchik 668bb4fd71 Fix equals check in interpreter in case when object is wrapped as Proxy 2021-08-06 13:33:18 +03:00
Ivan Kylchik b9decc3b30 Support type check for deep nested arrays in interpreter 2021-08-06 13:33:17 +03:00
Ivan Kylchik 4ad88679fd Unify logic of creation new ir tree nodes in interpreter 2021-08-06 13:33:17 +03:00
Ivan Kylchik 6ce2f8eb14 Drop unnecessary SubFrame creation from interpreter 2021-08-06 13:33:16 +03:00
Ivan Kylchik 10efbeb0c9 Add synthetic function in interpreter for default args evaluation 2021-08-06 13:33:16 +03:00
Ivan Kylchik 7852d01da6 Rewrite interpreter logic around arguments evaluation
For now calculated arguments will be stored on stack instead of memory.
At first this was done because of problems with default arguments, but
in the next commit this problem will be solved.
2021-08-06 13:33:15 +03:00
Ivan Kylchik d41c6e900a Place variables in interpreter's memory at the beginning
In case than in single SubFrame can appear several variables with
the same symbol, it is important to get the latest one. It is
relevant for local functions.
2021-08-06 13:33:14 +03:00
Ivan Kylchik e5ca646de4 Move object creation logic into constructor interpretation
This newly created object is not used in arguments interpretation
so there is no need to create it in InstructionsUnfolder. Moreover
this object can interfere with other objects in memory, for example,
when creating outer object from inner.
2021-08-06 13:33:14 +03:00
Ivan Kylchik 1af1a3c84e Support interpretation of Throwable constructor
For now every subclass of Throwable will be represented as
ExceptionState. This way it is easier to store stack trace and handle
`cause` property in exceptions.
2021-08-06 13:33:13 +03:00
Ivan Kylchik c8cd000563 Simplify work with fake override methods in interpreter 2021-08-06 13:33:12 +03:00
Ivan Kylchik 8972fc5158 Interpret properties and init blocks in order of appearance 2021-08-06 13:33:12 +03:00
Ivan Kylchik 78475a5d9c Support interpretation of toArray for collections 2021-08-06 13:33:11 +03:00
Ivan Kylchik b10fdb919f Support cast to array with reified argument in interpreter 2021-08-06 13:33:10 +03:00
Ivan Kylchik cc56acc2c2 Add configuration into IrInterpreterEnvironment
This configuration will contains all necessary setting for interpreter
and will be replenished over time
2021-08-06 13:33:10 +03:00
Ivan Kylchik b150cc9537 Implement better support for default args in interpreter
Now supported default args:
1. from super class or interface;
2. with field access, declared in interface;
3. with field access, declared in outer class.
2021-08-06 13:33:09 +03:00
Ivan Kylchik 42ea17b151 Support interpretation of dataClassArrayMemberToString method 2021-08-06 13:33:09 +03:00
Ivan Kylchik 15808cb376 Lower priority of captured variables in interpreter 2021-08-06 13:33:08 +03:00
Ivan Kylchik 4f3d47eed3 Remove unused equals and hashCode methods from Primitive class
They were used only when primitive objects were put in the collection
as they were, in Primitive state wrapper
2021-08-06 13:33:07 +03:00
Ivan Kylchik 0716c557fe Allow inner class to has outer super class in interpreter 2021-08-06 13:33:07 +03:00
Ivan Kylchik 574c607f1c Support proper subtype check in interpreter for KFunction 2021-08-06 13:33:06 +03:00
Ivan Kylchik 9638af042d Support proper behavior in interpreter for cast of null value 2021-08-06 13:33:05 +03:00
Ivan Kylchik b44fd1a6fe Simplify logic of interpreting invoke method for lambdas
For now will be created separate invoke method that will contains
a call to lambda. This way it is clearer and more intuitive
2021-08-06 13:33:04 +03:00
Ivan Kylchik 06a8156376 Change logic of returning object from constructor in interpreter
For now there is no need to place object on stack before evaluation.
The result will be taken from memory and all unnecessary values on
stack will be removed
2021-08-06 13:33:02 +03:00
Ivan Kylchik 3326cbd9c0 Support passing property as argument to array constructor in interpreter 2021-08-06 13:33:02 +03:00