use of php.runtime.reflection.ConstantEntity in project jphp by jphp-compiler.
the class ConstantDumper method load.
@Override
public ConstantEntity load(InputStream input) throws IOException {
DumpInputStream dump = new DumpInputStream(input);
boolean cs = dump.readBoolean();
Modifier modifier = dump.readModifier();
String name = dump.readName();
TraceInfo trace = dump.readTrace(context);
Memory value = dump.readMemory();
ConstantEntity entity = new ConstantEntity(name, value, cs);
entity.setContext(context);
entity.setTrace(trace);
dump.readRawData();
return entity;
}
use of php.runtime.reflection.ConstantEntity in project jphp by jphp-compiler.
the class ModuleDumper method load.
@Override
public ModuleEntity load(InputStream input) throws IOException {
DumpInputStream data = new DumpInputStream(input);
int STAMP = data.readInt();
if (STAMP != DUMP_STAMP)
throw new DumpException("Invalid file format");
int VERSION = data.readInt();
if (VERSION != DUMP_VERSION)
throw new DumpException("Invalid dump version - " + VERSION + ", only " + DUMP_VERSION);
// legacy
data.readLangMode();
ModuleEntity entity = new ModuleEntity(context);
entity.setName(data.readName());
entity.setInternalName(data.readName());
entity.setTrace(data.readTrace(context));
// constants
int count = data.readInt();
for (int i = 0; i < count; i++) {
ConstantEntity el = constantDumper.load(input);
el.setModule(entity);
entity.addConstant(el);
}
// closures
count = data.readInt();
for (int i = 0; i < count; i++) {
ClosureEntity el = closureDumper.load(input);
el.setModule(entity);
entity.addClosure(el);
}
count = data.readInt();
for (int i = 0; i < count; i++) {
GeneratorEntity el = generatorDumper.load(input);
el.setModule(entity);
entity.addGenerator(el);
}
// functions
count = data.readInt();
for (int i = 0; i < count; i++) {
FunctionEntity el = functionDumper.load(input);
el.setModule(entity);
entity.addFunction(el);
}
// classes
count = data.readInt();
ClassDumper classDumper = new ClassDumper(context, entity, env, debugInformation);
for (int i = 0; i < count; i++) {
ClassEntity el = classDumper.load(input);
el.setModule(entity);
entity.addClass(el);
}
// byte code
entity.setData(data.readRawData(Integer.MAX_VALUE));
data.readRawData(1024 * 1024 * 5);
return entity;
}
use of php.runtime.reflection.ConstantEntity in project jphp by jphp-compiler.
the class InfoFunctions method get_defined_constants.
public static Memory get_defined_constants(Environment env, boolean capitalize) {
Set<String> exists = new HashSet<String>();
ArrayMemory result = new ArrayMemory();
for (String ext : env.scope.getExtensions()) {
Extension extension = env.scope.getExtension(ext);
ArrayMemory item = result;
if (capitalize)
item = (ArrayMemory) result.refOfIndex(ext).assign(new ArrayMemory());
for (CompileConstant constant : extension.getConstants().values()) {
item.put(constant.name, constant.value);
exists.add(constant.name);
}
}
ArrayMemory item = result;
if (capitalize)
item = (ArrayMemory) result.refOfIndex("user").assign(new ArrayMemory());
for (ConstantEntity constant : env.scope.getConstants()) {
if (!exists.contains(constant.getName()))
item.put(constant.getName(), constant.getValue());
}
for (ConstantEntity constant : env.getConstants().values()) {
if (!exists.contains(constant.getName()))
item.put(constant.getName(), constant.getValue());
}
return result;
}
Aggregations