use of php.runtime.ext.support.compile.CompileFunctionSpec 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.compile.CompileFunctionSpec in project jphp by jphp-compiler.
the class CompileScope method findCompileFunction.
public CompileFunction findCompileFunction(String name) {
name = name.toLowerCase();
CompileFunction function = compileFunctionMap.get(name);
if (function != null) {
return function;
}
synchronized (this) {
CompileFunctionSpec functionSpec = compileFunctionSpecMap.get(name);
if (functionSpec == null) {
return null;
}
compileFunctionMap.put(name, function = functionSpec.toFunction());
}
return function;
}
Aggregations