Giter Site home page Giter Site logo

flonso / kotlin-scala.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lionelfleury/kotlin-scala.js

0.0 1.0 0.0 39.46 MB

Compile Kotlin code to JavaScript through the Scala.js compiler

Scala 3.01% Java 41.61% Kotlin 52.24% HTML 0.03% Assembly 0.01% JavaScript 3.03% CSS 0.07%

kotlin-scala.js's Introduction

Kotlin-Scala.js

Build Status

Compile Kotlin code to JavaScript through the Scala.js compiler

Documentation

A full technical report is available under the docs/report directory. Useful resources include the Kotlin Documentation and the Scala.js Website.

Running the compiler

sbt "run {list_of_source_files} -d {output_sjsir_dir} -kotlin-home {kotlin_home_directory}"

To compile the Kotlin Standard Library use the -Xallow-kotlin-package option to ignore the package kotlin reservation.

  • A gradle plugin is also available with an example project here
  • A basic maven plugin is available here

Testing

All tests are stored under src/test and can be run with sbt test. Before running them, create the folders src/test/resources/out and src/test/resources/benchmark_out.

You will need to install the same version of Kotlin which is used by SBT.

To do so, either install it from here https://kotlinlang.org/docs/tutorials/command-line.html and/or change the path to the directory by changing the KOTLIN_HOME value in BlackBoxTest.scala

The tests require the presence of the Scala.js library jar file inside src/test/resources/lib. It should be included in this repository. If you need to change the Scala.js version in use for the tests, be sure to change the referenced .jar inside the BlackBoxTest.scala file.

Kotlin Standard Library

A test has been setup to check that the IR generated for the files constituting the Kotlin Standard Library is valid. Because the standard library is not compilable yet, the test has been disabled by default. It can be enabled in file src/test/scala/KotlinStdLibTest.

Benchmarking

Benchmarks are available in src/test/scala/BenchmarkTest. Outputs are written to the benchmark_out directory mentioned above.

kotlin-scala.js's People

Contributors

flonso avatar ex0ns avatar

Watchers

 avatar

kotlin-scala.js's Issues

Behaviour of is operator on Int and Double

The following Kotlin code doesn't produce the same output on both Kotlin "stock" compiler and the Kotlin-Scala.js compiler :

fun main(args: Array<String>) {
    val myDouble = 1.7

    check(myDouble)
}

fun check(a: Any) {

    if (a is Int) println("$a is an Int")
    if (a is Double) println("$a is a Double")
    if (a is Long) println("$a is a Long")


    if (a !is Int) println("$a is not an Int")
    if (a !is Double) println("$a is not a Double")
    if (a !is Long) println("$a is not a Long")
}

Output for KotlinJS compiler :

1.7 is an Int
1.7 is a Double
1.7 is not a Long

Output for Kotlin-Scala.js compiler :

1.7 is a Double
1.7 is not an Int
1.7 is not a Long

Need to investigate the reason behind this difference.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.