本文整理了Java中php.runtime.env.Environment.getScope()
方法的一些代码示例,展示了Environment.getScope()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Environment.getScope()
方法的具体详情如下:
包路径:php.runtime.env.Environment
类名称:Environment
方法名:getScope
暂无
代码示例来源:origin: jphp-group/jphp
public AbstractCompiler(Environment environment, Context context){
this.context = context;
this.scope = environment.getScope();
this.environment = environment;
}
代码示例来源:origin: jphp-group/jphp
@Signature
public Set<String> getSuperGlobals() {
return environment.getScope().superGlobals;
}
代码示例来源:origin: jphp-group/jphp
@Signature
public static void addClassPath(Environment env, File file) throws IOException {
try {
env.getScope().getClassLoader().addLibrary(file.toURI().toURL());
} catch (Throwable t) {
throw new IOException("Error, could not add URL to system classloader, " + t.getMessage());
}
}
}
代码示例来源:origin: jphp-group/jphp
@Signature(@Arg("name"))
public Memory hasSuperGlobal(Environment env, Memory... args) {
return environment.getScope().superGlobals.contains(args[0].toString()) ? Memory.TRUE : Memory.FALSE;
}
代码示例来源:origin: jphp-group/jphp
@Signature(@Arg("name"))
public static Memory exists(Environment env, Memory... args) throws IOException {
String name = args[0].toString();
if (name.startsWith("res:///")) {
name = name.substring(7);
} else if (name.startsWith("res://")) {
name = name.substring(6);
}
return env.getScope().getClassLoader().getResource(name) == null ? Memory.FALSE : Memory.TRUE;
}
代码示例来源:origin: jphp-group/jphp
@Override
@Signature({@Arg("path")})
public Memory __construct(Environment env, Memory... args) throws IOException {
super.__construct(env, args[0], StringMemory.valueOf("r"));
//long t = System.currentTimeMillis();
String path = this.getPath().replace('\\', '/').replace("//", "/");
if (path.startsWith("/")) {
path = path.substring(1);
}
setPath("res://" + path);
url = env.getScope().getClassLoader().getResource(path);
if (url == null) {
throw new IOException("Resource not found - " + getPath());
}
stream = url.openStream();
//System.err.println(path + ", time = " + (System.currentTimeMillis() - t));
return Memory.NULL;
}
代码示例来源:origin: jphp-group/jphp
@Signature(@Arg("name"))
public static Memory getResources(Environment env, Memory... args) throws IOException {
Enumeration<URL> list = env.getScope().getClassLoader().getResources(args[0].toString());
ArrayMemory r = new ArrayMemory();
while (list.hasMoreElements()) {
URL url = list.nextElement();
if (url != null) {
ResourceStream rs = new ResourceStream(env, url.openStream());
rs.setPath("res://" + args[0]);
r.add(rs);
}
}
return r.toConstant();
}
}
代码示例来源:origin: jphp-group/jphp
@Signature({
@Arg("name"), @Arg(value = "value", optional = @Optional("null"))
})
public Memory addSuperGlobal(Environment env, Memory... args) {
if (hasSuperGlobal(env, args[0]).toBoolean()) {
environment.exception("Super-global variable $%s already exists", args[0]);
}
environment.getScope().superGlobals.add(args[0].toString());
environment.getGlobals().putAsKeyString(args[0].toString(), args[1].toImmutable());
return Memory.UNDEFINED;
}
代码示例来源:origin: jphp-group/jphp
public static Memory getValue(Debugger context, String value) {
DebugTick tick = context.getRegisteredTick();
Environment environment = new Environment(new CompileScope(tick.getEnvironment().getScope()));
try {
return LangFunctions.eval(environment, tick.getTrace(), tick.getLocals(), "return " + value + ";");
} catch (Throwable throwable) {
return null;
}
}
代码示例来源:origin: jphp-group/jphp
@SuppressWarnings("unchecked")
protected Memory includeResource(String name, ArrayMemory globals){
ByteArrayOutputStream output = new ByteArrayOutputStream();
Environment environment;
if (isConcurrent()) {
environment = new ConcurrentEnvironment(newScope(), output);
} else {
environment = new Environment(newScope(), output);
}
File file = new File(Thread.currentThread().getContextClassLoader().getResource("resources/" + name).getFile());
Context context = new Context(file);
JvmCompiler compiler = new JvmCompiler(environment, context, getSyntax(context));
ModuleEntity module = compiler.compile();
environment.getScope().loadModule(module);
try {
environment.registerModule(module);
} catch (Throwable throwable) {
throw new RuntimeException(throwable);
}
if (globals != null)
environment.getGlobals().putAll(globals);
Memory memory = module.includeNoThrow(environment, environment.getGlobals());
try {
environment.doFinal();
} catch (Throwable throwable) {
throw new RuntimeException(throwable);
}
lastOutput = output.toString();
return memory;
}
代码示例来源:origin: jphp-group/jphp
protected Memory runDynamic(String code, boolean returned){
runIndex += 1;
Environment environment = new Environment(newScope());
code = (returned ? "return " : "") + code + ";";
Context context = new Context(code);
JvmCompiler compiler = new JvmCompiler(environment, context, getSyntax(context));
ModuleEntity module = compiler.compile();
environment.getScope().loadModule(module);
try {
environment.registerModule(module);
} catch (Throwable throwable) {
throw new RuntimeException(throwable);
}
return module.includeNoThrow(environment);
}
代码示例来源:origin: jphp-group/jphp
protected Memory run(String code, boolean returned){
runIndex += 1;
Environment environment = new Environment(newScope());
code = "class TestClass { static function test(){ " + (returned ? "return " : "") + code + "; } }";
Context context = new Context(code);
JvmCompiler compiler = new JvmCompiler(environment, context, getSyntax(context));
ModuleEntity module = compiler.compile();
environment.getScope().loadModule(module);
ClassEntity entity = module.findClass("TestClass");
try {
return entity.findMethod("test").invokeStatic(environment);
} catch (Throwable throwable) {
throw new RuntimeException(throwable);
}
}
代码示例来源:origin: jphp-group/jphp
CompileScope compileScope = this.analyzer.getEnvironment().getScope();
代码示例来源:origin: jphp-group/jphp
environment.getScope().loadModule(module);
environment.getScope().addUserModule(module);
environment.registerModule(module);
environment.getModuleManager().addModule(context.getFileName(), module);
内容来源于网络,如有侵权,请联系作者删除!