use of org.develnext.jphp.core.tokenizer.token.expr.value.GetVarExprToken in project jphp by jphp-compiler.
the class UnsetCompiler method write.
@Override
public void write(UnsetExprToken token, boolean returnValue) {
method.getEntity().setImmutable(false);
for (ExprStmtToken param : token.getParameters()) {
if (param.isSingle() && param.getSingle() instanceof VariableExprToken) {
VariableExprToken variable = (VariableExprToken) param.getSingle();
expr.checkAssignableVar(variable);
LocalVariable local = method.getLocalVariable(variable.getName());
expr.writeVarLoad(local);
expr.writePushEnv();
expr.writeSysDynamicCall(Memory.class, "manualUnset", void.class, Environment.class);
if (!local.isReference()) {
expr.writePushNull();
expr.writeVarAssign(local, null, false, false);
}
local.setValue(null);
} else if (param.isSingle() && param.getSingle() instanceof GetVarExprToken) {
expr.writeValue((ValueExprToken) param.getSingle(), true);
expr.writePushEnv();
expr.writeSysDynamicCall(Memory.class, "manualUnset", void.class, Environment.class);
} else {
expr.writeExpression(param, false, false, true);
}
}
if (returnValue)
expr.writePushNull();
}
use of org.develnext.jphp.core.tokenizer.token.expr.value.GetVarExprToken in project jphp by jphp-compiler.
the class GlobalDefinitionCompiler method write.
@Override
public void write(GlobalStmtToken token) {
for (ValueExprToken variable : token.getVariables()) {
if (variable instanceof VariableExprToken) {
LocalVariable local = method.getLocalVariable(((VariableExprToken) variable).getName());
assert local != null;
expr.writePushEnv();
expr.writePushConstString(local.name);
expr.writeSysDynamicCall(Environment.class, "getOrCreateGlobal", Memory.class, String.class);
expr.writeVarStore(local, false, false);
} else if (variable instanceof GetVarExprToken) {
BaseExprCompiler<GetVarExprToken> compiler = (BaseExprCompiler<GetVarExprToken>) expr.getCompiler(GetVarExprToken.class);
if (compiler == null)
throw new CriticalException("Cannot find a valid compiler for " + GetVarExprToken.class.getName());
compiler.write((GetVarExprToken) variable, true);
expr.writePushEnv();
Memory name = expr.writeExpression(((GetVarExprToken) variable).getName(), true, true, true);
if (name != null) {
expr.writePushConstString(name.toString());
} else {
expr.writePopString();
}
expr.writeSysDynamicCall(Environment.class, "getOrCreateGlobal", Memory.class, String.class);
expr.writeSysDynamicCall(Memory.class, "assign", Memory.class, Memory.class);
expr.writePopAll(1);
}
}
}
Aggregations