本文整理了Java中php.runtime.env.Environment.<init>()
方法的一些代码示例,展示了Environment.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Environment.<init>()
方法的具体详情如下:
包路径:php.runtime.env.Environment
类名称:Environment
方法名:<init>
暂无
代码示例来源:origin: jphp-group/jphp
public static void main(String[] args) {
Environment env = new Environment();
代码示例来源:origin: jphp-group/jphp
: new Environment(compileScope, out);
代码示例来源: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
@Signature({
@Arg(value = "parent", nativeType = WrapEnvironment.class, optional = @Optional("NULL")),
@Arg(value = "flags", optional = @Optional(value = "0", type = HintType.INT))
})
public Memory __construct(Environment env, Memory... args){
CompileScope scope = env.scope;
int flags = args[1].toInteger();
boolean hotReload = (flags & HOT_RELOAD) == HOT_RELOAD;
boolean concurrent = (flags & CONCURRENT) == CONCURRENT;
if (hotReload) {
scope = new CompileScope(scope);
}
if (args[0].isNull()) {
if (concurrent)
setEnvironment(new ConcurrentEnvironment(scope, env.getDefaultBuffer().getOutput()));
else
setEnvironment(new Environment(scope, env.getDefaultBuffer().getOutput()));
} else {
if (hotReload)
env.exception("Environment cannot be hot-reloadable with parent");
if (concurrent)
setEnvironment(new ConcurrentEnvironment(args[0].toObject(WrapEnvironment.class).getWrapEnvironment()));
else
setEnvironment(new Environment(args[0].toObject(WrapEnvironment.class).getWrapEnvironment()));
}
return Memory.NULL;
}
代码示例来源: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
public JPHPScriptEngine() {
super();
Launcher launcher = new Launcher();
try {
launcher.run(false);
} catch (Throwable e) {
//pass
}
environment = new Environment(launcher.getCompileScope(), System.out);
environment.getDefaultBuffer().setImplicitFlush(true);
JPHPContext ctx = new JPHPContext();
ctx.setBindings(createBindings(), ScriptContext.ENGINE_SCOPE);
setContext(ctx);
put(LANGUAGE_VERSION, __LANGUAGE_VERSION__);
put(LANGUAGE, __LANGUAGE__);
put(ENGINE, __NAME__);
put(ENGINE_VERSION, __ENGINE_VERSION__);
put(NAME, __SHORT_NAME__);
}
代码示例来源: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
environment = new ConcurrentEnvironment(newScope(), outputR);
} else {
environment = new Environment(newScope(), outputR);
内容来源于网络,如有侵权,请联系作者删除!