use of org.develnext.jphp.core.compiler.jvm.JvmCompiler 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 org.develnext.jphp.core.compiler.jvm.JvmCompiler in project jphp by jphp-compiler.
the class Launcher method loadFromFile.
public ModuleEntity loadFromFile(String file) throws IOException {
InputStream inputStream = getResource(file);
if (inputStream == null)
return null;
Context context = new Context(inputStream, file, environment.getDefaultCharset());
JvmCompiler compiler = new JvmCompiler(environment, context);
return compiler.compile(false);
}
Aggregations