Commit Graph

66867 Commits

Author SHA1 Message Date
Ivan Kylchik 2534b15553 Remove descriptors.jvm dependency from common backend module
Common backend should not depend on JVM parts
2020-06-24 16:13:00 +03:00
Ivan Kylchik 8f6a1b418d Add method to evaluate constant expressions in ir module for fir2ir 2020-06-24 16:13:00 +03:00
Ivan Kylchik fa221af1b1 Move IrConstTransformer.kt to evaluate package 2020-06-24 16:13:00 +03:00
Ivan Kylchik 932ce71093 Rename method checkForError to replaceIfError
This name better reflects the point of this method.
a.replaceIfError(b) will return b instead of a in case a is an error
expression
2020-06-24 16:13:00 +03:00
Ivan Kylchik b71c74c6ef Remove descriptor usages in Primitive.kt 2020-06-24 16:13:00 +03:00
Ivan Kylchik 0c6d485c9c Rename ReturnLabel.NEXT to ReturnLabel.REGULAR
This name better describe that this label mean: execution was finished
regular and there is no need to make special processing
2020-06-24 16:13:00 +03:00
Ivan Kylchik 9377d274a8 Drop ExecutionResult class implementations and make it regular class
There was 2 implementations that I managed to combine
2020-06-24 16:12:59 +03:00
Ivan Kylchik c386cbeb54 Move checkNullability function in State.kt file 2020-06-24 16:12:59 +03:00
Ivan Kylchik e57de9a08f Mark most of classes and functions from interpreter package as internal
Main goal is to avoid ambiguity because some names, that are used by
interpreter, can be found in other modules
2020-06-24 16:12:59 +03:00
Ivan Kylchik 27c52f54ca Remove IGNORE_FIR from tests that are passing after constant folding 2020-06-24 16:12:59 +03:00
Ivan Kylchik f20e878d35 Add constant folding after FIR2IR processing 2020-06-24 16:12:59 +03:00
Ivan Kylchik f2045b857b Add fix for interpretation const val
After FIR2IR processing getter doesn't has body, but has initializer.
On the other hand common IR has body for const val getter
2020-06-24 16:12:59 +03:00
Ivan Kylchik af6ed5ca43 Change toIrConst extension function logic
For now this function check not value, but type. By ir type it create
right ir const
2020-06-24 16:12:59 +03:00
Ivan Kylchik 3155f56d8a Change the way of receiving fields
Before that, interpreted values for fields were taken by backing
field's symbol. For now, they will be taken by property's symbol.
It was done because not all properties contain backing field. For
example, Throwable class in FIR2IR.
2020-06-24 16:12:58 +03:00
Ivan Kylchik 8644c48b28 Prevent interpretation of call expression with continue/break statement
Example: foo("" + continue)
2020-06-24 16:12:58 +03:00
Ivan Kylchik d90aba60cc Implement correct type checks and casts taking into account erased types 2020-06-24 16:12:58 +03:00
Ivan Kylchik 7a19906705 Change all usages of descriptors in interpreter to usages of ir symbols 2020-06-24 16:12:58 +03:00
Ivan Kylchik db5046af85 Add support in interpreter for jvm static fields in primitive classes 2020-06-24 16:12:58 +03:00
Ivan Kylchik a3c77eca08 Make interpreter maps of enum and object declarations non static
Instead of this just create interpreter once per module handling
2020-06-24 16:12:58 +03:00
Ivan Kylchik ff830cc744 Make state property mutable in Variable class
This change allow to remove copy method from State interface
2020-06-24 16:12:57 +03:00
Ivan Kylchik 848ca70de1 Change keys in static maps of enums and objects from String to IrSymbol 2020-06-24 16:12:57 +03:00
Ivan Kylchik 224d56ec15 Allow compile time calculations inside object declaration 2020-06-24 16:12:57 +03:00
Ivan Kylchik 1c498660dc Create ir compile time checker
This checker is suppose to return true if ir node can be computed
in compile time
2020-06-24 16:12:57 +03:00
Ivan Kylchik 19495e40f7 Remove unnecessary getAllTypeArguments method from Stack class 2020-06-24 16:12:57 +03:00
Ivan Kylchik 99d823da8a Remove unnecessary getThisAsReceiver function from Utils.kt file 2020-06-24 16:12:57 +03:00
Ivan Kylchik c6240face0 Add test for generation builtins map for interpreter 2020-06-24 16:12:57 +03:00
Ivan Kylchik 1103de4bd5 Prepare ir interpreter for receiving ir bodies in separate map
This change will be useful when starts work with jvm klib
2020-06-24 16:12:56 +03:00
Ivan Kylchik 9542eb36ec Support interpretation of String's plus method and its extension version 2020-06-24 16:12:56 +03:00
Ivan Kylchik 94e36411fa Support interpretation for inner class 2020-06-24 16:12:56 +03:00
Ivan Kylchik 0c1f2edbf2 Get rid of abstract and fake override checks in ir call interpretation
For now interpreter will find necessary method for interpretation in
one step instead of checking is this method abstract or fake override
2020-06-24 16:12:56 +03:00
Ivan Kylchik 80d83f8703 Change check for Wrapper method
For now method is wrapper if its receiver is Wrapper and
method itself isn't inline only
2020-06-24 16:12:56 +03:00
Ivan Kylchik 38822c3bf8 Implement correct interpretation of toList function 2020-06-24 16:12:56 +03:00
Ivan Kylchik ba8147cd47 Allow lambda to be used in built in calculation
Primary use case to allow lambda null check
2020-06-24 16:12:55 +03:00
Ivan Kylchik 5f61f6f3a5 Simplify interpretation for java methods with names other in kotlin 2020-06-24 16:12:55 +03:00
Ivan Kylchik 2e0d4c9af1 Add correct interpretation for unsigned arrays in vararg method handler 2020-06-24 16:12:55 +03:00
Ivan Kylchik 30f2affb93 Add support for local function that are declared and called immediately 2020-06-24 16:12:55 +03:00
Ivan Kylchik 296f343cab Change conditions for saving type arguments into stack
For now all type arguments are saved. This is necessary for several
reason:
1. ir type operator call need to get right type argument class
2. if class is local then information about type argument cannot be lost
2020-06-24 16:12:55 +03:00
Ivan Kylchik a095309e10 Allow local declaration interpretation
By local declaration is meant local functions and local objects
2020-06-24 16:12:55 +03:00
Ivan Kylchik 2c93c46b84 Implement do while loop 2020-06-24 16:12:55 +03:00
Ivan Kylchik 1e82975a7c Replace explicit returnLabel call to check call inside try interpreter 2020-06-24 16:12:54 +03:00
Ivan Kylchik a14e8e4c28 Implement cache for enum entries and objects 2020-06-24 16:12:54 +03:00
Ivan Kylchik 0b0550f562 Remove useless Intrinsic interface
Moved all its methods inside sealed class
2020-06-24 16:12:54 +03:00
Ivan Kylchik eb3ac74c3f Move out intrinsic evaluation from interpreter class 2020-06-24 16:12:54 +03:00
Ivan Kylchik 6eae77572a Move stack trace inside Stack class 2020-06-24 16:12:54 +03:00
Ivan Kylchik e00dc76645 Simplify constructor interpretation
Unified case with secondary and primary constructors
2020-06-24 16:12:53 +03:00
Ivan Kylchik cf63a5f52b Replace some casts to Primitive with corresponding extension calls 2020-06-24 16:12:53 +03:00
Ivan Kylchik 5791ecd4f7 Remove redundant suspend modifiers 2020-06-24 16:12:53 +03:00
Ivan Kylchik cb0eb008f8 Implement correct access to stack
Rewrote work with data and implement Stack class that work over Frame
2020-06-24 16:12:53 +03:00
Ivan Kylchik 06e6c7cdf5 Implement interpretation for object with overridden methods 2020-06-24 16:12:53 +03:00
Ivan Kylchik fe7abb7132 Remove unnecessary code about handling KotlinNullPointerException
This part of code was necessary because jvm threw
KotlinNullPointerException, but js expected NullPointerException.
2020-06-24 16:12:53 +03:00