Search in sources :

Example 1 with StaticExprToken

use of org.develnext.jphp.core.tokenizer.token.expr.value.StaticExprToken in project jphp by jphp-compiler.

the class NewValueCompiler method write.

@Override
public void write(NewExprToken token, boolean returnValue) {
    method.getEntity().setImmutable(false);
    expr.writeLineNumber(token);
    expr.writePushEnv();
    if (token.isDynamic()) {
        Memory className = expr.writeExpression(token.getExprName(), true, true, false);
        if (className != null) {
            expr.writePushConstString(className.toString());
            expr.writePushConstString(className.toString().toLowerCase());
        } else {
            expr.writeExpression(token.getExprName(), true, false);
            expr.writePopString();
            expr.writePushDupLowerCase();
        }
    } else {
        if (token.getName() instanceof StaticExprToken) {
            expr.writePushStatic();
            expr.writePushDupLowerCase();
        } else if (token.getName() instanceof SelfExprToken) {
            expr.writePushEnv();
            expr.writeSysDynamicCall(Environment.class, "__getMacroClass", Memory.class);
            expr.writePopString();
            expr.writePushDupLowerCase();
        } else {
            FulledNameToken name = (FulledNameToken) token.getName();
            expr.writePushString(name.getName());
            expr.writePushString(name.getName().toLowerCase());
        }
    }
    expr.writePushTraceInfo(token);
    expr.writePushParameters(token.getParameters());
    expr.writeSysDynamicCall(Environment.class, "__newObject", Memory.class, String.class, String.class, TraceInfo.class, Memory[].class);
    expr.setStackPeekAsImmutable();
    if (!returnValue)
        expr.writePopAll(1);
}
Also used : Memory(php.runtime.Memory) StaticExprToken(org.develnext.jphp.core.tokenizer.token.expr.value.StaticExprToken) Environment(php.runtime.env.Environment) SelfExprToken(org.develnext.jphp.core.tokenizer.token.expr.value.SelfExprToken) FulledNameToken(org.develnext.jphp.core.tokenizer.token.expr.value.FulledNameToken)

Aggregations

FulledNameToken (org.develnext.jphp.core.tokenizer.token.expr.value.FulledNameToken)1 SelfExprToken (org.develnext.jphp.core.tokenizer.token.expr.value.SelfExprToken)1 StaticExprToken (org.develnext.jphp.core.tokenizer.token.expr.value.StaticExprToken)1 Memory (php.runtime.Memory)1 Environment (php.runtime.env.Environment)1