use of org.develnext.jphp.core.tokenizer.token.expr.ValueExprToken in project jphp by jphp-compiler.
the class StringBuilderValueCompiler method writeBuilder.
public void writeBuilder(List<Token> tokens, boolean binary) {
expr.writePushNewObject(StringBuilder.class);
for (Token el : tokens) {
//writePushDup();
if (el instanceof ValueExprToken) {
expr.writePush((ValueExprToken) el, true, false);
} else if (el instanceof ExprStmtToken) {
//unexpectedToken(el);
expr.writeExpression((ExprStmtToken) el, true, false, true);
} else
expr.unexpectedToken(el);
StackItem.Type peek = expr.stackPeek().type;
if (!peek.isConstant()) {
expr.writeSysDynamicCall(StringBuilder.class, "append", StringBuilder.class, Object.class);
} else
expr.writeSysDynamicCall(StringBuilder.class, "append", StringBuilder.class, peek.toClass());
}
expr.writeSysDynamicCall(StringBuilder.class, "toString", String.class);
if (binary) {
expr.writeSysStaticCall(BinaryMemory.class, "valueOf", Memory.class, String.class);
}
}
use of org.develnext.jphp.core.tokenizer.token.expr.ValueExprToken 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