Commit Graph

262 Commits

Author SHA1 Message Date
Svyatoslav Kuzmich 5d7f18b1b9 [JS] Support wrapped and dynamic types in typeOf 2019-10-03 13:12:46 +03:00
Svyatoslav Kuzmich 7592048437 [JS] Support typeOf 2019-09-25 18:12:55 +03:00
Ilya Gorbunov 44195d436e Rename: Clock.markNow, ClockMark.elapsedNow
Add "Now" suffix to the names of functions that depend on the current
time moment.
2019-08-16 15:29:16 +03:00
Ilya Gorbunov 3751a8a797 Common Array.fill for unsigned arrays, improve docs, native impl name
KT-32359
2019-08-01 19:02:39 +03:00
Jake Wharton 1a6069382e Provide Array.fill in common stdlib
KT-32359
2019-08-01 19:02:38 +03:00
Dat Trieu 38d26b1d92 KT-16602: Provide samples for sorting API usage 2019-07-12 21:32:03 +03:00
Ilya Gorbunov 39bdf34b9f Use common implementation of fastLog2 based on countLeadingZeroBits 2019-07-08 19:09:32 +03:00
Ilya Gorbunov f8724654a1 Bit query and bit rotation functions for Int, Long, Short, Byte
#KT-12749
2019-07-08 19:09:32 +03:00
Svyatoslav Kuzmich 69962cbf8c [JS IR BE] Add JsExport annotations 2019-07-01 18:55:41 +03:00
Ilya Gorbunov d58c8c68d5 Fix replacement for deprecated Math.pow #KT-32083 2019-06-27 05:22:25 +03:00
AJ Alt ed96197d6b Always use LF line endings in generated stdlib code
The code generation uses a mixture of literal `\n` characters and `appendln`. The latter insert `\r\n` on Windows by default, causing generated files to contain a mixture of line endings.

This commit sets the `line.separator` system property for the generator to `\n` so that `appendln` will never insert `\r` characters. As an additional measure, `.gitattributes` files were added to checkout generated stdlib files always with LF line endings.
2019-06-27 03:02:10 +03:00
Ilya Gorbunov a2b1c537af Change Duration.toString scientific exponent formatting
- use 'e+' for positive exponents in scientific format
2019-06-18 19:49:35 +03:00
Ilya Gorbunov c66740a7ed Explicit public visibility, SinceKotlin and ExperimentalTime status
Use file level ExperimentalTime opt-in in tests.
2019-06-18 04:02:35 +03:00
Ilya Gorbunov 8c730e180c Make ClockMark an abstract class instead of an interface 2019-06-18 04:02:34 +03:00
Ilya Gorbunov 368452748b Move convertDurationUnit into Duration companion 2019-06-18 04:02:33 +03:00
Ilya Gorbunov b5d16f1a9b Simplify Clock/ClockMark design
- Do not require initialElapsed parameter
- Introduce instead ClockMark +- Duration operators
- Do not require ClockMark to expose its originating Clock back
- Turn elapsedFrom property into elapsed() function
- Rename abstract clock classes
- Fix unit of abstract clocks when constructing them

Add top-level docs for Clocks
2019-06-18 04:02:32 +03:00
Ilya Gorbunov ca29cfb88d Implement MonoClock in JS
It uses either process.hrtime() in node.js or performance.now() in browser,
falling back to Date.now() if the latter is not available
2019-06-18 04:02:31 +03:00
Ilya Gorbunov b816f50d4d Implement and test default string formatting in JVM and JS
Relax Duration.toString tests for JS and Native rounding specifics
2019-06-18 04:01:55 +03:00
Ilya Gorbunov 804d2b2d8c Helper utilities to execute test code on particular platforms 2019-06-18 03:59:52 +03:00
Ilya Gorbunov 7977b6cdb8 Implement DurationUnit in JS, add doc summary and conversion test 2019-06-18 03:59:51 +03:00
Ilya Gorbunov 37c5f2c54f Initial prototype of Duration and Clocks API 2019-06-18 03:59:51 +03:00
Svyatoslav Kuzmich 142c9e2a8b [JS RUNTIME] Workaround invalid IR in ArraySorting 2019-05-24 11:50:47 +03:00
Svyatoslav Kuzmich ec34cdaae9 [JS STDLIB] Fix: Object.keys() returns list of strings 2019-05-24 11:50:46 +03:00
Roman Artemev cd3fd60dd7 [JS BE] Extract backend specific code from shared stdlib sources 2019-05-16 19:27:41 +03:00
Svyatoslav Kuzmich 23a214710b [JS IR BE] Add Unit return type to function signature 2019-05-15 14:09:02 +03:00
Ilya Gorbunov 2c26dc3af6 Add simplified overloads of String<->ByteArray/CharArray conversions
These overloads cover the most common cases of conversion of the entire
String or Byte/CharArray, avoiding extra index check and branching.

#KT-24810, KT-29265
2019-05-08 02:58:57 +03:00
Svyatoslav Kuzmich e3bcabeae3 [JS IR] stdlib: Fix bugs in Long.toString(radix) 2019-05-07 21:49:12 +03:00
Svyatoslav Kuzmich bc29a5b15c [JS IR] stdlib: port methods that use bit representation of numbers
- Port part of 'misc.js' from current backend to 'bitUtils.kt' in IR backend
- Enable toBits, toRawBits, fromBits extension function on Double and Float
- Enable Double.withSign
- Refactor getNumberHashCode using new utils
2019-05-07 21:49:12 +03:00
Abduqodiri Qurbonzoda c8a4fa58cd Implement String to/from ByteArray conversion (KT-24810) 2019-05-06 15:54:28 +03:00
Abduqodiri Qurbonzoda 81d2d3cb6a Implement String to/from CharArray conversion (KT-29265) 2019-05-06 15:54:28 +03:00
Svyatoslav Kuzmich 379cb08226 [JS] Reduce usage of 'js' function in stdlib
Function 'kotlin.js.js' is to be redesigned in JS IR backend,
partially because it is a hard feature to support.

Current implementation is unstable and can cause problems around
 inlining and name generator. Luckily most of its use-cases
can be covered by simpler features like dynamic expressions and
external declarations.

Thus we are reducing it's usage in stdlib to make IR backend more
stable in current state. JavaScript features that can't be covered by dynamic expression are
implemented in 'jsOperators.kt' file respectively for each backend:

 - 'internal inline' function which calls 'js' function inside for current
   pre-IR backend

 - 'internal' function with '_hack' parameters for JS IR backend which will be
   later intinsicified in a compiler
2019-04-30 15:27:19 +03:00
nikita.movshin abb7d3ab46 Update copyright.
Change the copyright from "JetBrains s.r.o." to
"JetBrains s.r.o. and Kotlin Project contributors"
Update 2 lines comment
2019-04-23 20:09:27 +03:00
nikita.movshin 65244b4bea Update copyright.
Change the copyright from "JetBrains s.r.o." to
"JetBrains s.r.o. and Kotlin Project contributors"
Update only 2 lines copyright.
2019-04-23 20:09:22 +03:00
Svyatoslav Kuzmich b1d303b027 Reorganize stdlib-js sources specific to the current JS backend
Move kotlin-stdlib-js project and the sources specific to the current backend to 'stdlib/js-v1' directory,
but leave sources that can be shared with the new IR backend in the common 'stdlib/js' location
with exception for 'stdlib/js/src/generated', which is used exclusively for current backend.
This simplifies sourceset configuration when building stdlib with the new backend.
2019-04-22 20:30:57 +03:00
Svyatoslav Kuzmich d7be91e8a4 [JS IR BE] Add SIZE_BYTES and SIZE_BITS to Long and Char 2019-04-22 20:30:57 +03:00
Svyatoslav Kuzmich 3fd55673a8 [JS IR BE] Workaround for println
IR backend has a bug in decomposition of dynamic calls.
Workaround: don't use inline function call inside dynamic call argument.
2019-04-22 13:18:00 +03:00
Abduqodiri Qurbonzoda 3f08753f87 Move string-related files to text directory 2019-04-19 03:51:20 +03:00
Svyatoslav Kuzmich 977d3ef840 [JS IR BE] New name generator 2019-04-13 14:19:36 +03:00
Svyatoslav Kuzmich 38fc4b0c59 [JS IR BE] Hack irRuntime js function usage to compensate for implementation shortcomings 2019-04-13 14:17:59 +03:00
Anton Bannykh b7ffdb9fde JS IR: support kotlin.test 2019-04-05 12:30:21 +03:00
Ilya Gorbunov 04bbf23936 Add explicit imports of kotlin.ranges more specific functions
The extensions 'contains' and 'reversed' from kotlin.ranges can be more
specific for IntRange, LongRange, etc than the same functions from
kotlin.collections, yet they lose in overload resolution to the latter
ones when invoked from kotlin.collections package
because of same package package extensions are preferred (KT-30633).
2019-04-02 21:28:33 +03:00
Sergey Rostov fb3f28974e Build: support local.properties for JPS build. Apply JPS related tweaks only inside IDEA import. 2019-03-28 10:06:16 +03:00
Ilya Gorbunov b74fe7c1c3 Clarify floor and ceil docs (KT-30418) 2019-03-19 03:12:12 +03:00
Ilya Gorbunov b0a234ec74 Minor: collection docs formatting 2019-03-19 03:12:09 +03:00
Abduqodiri Qurbonzoda a369496aca Throw IOOB on invalid index in JS StringBuilder.get to adhere contract 2019-03-15 17:40:31 +03:00
Abduqodiri Qurbonzoda ba61695a45 Check for index-out-of-bound in elementAt function (KT-30051) 2019-03-12 21:39:09 +03:00
Ilya Gorbunov db4c4132f6 Make JvmPackageName a common internal annotation 2019-03-08 23:35:37 +03:00
Abduqodiri Qurbonzoda fc85781bfc Implement asList, slice & sliceArray extension functions for UArrays 2019-03-08 23:34:34 +03:00
Roman Artemev 0ec75f1534 [JS IR BE] Temporary fix K/JS stdlib 2019-03-04 23:24:14 +03:00
Svyatoslav Kuzmich a01407eec9 [JS IR BE] Don't mangle Any::equals method 2019-02-28 20:13:56 +03:00