use of org.develnext.jphp.core.compiler.common.misc.StackItem in project jphp by jphp-compiler.
the class ExpressionStmtCompiler method writePushDup.
public void writePushDup() {
StackItem item = method.peek();
stackPush(item);
if (item.type.size() == 2)
code.add(new InsnNode(DUP2));
else
code.add(new InsnNode(DUP));
}
use of org.develnext.jphp.core.compiler.common.misc.StackItem in project jphp by jphp-compiler.
the class MethodStmtCompiler method pop.
StackItem pop() {
StackItem item = stack.pop();
stackSize -= item.size;
return item;
}
use of org.develnext.jphp.core.compiler.common.misc.StackItem in project jphp by jphp-compiler.
the class ExpressionStmtCompiler method writeDynamicAccessPrepare.
public void writeDynamicAccessPrepare(DynamicAccessExprToken dynamic, boolean addLowerName) {
if (stackEmpty(true))
unexpectedToken(dynamic);
StackItem o = stackPop();
writePush(o);
if (stackPeek().isConstant())
unexpectedToken(dynamic);
writePopBoxing();
if (dynamic instanceof DynamicAccessAssignExprToken) {
if (((DynamicAccessAssignExprToken) dynamic).getValue() != null) {
writeExpression(((DynamicAccessAssignExprToken) dynamic).getValue(), true, false);
writePopBoxing(true);
}
}
writeDynamicAccessInfo(dynamic, addLowerName);
}
use of org.develnext.jphp.core.compiler.common.misc.StackItem in project jphp by jphp-compiler.
the class ExpressionStmtCompiler method writeArrayGet.
void writeArrayGet(ArrayGetExprToken operator, boolean returnValue) {
StackItem o = stackPeek();
ValueExprToken L = null;
if (o.getToken() != null) {
stackPop();
writePush(L = o.getToken(), true, false);
writePopBoxing();
}
String methodName = operator instanceof ArrayGetRefExprToken ? "refOfIndex" : "valueOfIndex";
boolean isShortcut = operator instanceof ArrayGetRefExprToken && ((ArrayGetRefExprToken) operator).isShortcut();
int i = 0;
int size = operator.getParameters().size();
int traceIndex = createTraceInfo(operator);
for (ExprStmtToken param : operator.getParameters()) {
// push dup trace
writePushTraceInfo(traceIndex);
writeExpression(param, true, false);
if (operator instanceof ArrayGetUnsetExprToken && i == size - 1) {
writePopBoxing();
writeSysDynamicCall(Memory.class, "unsetOfIndex", void.class, TraceInfo.class, stackPeek().type.toClass());
if (returnValue)
writePushNull();
} else if (operator instanceof ArrayGetIssetExprToken && i == size - 1) {
writePopBoxing();
writeSysDynamicCall(Memory.class, "issetOfIndex", Memory.class, TraceInfo.class, stackPeek().type.toClass());
} else if (operator instanceof ArrayGetEmptyExprToken && i == size - 1) {
writePopBoxing();
writeSysDynamicCall(Memory.class, "emptyOfIndex", Memory.class, TraceInfo.class, stackPeek().type.toClass());
} else {
// TODO: Remove.
// PHP CMP: $hack = &$arr[0];
// boolean isMemory = stackPeek().type.toClass() == Memory.class;
// if (isMemory)
/*if (compiler.isPhpMode()){
if (i == size - 1 && isShortcut){
writePopBoxing();
writeSysDynamicCall(Memory.class, methodName + "AsShortcut", Memory.class, TraceInfo.class, Memory.class);
continue;
}
}*/
writeSysDynamicCall(Memory.class, methodName, Memory.class, TraceInfo.class, stackPeek().type.toClass());
i++;
}
}
}
Aggregations