Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0b57718

Browse files
committed
Merge pull request#25 from timxzl/develop
catch up with Scala 2.11.2 version (the most recent scala virtualized version)
2 parentsd5e31ee +3f8105e commit0b57718

File tree

20 files changed

+82
-47
lines changed

20 files changed

+82
-47
lines changed

‎.gitignore‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,9 @@ examples/d3/d3_.html
2323

2424
# Tests
2525
~test-out/*.check
26+
27+
# Vim swap files
28+
*.swp
29+
30+
# Mac OS X junk
31+
.DS_Store

‎core/src/main/scala/scala/js/InScala.scala‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
packagescala.js
22

3+
importscala.language.implicitConversions
4+
importscala.language.existentials
5+
36
importscala.virtualization.lms.common._
47
importscala.reflect.SourceContext
58
importscala.js.language._
@@ -233,7 +236,7 @@ trait JSProxyInScala extends Proxy with InScala {
233236

234237
traitJSTraitsInScalaextendsTraitswithJSProxyInScala {
235238
defcreate[T<:AnyRef:Manifest]():T=
236-
thrownewRuntimeException("don't know how to create"+ implicitly[Manifest[T]].erasure.getName)
239+
thrownewRuntimeException("don't know how to create"+ implicitly[Manifest[T]].runtimeClass.getName)
237240
defregister[T<:AnyRef:Manifest](outer:AnyRef):Factory[T]=
238241
newFactory[T] {
239242
overridedefapply()= create[T]()
@@ -434,4 +437,4 @@ trait OptionOpsInScala extends OptionOps with InScala {
434437
deffold[B:Manifest](none:=>B,some:A=>B)= o.fold(none)(some)
435438
defgetOrElse[B>:A:Manifest](default:=>Rep[B])= fold(default, identity)
436439
}
437-
}
440+
}

‎core/src/main/scala/scala/js/exp/CastsCheckedExp.scala‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
packagescala.js.exp
22

3+
importscala.language.implicitConversions
4+
35
importscala.js.language.Casts
46
importscala.virtualization.lms.common.EffectExp
57

‎core/src/main/scala/scala/js/exp/JSLiteralExp.scala‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
packagescala.js.exp
22

3+
importscala.language.implicitConversions
4+
35
importscala.js.language.JSLiteral
46
importscala.virtualization.lms.common._
57

@@ -36,4 +38,4 @@ trait JSLiteralExp extends JSLiteral with BaseExp {
3638
valevalArgs= argNames.map(x=> x-> self(x))
3739
JSLiteralDef(evalArgs)
3840
}
39-
}
41+
}

‎core/src/main/scala/scala/js/exp/ProxyExp.scala‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ trait ProxyExp extends Proxy with EffectExp {
2121
}
2222

2323
defproxy[T<:AnyRef](x:Rep[T],parentConstructor:Option[Rep[Any]],outer:AnyRef)(implicitm:Manifest[T]):T= {
24-
valclazz= m.erasure
24+
valclazz= m.runtimeClass
2525
valhandler=newJSInvocationHandler(x, parentConstructor, outer)
2626
valproxy= jreflect.Proxy.newProxyInstance(clazz.getClassLoader(),Array(clazz), handler)
2727
proxy.asInstanceOf[T]
@@ -70,4 +70,4 @@ trait ProxyExp extends Proxy with EffectExp {
7070
else reflectEffect(MethodCall[AnyRef](receiver, m.getName, args_.toList)):Exp[Any]
7171
}
7272
}
73-
}
73+
}

‎core/src/main/scala/scala/js/exp/TraitsExp.scala‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ trait TraitsExp extends Traits with ProxyExp {
2626
privatevarregistered:Map[String,Exp[Constructor[Any]]]=Map()
2727
privatedefregisterInternal[T<:AnyRef:Manifest](outer:AnyRef):Exp[Constructor[T]]= {
2828
valm= implicitly[Manifest[T]]
29-
valtraitClazz= m.erasure
29+
valtraitClazz= m.runtimeClass
3030
valkey= traitClazz.getName
3131

3232
registered.get(key)match {
@@ -35,7 +35,7 @@ trait TraitsExp extends Traits with ProxyExp {
3535
}
3636

3737
valimplClazz=Class.forName(traitClazz.getName+"$class")
38-
valparents= traitClazz.getInterfaces.filter(_!= implicitly[Manifest[scala.ScalaObject]].erasure)
38+
valparents= traitClazz.getInterfaces.filter(_!= implicitly[Manifest[AnyRef]].runtimeClass)
3939
assert (parents.length<2,"Only single inheritance is supported.")
4040
valparentConstructor=if (parents.length==0)NoneelseSome(registerInternal[AnyRef](outer)(Manifest.classType(parents(0))))
4141
valparent= parentConstructor.map(c=>ParentTemplate(c, create[AnyRef](c)))
@@ -70,4 +70,4 @@ trait TraitsExp extends Traits with ProxyExp {
7070
caseMethodTemplate(_, params, body)=> freqHot(body)
7171
case _=>super.symsFreq(e)
7272
}
73-
}
73+
}

‎core/src/main/scala/scala/js/exp/dom/ElementOpsExp.scala‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ trait ElementOpsExp extends ElementOps with EffectExp with EventOpsExp with Sele
99
defcss_fontweight(css:Rep[CSSStyleDeclaration])=foreign"$css.fontWeight"[Int].withEffect()
1010
defcss_set_fontweight(css:Rep[CSSStyleDeclaration],v:Rep[Int])=foreign"$css.fontWeight =$v".withEffect()
1111

12-
defelement_setAttribute(e:Exp[Element],name:Exp[String],value:Exp[Any])=foreign"$e.setAttribute($name,$value)".withEffect()
12+
overridedefelement_setAttribute(e:Exp[Element],name:Exp[String],value:Exp[_]):Rep[Unit]=foreign"$e.setAttribute($name,$value)".withEffect()
1313
defelement_tagName(e:Exp[Element])=foreign"$e.tagName"[String]
1414
defelement_className(e:Exp[Element])=foreign"$e.className"[String].withEffect()
1515
defelement_parentNode(e:Exp[Element])=foreign"$e.parentNode"[Option[Element]].withEffect()
@@ -53,4 +53,4 @@ trait ElementOpsExp extends ElementOps with EffectExp with EventOpsExp with Sele
5353
defimg_src(img:Exp[Img])=foreign"$img.src".withEffect()
5454
defimg_set_src(img:Exp[Img],src:Exp[String])=foreign"$img.src =$src".withEffect()
5555

56-
}
56+
}

‎core/src/main/scala/scala/js/gen/js/Compile.scala‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,4 +291,4 @@ trait GenMiscOps extends GenBase {
291291
caseError(s)=> stream.println("throw"+ quote(s)+";")
292292
case _=>super.emitNode(sym, rhs)
293293
}
294-
}
294+
}

‎core/src/main/scala/scala/js/gen/js/GenCastChecked.scala‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ trait GenCastChecked extends GenEffect {
2020
m.fields foreach {case (name, manifest)=> conformsFieldCheck(v, name, manifest) }
2121
case mif m==Manifest.classType(classOf[String])=> ()
2222
caseManifest.Int=> ()
23-
case mif m.erasure.isArray=>
23+
case mif m.runtimeClass.isArray=>
2424
stream.println("""if (!(%1$s instanceof Array)) throw "Not an Array: " + %1$s;""".format(v))
2525
valList(arrayElem)= m.typeArguments
2626
stream.println("""for (var i=0; i < %1$s; i++) {""".format(v+".length"))
@@ -33,4 +33,4 @@ trait GenCastChecked extends GenEffect {
3333
conformsCheck(v+"."+ f, m)
3434
}
3535

36-
}
36+
}

‎core/src/main/scala/scala/js/language/Adts.scala‎

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
packagescala.js.language
22

3+
importscala.language.higherKinds
4+
35
importscala.language.experimental.macros
46
importscala.virtualization.lms.common.Functions
57

@@ -40,7 +42,7 @@ trait Adts extends Functions {
4042
*
4143
*@return a staged smart constructor for the data type T
4244
*/
43-
defadt[T<:Adt]= macroAdtsImpl.adt[T]
45+
defadt[T<:Adt]:AnyRef= macroAdtsImpl.adt[T]
4446

4547
/**
4648
* {{{
@@ -57,22 +59,22 @@ trait Adts extends Functions {
5759
*
5860
*@return an object with staged members for the type T
5961
*/
60-
defadtOps[T<:Adt](o:Rep[T])= macroAdtsImpl.ops[T,Rep]
62+
defadtOps[T<:Adt](o:Rep[T]):AnyRef= macroAdtsImpl.ops[T,Rep]
6163

6264
}
6365

6466
objectAdtsImpl {
6567

66-
importscala.reflect.macros.Context
68+
importscala.reflect.macros.whitebox.Context
6769

6870
traitAdt
6971

7072
defadt[U<:Adt: c.WeakTypeTag](c:Context)=
71-
c.Expr[Any](newGenerator[c.type](c).construct[U])
73+
c.Expr[AnyRef](newGenerator[c.type](c).construct[U])
7274

7375

7476
defops[U<:Adt: c.WeakTypeTag,R[_]](c:Context)(o: c.Expr[R[U]])=
75-
c.Expr[Any](newGenerator[c.type](c).ops(o))
77+
c.Expr[AnyRef](newGenerator[c.type](c).ops(o))
7678

7779

7880
classGenerator[C<:Context](valc:C) {
@@ -99,13 +101,13 @@ object AdtsImpl {
99101
base.knownDirectSubclasses.foldLeft(List(base)) { (result, symbol)=>
100102
valclazz= symbol.asClass
101103
if (clazz.isCaseClass) clazz:: result
102-
elseif (clazz.isSealed&& (clazz.isTrait|| clazz.isAbstractClass)) subHierarchy(clazz)++ result
104+
elseif (clazz.isSealed&& (clazz.isTrait|| clazz.isAbstract)) subHierarchy(clazz)++ result
103105
else c.abort(c.enclosingPosition,"A class hierarchy may only contain case classes, sealed traits and sealed abstract classes")
104106
}
105107
}
106108

107109
subHierarchy(rootClass)
108-
.sortBy(_.name.decoded)
110+
.sortBy(_.name.decodedName.toString)
109111
.ensuring(_.nonEmpty,s"Oops: whole hierarchy of$rootClass is empty")
110112
}
111113

@@ -122,14 +124,14 @@ object AdtsImpl {
122124
objectMember {
123125
defapply(symbol:Symbol)= {
124126
// Trim because case classes members introduce a trailing space
125-
valnameStr= symbol.name.decoded.trim
126-
newMember(nameStr,newTermName(nameStr), symbol.typeSignature)
127+
valnameStr= symbol.name.decodedName.toString.trim
128+
newMember(nameStr,TermName(nameStr), symbol.typeSignature)
127129
}
128130
}
129131

130132
/**@return The members of the type `tpe`*/
131133
deflistMembers(tpe:Type):List[Member]=
132-
tpe.typeSymbol.typeSignature.declarations.toList.collect {casex:TermSymbolif x.isVal&& x.isCaseAccessor=>Member(x) }
134+
tpe.typeSymbol.typeSignature.decls.toList.collect {casex:TermSymbolif x.isVal&& x.isCaseAccessor=>Member(x) }
133135

134136
/**
135137
* Expands to a value providing staged operations on algebraic data types.
@@ -159,17 +161,17 @@ object AdtsImpl {
159161
*/
160162
// TODO Simplify the expansion
161163
defops[U<:Adt: c.WeakTypeTag,R[_]](obj: c.Expr[R[U]])= {
162-
valanon=newTypeName(c.fresh)
163-
valwrapper=newTypeName(c.fresh)
164-
valctor=newTermName(c.fresh)
164+
valanon=TypeName(c.freshName)
165+
valwrapper=TypeName(c.freshName)
166+
valctor=TermName(c.freshName)
165167

166168
valU= weakTypeOf[U]
167169
valmembers= listMembers(U)
168170
if (!U.typeSymbol.isClass) {
169171
c.abort(c.enclosingPosition,s"$U must be a sealed trait, an abstract class or a case class")
170172
}
171173
valtypeSymbol=U.typeSymbol.asClass
172-
if (!(typeSymbol.isCaseClass|| (typeSymbol.isSealed&& (typeSymbol.isTrait|| typeSymbol.isAbstractClass)))) {
174+
if (!(typeSymbol.isCaseClass|| (typeSymbol.isSealed&& (typeSymbol.isTrait|| typeSymbol.isAbstract)))) {
173175
c.abort(c.enclosingPosition,s"$U must be a sealed trait, an abstract class or a case class")
174176
}
175177

@@ -216,7 +218,7 @@ object AdtsImpl {
216218
}
217219
"""
218220

219-
valvariants2= wholeHierarchy[U].filter(_.isCaseClass).map(s=> s->newTermName(c.fresh()))
221+
valvariants2= wholeHierarchy[U].filter(_.isCaseClass).map(s=> s->TermName(c.freshName))
220222

221223
valparamsFold=for((param, symbol)<- variants2)yieldq"val$symbol: (Rep[$param] => Rep[A])"
222224

@@ -266,7 +268,7 @@ object AdtsImpl {
266268
valU= weakTypeOf[U]
267269
if (U.typeSymbol.asClass.isCaseClass) {
268270
valmembers= listMembers(U)
269-
valobjName=U.typeSymbol.name
271+
valobjName:c.TypeName=U.typeSymbol.name.asInstanceOf[c.TypeName]
270272
valparamsDef=for(member<- members)yieldq"val${member.term}: Rep[${member.tpe}]"
271273
valparamsConstruct=for(member<- members)yieldq"${member.name} ->${member.term}"
272274
valparamsType=for(member<- members)yieldtq"Rep[${member.tpe}]"
@@ -278,7 +280,7 @@ object AdtsImpl {
278280
}
279281
}
280282
q"""
281-
new${newTypeName("Function"+ paramsType.length)}[..$paramsType, Rep[$objName]] {
283+
new${TypeName("Function"+ paramsType.length)}[..$paramsType, Rep[$objName]] {
282284
def apply(..$paramsDef) = adt_construct[$objName](..$allParams)
283285
}
284286
"""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp