Skip to content

Instantly share code, notes, and snippets.

@abstractj
Created February 14, 2012 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abstractj/1831357 to your computer and use it in GitHub Desktop.
Save abstractj/1831357 to your computer and use it in GitHub Desktop.
forIterVar
java.lang.NegativeArraySizeException
at me.qmx.internal.org.objectweb.asm.Frame.a(Unknown Source)
at me.qmx.internal.org.objectweb.asm.MethodWriter.visitMaxs(Unknown Source)
at me.qmx.internal.org.objectweb.asm.tree.MethodNode.accept(Unknown Source)
at me.qmx.internal.org.objectweb.asm.tree.MethodNode.accept(Unknown Source)
at me.qmx.internal.org.objectweb.asm.tree.ClassNode.accept(Unknown Source)
at me.qmx.jitescript.JiteClass.toBytes(JiteClass.java:92)
at org.dynjs.compiler.DynJSCompiler.defineClass(DynJSCompiler.java:124)
at org.dynjs.compiler.DynJSCompiler.compile(DynJSCompiler.java:114)
at org.dynjs.runtime.DynJS.execute(DynJS.java:92)
at org.dynjs.runtime.DynJS.eval(DynJS.java:52)
at org.dynjs.runtime.DynJSTestRunner.run(DynJSTestRunner.java:83)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:71)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
/**
* Copyright 2011 Douglas Campos
* Copyright 2011 dynjs contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dynjs.parser.statement;
import me.qmx.jitescript.CodeBlock;
import org.dynjs.parser.Statement;
import org.dynjs.runtime.RT;
import static me.qmx.jitescript.CodeBlock.newCodeBlock;
import static me.qmx.jitescript.util.CodegenUtils.p;
import static me.qmx.jitescript.util.CodegenUtils.sig;
public class ForIterVarStatement implements Statement {
private Statement varDef;
private Statement expr1;
private BlockStatement statement;
public ForIterVarStatement(Statement varDef, Statement expr1, Statement statement) {
this.varDef = varDef;
this.expr1 = expr1;
this.statement = (BlockStatement) statement;
}
@Override
public CodeBlock getCodeBlock() {
return newCodeBlock()
.append(varDef.getCodeBlock())
.label(statement.getBeginLabel())
.invokedynamic("dynjs:convert:to_boolean", sig(Boolean.class, Object.class), RT.BOOTSTRAP, RT.BOOTSTRAP_ARGS)
.invokevirtual(p(Boolean.class), "booleanValue", sig(boolean.class))
.iffalse(statement.getEndLabel())
.append(statement.getCodeBlock())
.append(expr1.getCodeBlock())
.go_to(statement.getBeginLabel())
.label(statement.getEndLabel());
//TODO missing implementation
}
}
public Statement forIterVar(Statement varDef, Statement expr1, Statement statement) {
return new ForIterVarStatement(varDef, expr1, statement);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment