Giter VIP home page Giter VIP logo

lms-sandbox's Introduction

This sandbox has graduated to js.scala.

lms-sandbox's People

Contributors

gkossakowski avatar namin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

lms-sandbox's Issues

heisenbug: reified calls to finalize()

It happened only once with the class proxy, but I thought I'd record it anyways, lest I forget. In one run of the tests, testReifiedExtendedClass had calls to finalize() like this:
...
x7 = new x6()
var x8 = this.finalize()
var x9 = this.finalize()
...

I am not sure if any other calls falls into this category, but for these, it seems we can just skip handling them in the JS invocation handler. (For the class proxy based on javassist, we can just use the filter for that, so the super 'real' class will handle these calls.)

@gkossakowski

chained super calls don't resolve correctly in reified traits

In reified traits, we only support single inheritance. Right now, we resolve super calls dynamically, having set this.$super$ to the parent. But this means that in a method inherited twice, where each calls its super, we would have an infinite loop.

create a file extension (maybe .scalajs?) which acts like build.sbt, setting up a file to be the scalajs DSL

So it'd have default imports of some package objects/Predef type constructs.

e.g.

// Foo.scalajs
package foo

def blah(x: Int) = x * 2

class Whatnot(val y: String) {
def thingy = "Hello " + y
}

which then pseudo-generates something like this from the perspective of Scala IDE / sbt...

// Foo.scala
package foo

import scalajs._

def blah(x: Int) = x * 2

class Whatnot(val y: String) {
def thingy = "Hello " + y
}

which then aliases things like scalajs.Int => scala.js.Rep[Int] etc

Semantics of private conflicting vals in reified classes

This example returns "1abc" instead of 2, because the private fields x overwrite each other dynamically, instead of being resolved statically.

@gkossakowski suggests just renaming private fields to avoid conflict.

diff --git a/src/test/scala/scala/js/TestClasses.scala b/src/test/scala/scala/js/TestClasses.scala
index 60713c2..072cfed 100644
--- a/src/test/scala/scala/js/TestClasses.scala
+++ b/src/test/scala/scala/js/TestClasses.scala
@@ -60,6 +60,19 @@ trait ClassesProg { this: JS with JSClasses =>
   }
   implicit def proxyRepFooFun(x: Rep[FooFun]) = repClassProxy[FooFun](x, this)

+  class PrivateA {
+    private val x = unit(1)
+    def get() = x
+  }
+  implicit def proxyRepPrivateA(x: Rep[PrivateA]) = repClassProxy[PrivateA](x, this)
+
+  class PrivateB extends PrivateA {
+    private val x = unit("abc")
+    def get2() = x
+    def get3() = unit(2)
+  }
+  implicit def proxyRepPrivateB(x: Rep[PrivateB]) = repClassProxy[PrivateB](x, this)
+
   def testClassProxy(foo: Rep[Foo]): Rep[Int] = {
     foo.f()
   }
@@ -147,6 +160,14 @@ trait ClassesProg { this: JS with JSClasses =>
     val outProducer = fun { () => 1 }
     (outProducer() + (fooFun.producer())()) // x+1
   }
+
+  def testPrivateConflictingVals(x: Rep[Int]): Rep[Int] = {
+    val newA = registerClass[PrivateA](this)
+    val newB = registerClass[PrivateB](this)
+    val a = newA()
+    val b = newB()
+    a.get() + b.get()
+  }
 }

 class TestClasses extends FileDiffSuite {
@@ -292,6 +313,16 @@ class TestClasses extends FileDiffSuite {
     assertFileEqualsCheck(prefix+"reified-class-fun-in-and-out")
   }

+  def testPrivateConflictingVals = {
+    withOutFile(prefix+"reified-class-private-conflicting-vals") {
+      new ClassesProg with JSExp with JSClassesExp { self =>
+        val codegen = new JSGen with JSGenClasses { val IR: self.type = self }
+        codegen.emitSource(testPrivateConflictingVals _, "main", new PrintWriter(System.out))
+      }
+    }
+    assertFileEqualsCheck(prefix+"reified-class-private-conflicting-vals")
+  }
+
   def testMixInClassesAndTraitsProxy = {
     trait ClassesAndTraitsProxyProg { this: JS with JSClassProxyBase with JSProxyBase =>
     }
@@ -307,4 +338,5 @@ class TestClasses extends FileDiffSuite {
       val codegen = new JSGen with JSGenClasses with JSGenTraits { val IR: self.type = self }
     }
   }
+
 }

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.