use of php.runtime.loader.dump.io.DumpInputStream in project jphp by jphp-compiler.
the class PropertyDumper method load.
@Override
public PropertyEntity load(InputStream input) throws IOException {
PropertyEntity property = new PropertyEntity(context);
DumpInputStream data = new DumpInputStream(input);
String docComment = data.readUTF();
if (!docComment.isEmpty()) {
property.setDocComment(new DocumentComment(docComment));
}
property.setStatic(data.readBoolean());
property.setModifier(data.readModifier());
property.setName(data.readName());
property.setTrace(data.readTrace(context));
// typed
property.setNullable(data.readBoolean());
property.setType(data.readHintType());
String typeClass = data.readName();
if (typeClass != null && !typeClass.isEmpty()) {
property.setTypeClass(typeClass);
}
property.setDefault(data.readBoolean());
property.setDefaultValue(data.readMemory());
byte[] raw = data.readRawData();
return property;
}
use of php.runtime.loader.dump.io.DumpInputStream in project jphp by jphp-compiler.
the class StandaloneLibraryDumper method load.
public StandaloneLibrary load(InputStream input) throws IOException {
StandaloneLibrary library = new StandaloneLibrary();
DumpInputStream data = new DumpInputStream(input);
String hash = data.readName();
if (!HASH.equals(hash)) {
throw new DumpException("Invalid standalone modules, invalid hash");
}
String coreVersion = data.readName();
String likePhpVersion = data.readName();
library.setCoreVersion(coreVersion);
library.setLikePhpVersion(likePhpVersion);
int count = data.readInt();
for (int i = 0; i < count; i++) {
String name = data.readName();
String internalName = data.readName();
// classes
int classesSize = data.readInt();
Set<String> classes = new HashSet<>();
for (int j = 0; j < classesSize; j++) {
classes.add(data.readName());
}
// functions
int functionsSize = data.readInt();
Set<String> functions = new HashSet<>();
for (int j = 0; j < functionsSize; j++) {
functions.add(data.readName());
}
// constants
int constantSize = data.readInt();
Set<String> constants = new HashSet<>();
for (int j = 0; j < constantSize; j++) {
constants.add(data.readName());
}
StandaloneLibrary.Module module = new StandaloneLibrary.Module(name, internalName, classes, functions, constants);
library.addModule(module);
}
return library;
}
use of php.runtime.loader.dump.io.DumpInputStream in project jphp by jphp-compiler.
the class GeneratorDumper method load.
@Override
public GeneratorEntity load(InputStream input) throws IOException {
GeneratorEntity entity = classDumper.load(input, GeneratorEntity.class);
DumpInputStream data = new DumpInputStream(input);
entity.setReturnReference(data.readBoolean());
int paramCount = data.readInt();
if (paramCount < 0)
throw new DumpException("Invalid param count");
entity.parameters = new ParameterEntity[paramCount];
for (int i = 0; i < paramCount; i++) {
ParameterEntity param = parameterDumper.load(input);
param.setTrace(entity.getTrace());
entity.parameters[i] = param;
}
return entity;
}
use of php.runtime.loader.dump.io.DumpInputStream in project jphp by jphp-compiler.
the class MethodDumper method load.
@Override
public MethodEntity load(InputStream input) throws IOException {
DumpInputStream data = new DumpInputStream(input);
MethodEntity entity = new MethodEntity(context);
String docComment = data.readUTF();
if (!docComment.isEmpty()) {
entity.setDocComment(new DocumentComment(docComment));
}
// static
entity.setStatic(data.readBoolean());
// final
entity.setFinal(data.readBoolean());
// abstract
entity.setAbstract(data.readBoolean());
entity.setAbstractable(data.readBoolean());
entity.setImmutable(data.readBoolean());
entity.setResult(data.readMemory());
entity.setEmpty(data.readBoolean());
// ref
entity.setReturnReference(data.readBoolean());
// type hinting
entity.setReturnType(data.readHintType());
String returnTypeClass = data.readName();
if (returnTypeClass != null && !returnTypeClass.isEmpty()) {
entity.setReturnTypeClass(returnTypeClass);
}
entity.setReturnTypeNullable(data.readBoolean());
// uses stack trace
entity.setUsesStackTrace(data.readBoolean());
// modifier
entity.setModifier(data.readModifier());
// name
entity.setName(data.readName());
entity.setInternalName(data.readName());
// trace
entity.setTrace(data.readTrace(context));
int paramCount = data.readInt();
if (paramCount < 0)
throw new DumpException("Invalid param count");
entity.setParameters(new ParameterEntity[paramCount]);
for (int i = 0; i < paramCount; i++) {
ParameterEntity param = parameterDumper.load(input);
param.setTrace(entity.getTrace());
entity.getParameters()[i] = param;
}
data.readRawData();
return entity;
}
use of php.runtime.loader.dump.io.DumpInputStream in project jphp by jphp-compiler.
the class ClosureDumper method load.
@Override
public ClosureEntity load(InputStream input) throws IOException {
DumpInputStream data = new DumpInputStream(input);
ClosureEntity entity = new ClosureEntity(context);
entity.setParent(env.scope.fetchUserClass(Closure.class));
entity.setInternalName(data.readName());
entity.setReturnReference(data.readBoolean());
entity.methodMagicInvoke = methodDumper.load(input);
entity.methodMagicInvoke.setClazz(entity);
entity.addMethod(entity.methodMagicInvoke, null);
int paramCount = data.readInt();
if (paramCount < 0)
throw new DumpException("Invalid param count");
entity.parameters = new ParameterEntity[paramCount];
for (int i = 0; i < paramCount; i++) {
ParameterEntity param = parameterDumper.load(input);
param.setTrace(entity.getTrace());
entity.parameters[i] = param;
}
paramCount = data.readInt();
if (paramCount < 0)
throw new DumpException("Invalid param count");
entity.uses = new ParameterEntity[paramCount];
for (int i = 0; i < paramCount; i++) {
ParameterEntity param = parameterDumper.load(input);
param.setTrace(entity.getTrace());
entity.uses[i] = param;
}
entity.setData(data.readRawData(Integer.MAX_VALUE));
return entity;
}
Aggregations