use of php.runtime.common.AbstractCompiler in project jphp by jphp-compiler.
the class EvalFunctions method eval.
public static Memory eval(Environment env, TraceInfo trace, @Runtime.GetLocals ArrayMemory locals, String code) throws Throwable {
Context context = new Context(code);
try {
Tokenizer tokenizer = new Tokenizer(context);
SyntaxAnalyzer analyzer = syntaxAnalyzer.get();
analyzer.reset(env, tokenizer);
AbstractCompiler compiler = new JvmCompiler(env, context, analyzer);
ModuleEntity module = compiler.compile();
env.scope.loadModule(module);
env.registerModule(module);
return module.include(env, locals);
} catch (ErrorException e) {
if (e.getType() == ErrorType.E_PARSE) {
if (env.isHandleErrors(ErrorType.E_PARSE))
throw new ParseException(evalErrorMessage(e), trace);
} else
env.error(trace, e.getType(), evalErrorMessage(e));
}
return Memory.FALSE;
}
use of php.runtime.common.AbstractCompiler in project jphp by jphp-compiler.
the class WrapModule method __construct.
@Signature({ @Arg("source"), @Arg(value = "compiled", optional = @Optional("false")), @Arg(value = "debugInformation", optional = @Optional("true")) })
public Memory __construct(Environment env, Memory... args) throws Throwable {
InputStream is = Stream.getInputStream(env, args[0]);
try {
Context context = new Context(is, Stream.getPath(args[0]), env.getDefaultCharset());
if (args[1].toBoolean()) {
ModuleDumper moduleDumper = new ModuleDumper(context, env, args[2].toBoolean());
module = moduleDumper.load(context.getInputStream(env.getDefaultCharset()));
} else {
AbstractCompiler compiler = env.scope.createCompiler(env, context);
module = compiler.compile(false);
}
register(env);
} finally {
Stream.closeStream(env, is);
}
return Memory.NULL;
}
Aggregations