use of php.runtime.ext.support.Extension in project jphp by jphp-compiler.
the class CompileScope method registerExtension.
public void registerExtension(Extension extension) {
long t = System.currentTimeMillis();
if (extensions.containsKey(extension.getName()))
return;
// required
for (String dep : extension.getRequiredExtensions()) {
try {
Extension el = (Extension) Class.forName(dep).newInstance();
registerExtension(el);
} catch (Exception e) {
throw new CriticalException(e);
}
}
// optional
for (String dep : extension.getOptionalExtensions()) {
try {
Extension el = (Extension) Class.forName(dep).newInstance();
registerExtension(el);
} catch (ClassNotFoundException e) {
// do nothing ...
} catch (Exception e) {
throw new CriticalException(e);
}
}
// conflicts
for (String dep : extension.getConflictExtensions()) {
if (extensions.containsKey(dep))
throw new ConflictException("'" + dep + "' extension conflicts with '" + extension.getClass().getName() + "'");
}
extension.onRegister(this);
compileConstantMap.putAll(extension.getConstants());
compileFunctionSpecMap.putAll(extension.getFunctions());
for (Class<?> clazz : extension.getClasses().values()) {
registerLazyClass(extension, clazz);
}
for (CompileFunctionSpec function : extension.getFunctions().values()) {
functionMap.put(function.getLowerName(), new CompileFunctionEntity(extension, function));
}
extensions.put(extension.getName().toLowerCase(), extension);
if (Startup.isTracing()) {
Startup.traceWithTime("Register extension '" + extension.getName() + "'", t);
}
}
use of php.runtime.ext.support.Extension in project jphp by jphp-compiler.
the class ReflectionFunctionAbstract method getExtension.
@Signature
public Memory getExtension(Environment env, Memory... args) {
if (getClosureEntity() != null)
return Memory.NULL;
Extension extension = getEntity().getExtension();
if (extension == null)
return Memory.NULL;
else {
ReflectionExtension ext = new ReflectionExtension(env, env.fetchClass("ReflectionExtension"));
ext.setExtension(extension);
return new ObjectMemory(ext);
}
}
use of php.runtime.ext.support.Extension 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