php.runtime.env.Environment.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(151)

本文整理了Java中php.runtime.env.Environment.<init>()方法的一些代码示例,展示了Environment.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Environment.<init>()方法的具体详情如下:
包路径:php.runtime.env.Environment
类名称:Environment
方法名:<init>

Environment.<init>介绍

暂无

代码示例

代码示例来源:origin: jphp-group/jphp

  1. public static void main(String[] args) {
  2. Environment env = new Environment();

代码示例来源:origin: jphp-group/jphp

  1. : new Environment(compileScope, out);

代码示例来源:origin: jphp-group/jphp

  1. public static Memory getValue(Debugger context, String value) {
  2. DebugTick tick = context.getRegisteredTick();
  3. Environment environment = new Environment(new CompileScope(tick.getEnvironment().getScope()));
  4. try {
  5. return LangFunctions.eval(environment, tick.getTrace(), tick.getLocals(), "return " + value + ";");
  6. } catch (Throwable throwable) {
  7. return null;
  8. }
  9. }

代码示例来源:origin: jphp-group/jphp

  1. @SuppressWarnings("unchecked")
  2. protected Memory includeResource(String name, ArrayMemory globals){
  3. ByteArrayOutputStream output = new ByteArrayOutputStream();
  4. Environment environment;
  5. if (isConcurrent()) {
  6. environment = new ConcurrentEnvironment(newScope(), output);
  7. } else {
  8. environment = new Environment(newScope(), output);
  9. }
  10. File file = new File(Thread.currentThread().getContextClassLoader().getResource("resources/" + name).getFile());
  11. Context context = new Context(file);
  12. JvmCompiler compiler = new JvmCompiler(environment, context, getSyntax(context));
  13. ModuleEntity module = compiler.compile();
  14. environment.getScope().loadModule(module);
  15. try {
  16. environment.registerModule(module);
  17. } catch (Throwable throwable) {
  18. throw new RuntimeException(throwable);
  19. }
  20. if (globals != null)
  21. environment.getGlobals().putAll(globals);
  22. Memory memory = module.includeNoThrow(environment, environment.getGlobals());
  23. try {
  24. environment.doFinal();
  25. } catch (Throwable throwable) {
  26. throw new RuntimeException(throwable);
  27. }
  28. lastOutput = output.toString();
  29. return memory;
  30. }

代码示例来源:origin: jphp-group/jphp

  1. @Signature({
  2. @Arg(value = "parent", nativeType = WrapEnvironment.class, optional = @Optional("NULL")),
  3. @Arg(value = "flags", optional = @Optional(value = "0", type = HintType.INT))
  4. })
  5. public Memory __construct(Environment env, Memory... args){
  6. CompileScope scope = env.scope;
  7. int flags = args[1].toInteger();
  8. boolean hotReload = (flags & HOT_RELOAD) == HOT_RELOAD;
  9. boolean concurrent = (flags & CONCURRENT) == CONCURRENT;
  10. if (hotReload) {
  11. scope = new CompileScope(scope);
  12. }
  13. if (args[0].isNull()) {
  14. if (concurrent)
  15. setEnvironment(new ConcurrentEnvironment(scope, env.getDefaultBuffer().getOutput()));
  16. else
  17. setEnvironment(new Environment(scope, env.getDefaultBuffer().getOutput()));
  18. } else {
  19. if (hotReload)
  20. env.exception("Environment cannot be hot-reloadable with parent");
  21. if (concurrent)
  22. setEnvironment(new ConcurrentEnvironment(args[0].toObject(WrapEnvironment.class).getWrapEnvironment()));
  23. else
  24. setEnvironment(new Environment(args[0].toObject(WrapEnvironment.class).getWrapEnvironment()));
  25. }
  26. return Memory.NULL;
  27. }

代码示例来源:origin: jphp-group/jphp

  1. protected Memory runDynamic(String code, boolean returned){
  2. runIndex += 1;
  3. Environment environment = new Environment(newScope());
  4. code = (returned ? "return " : "") + code + ";";
  5. Context context = new Context(code);
  6. JvmCompiler compiler = new JvmCompiler(environment, context, getSyntax(context));
  7. ModuleEntity module = compiler.compile();
  8. environment.getScope().loadModule(module);
  9. try {
  10. environment.registerModule(module);
  11. } catch (Throwable throwable) {
  12. throw new RuntimeException(throwable);
  13. }
  14. return module.includeNoThrow(environment);
  15. }

代码示例来源:origin: jphp-group/jphp

  1. public JPHPScriptEngine() {
  2. super();
  3. Launcher launcher = new Launcher();
  4. try {
  5. launcher.run(false);
  6. } catch (Throwable e) {
  7. //pass
  8. }
  9. environment = new Environment(launcher.getCompileScope(), System.out);
  10. environment.getDefaultBuffer().setImplicitFlush(true);
  11. JPHPContext ctx = new JPHPContext();
  12. ctx.setBindings(createBindings(), ScriptContext.ENGINE_SCOPE);
  13. setContext(ctx);
  14. put(LANGUAGE_VERSION, __LANGUAGE_VERSION__);
  15. put(LANGUAGE, __LANGUAGE__);
  16. put(ENGINE, __NAME__);
  17. put(ENGINE_VERSION, __ENGINE_VERSION__);
  18. put(NAME, __SHORT_NAME__);
  19. }

代码示例来源:origin: jphp-group/jphp

  1. protected Memory run(String code, boolean returned){
  2. runIndex += 1;
  3. Environment environment = new Environment(newScope());
  4. code = "class TestClass { static function test(){ " + (returned ? "return " : "") + code + "; } }";
  5. Context context = new Context(code);
  6. JvmCompiler compiler = new JvmCompiler(environment, context, getSyntax(context));
  7. ModuleEntity module = compiler.compile();
  8. environment.getScope().loadModule(module);
  9. ClassEntity entity = module.findClass("TestClass");
  10. try {
  11. return entity.findMethod("test").invokeStatic(environment);
  12. } catch (Throwable throwable) {
  13. throw new RuntimeException(throwable);
  14. }
  15. }

代码示例来源:origin: jphp-group/jphp

  1. environment = new ConcurrentEnvironment(newScope(), outputR);
  2. } else {
  3. environment = new Environment(newScope(), outputR);

相关文章