Skip to content

Commit

Permalink
changed much stub
Browse files Browse the repository at this point in the history
  • Loading branch information
jrudolph committed Oct 2, 2008
1 parent 5e6c98b commit 1893de7
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 41 deletions.
4 changes: 3 additions & 1 deletion eclipse/EvaluateSpecs.launch
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="scala.application">
<stringAttribute key="bad_container_name" value="/objectformatter/eclips"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
Expand All @@ -7,6 +7,8 @@
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.maven.ide.eclipse.launchconfig.classpathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="net.virtualvoid.string.EvaluateSpecs"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="objectformatter"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.maven.ide.eclipse.launchconfig.sourcepathProvider"/>
</launchConfiguration>
4 changes: 3 additions & 1 deletion eclipse/ParserSpecs.launch
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration type="scala.application">
<stringAttribute key="bad_container_name" value="/objectformatter/eclips"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
Expand All @@ -7,6 +7,8 @@
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.maven.ide.eclipse.launchconfig.classpathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="net.virtualvoid.string.ParserSpecs"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="objectformatter"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.maven.ide.eclipse.launchconfig.sourcepathProvider"/>
</launchConfiguration>
78 changes: 39 additions & 39 deletions src/main/scala/net/virtualvoid/string/FormatCompiler.scala
Expand Up @@ -23,10 +23,10 @@ object Compiler{
case p@ParentExp(inner,parent) =>{
val m = p.method(cl)
f.dynMethod(m,classOf[AnyRef]) ~
(compileGetExp(inner,m.getReturnType.asInstanceOf[Class[Object]],retType))
compileGetExp(inner,m.getReturnType.asInstanceOf[Class[Object]],retType)
}
case ThisExp =>
f.checkcast(retType) // TODO: don't know why we need this, examine it
f.~(checkcast(retType)) // TODO: don't know why we need this, examine it
case e:Exp => {
f.dynMethod(e.method(cl),retType)
}
Expand All @@ -36,45 +36,45 @@ object Compiler{
= tok match {
case Literal(str) => f.ldc(str).method2(_.append(_))
case e:Exp =>
(f.l.load.e
~ compileGetExp(e,cl,classOf[AnyRef])
~ method(_.toString))
.method2(_.append(_))
f ~ (_.l.load.e) ~
compileGetExp(e,cl,classOf[AnyRef]) ~
method(_.toString) ~
method2(_.append(_))
case SpliceExp(exp,sep,inner) => {
val retType = exp.returnType(cl)

if (classOf[java.lang.Iterable[_]].isAssignableFrom(retType)){
val eleType:Class[AnyRef] = elementType(exp.genericReturnType(cl)).asInstanceOf[Class[AnyRef]]
val jmpTarget =
f.l.load.e
.swap // save one instance of T for later
.l.load.e
.~(compileGetExp(exp,cl,classOf[java.lang.Iterable[AnyRef]]))
.method(_.iterator)
.l.store.e
.target
jmpTarget
.l.load.e
.method(_.hasNext)
.ifeq(f=>
f.l.load.e
.swap
.l.load.e
.method(_.next)
.checkcast(eleType)
.l.store.e
.~(compileToks(inner,eleType))
.swap
.dup
.l.store.e
.method(_.hasNext)
.ifeq(f =>
f.ldc(sep:jString)
.method2(_.append(_))
.jmp(jmpTarget)) //todo: introduce ifeq(thenCode,elseTarget)
.jmp(jmpTarget))
.swap
.l.store.e
f ~ (_.l.load.e) ~
swap ~ // save one instance of T for later
(_.l.load.e) ~
compileGetExp(exp,cl,classOf[java.lang.Iterable[AnyRef]]) ~
method(_.iterator) ~
(_.l.store.e) ~
target
jmpTarget ~
(_.l.load.e) ~
method(_.hasNext) ~
ifeq(f =>
f.l.load.e ~
swap ~
(_.l.load.e) ~
method(_.next) ~
checkcast(eleType) ~
(_.l.store.e) ~
compileToks(inner,eleType) ~
swap ~
dup ~
(_.l.store.e) ~
method(_.hasNext) ~
ifeq(f =>
f~ldc(sep:jString) ~
method2(_.append(_)) ~
jmp(jmpTarget)) ~ //todo: introduce ifeq(thenCode,elseTarget)
jmp(jmpTarget)) ~
swap ~
(_.l.store.e)
}
else if (retType.isArray){
val eleType:Class[AnyRef] = retType.getComponentType.asInstanceOf[Class[AnyRef]]
Expand All @@ -97,7 +97,7 @@ object Compiler{
.arraylength
.swap
.isub
.ifeq(f =>
.~(ifeq(f =>
f.dup_x1
.l.load.e
.swap
Expand All @@ -116,15 +116,15 @@ object Compiler{
.l.load.e
.arraylength
.isub
.ifeq(f=>
.~(ifeq(f =>
f.swap
.ldc(sep)
.method2(_.append(_))
.swap
.jmp(jmpTarget)
)
))
.jmp(jmpTarget)
)
))
.pop
.swap
.l.store.e
Expand Down

0 comments on commit 1893de7

Please sign in to comment.