Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save suzuki0keiichi/6070633 to your computer and use it in GitHub Desktop.
Save suzuki0keiichi/6070633 to your computer and use it in GitHub Desktop.
Scala.jsでvalのメンバ変数がどのように変換されるか
// コンストラクタで宣言 $jsfield$というプリフィックスを付けて宣言される
ScalaJS.c.helloworld\ufe33HelloWorld$ = (function() {
ScalaJS.c.java\ufe33lang\ufe33Object.call(this);
this.$jsfield$hello = null
});
// getter
ScalaJS.c.helloworld\ufe33HelloWorld$.prototype.hello\ufe34T = (function() {
return this.$jsfield$hello
});
// コンストラクタ実体で初期化(Javascriptのコンストラクタとは別で存在している)
ScalaJS.c.helloworld\ufe33HelloWorld$.prototype.init\ufe33\ufe34 = (function() {
ScalaJS.c.java\ufe33lang\ufe33Object.prototype.init\ufe33\ufe34.call(this);
ScalaJS.moduleInstances.helloworld\ufe33HelloWorld = this;
this.$jsfield$hello = "hello world!";
return this
});
// 外部呼び出し用
ScalaJS.c.helloworld\ufe33HelloWorld$.prototype.hello = (function() {
return this.hello\ufe34T()
});
// コンストラクタで宣言($1がついている)
ScalaJS.c.HelloWorld$ = (function() {
ScalaJS.c.java_lang_Object.call(this);
this.hello$1 = null
});
// getter
ScalaJS.c.HelloWorld$.prototype.hello__T = (function() {
return this.hello$1
});
// コンストラクタ実体で初期化(Javascriptのコンストラクタとは別で存在している)
ScalaJS.c.HelloWorld$.prototype.init___ = (function() {
ScalaJS.c.java_lang_Object.prototype.init___.call(this);
ScalaJS.moduleInstances.HelloWorld = this;
this.hello$1 = "hello world!";
return this
});
// 外部呼び出し用(昔と違って__がpostfixにつくようになった?)
ScalaJS.c.HelloWorld$.prototype.hello__ = (function() {
return this.hello__T()
});
object HelloWorld {
val hello = "hello world!"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment