Skip to main content

Crate qlexpress

Crate qlexpress 

Source
Expand description

§QlExpress Rust

Alibaba QLExpress4 动态脚本引擎的 Rust 语义迁移实现。

当前 0.1.0-alpha.2 对齐 Java 4.2.0-beta,提供表达式解析、QVM 执行、 宿主函数与类型注册、安全策略、编译缓存以及表达式追踪能力。

[dependencies]
qlexpress = "=0.1.0-alpha.2"
use qlexpress::{DataValue, Express4Runner, QLOptions};

let runner = Express4Runner::new();
let result = runner.execute(
    "19 + 23",
    Default::default(),
    &QLOptions::builder().build(),
)?;
assert_eq!(result.into_result(), DataValue::Int(42));

完整文档、Java/Rust 对照关系及生产验收结果见 GitHub 仓库

qlexpress — full semantic migration of Alibaba QLExpress4 to Rust.

lib.rs is a thin index: only pub mod declarations plus facade re-exports. No implementation lives here (see SPEC §2).

Re-exports§

pub use check_options::CheckOptions;
pub use class_supplier::ClassSupplier;
pub use default_class_supplier::DefaultClassSupplier;
pub use express4_runner::Express4Runner;
pub use init_options::InitOptions;
pub use ql_options::QLOptions;
pub use ql_options::QLOptionsBuilder;
pub use ql_result::QLResult;
pub use exception::ErrorReporter;
pub use exception::PureErrReporter;
pub use exception::QLException;
pub use exception::QLExceptionKind;
pub use exception::QLSyntaxException;
pub use runtime::context::ExpressContext;
pub use runtime::context::MapExpressContext;
pub use runtime::context::QLAliasContext;
pub use runtime::value::DataValue;
pub use runtime::value::NativeObject;
pub use runtime::value::QValue;
pub use runtime::value::Value;
pub use annotation::QLFunctionMethod;
pub use annotation::QLFunctionProvider;
pub use api::BatchAddFunctionResult;
pub use api::QLFunctionalVarargs;
pub use runtime::function::CustomFunction;
pub use runtime::operator::custom_binary_operator::CustomBinaryOperator;
pub use security::CacheStats;
pub use security::CancellationToken;
pub use security::Capability;
pub use security::CapabilityPolicy;
pub use security::CompileCachePolicy;
pub use security::NativeMember;
pub use security::QLSecurityStrategy;
pub use security::ResourceLimits;
pub use security::SandboxProfile;
pub use aparser::build_tree;
pub use aparser::CheckVisitor;
pub use aparser::ChildRef;
pub use aparser::CompileCache;
pub use aparser::GeneratorScope;
pub use aparser::HasChildren;
pub use aparser::ImportManager;
pub use aparser::MacroDefine;
pub use aparser::Node;
pub use aparser::OutFunctionVisitor;
pub use aparser::OutVarAttrsVisitor;
pub use aparser::OutVarNamesVisitor;
pub use aparser::QCompileCache;
pub use aparser::QLParser;
pub use aparser::TerminalNode;
pub use aparser::Token;
pub use aparser::Visitor;

Modules§

annotation
Annotation metadata mirroring Java com.alibaba.qlexpress4.annotation.
aparser
Lexer/parser package mirroring Java com.alibaba.qlexpress4.aparser.
api
Public API types mirroring Java com.alibaba.qlexpress4.api.
arithmetic
算术操作符包,对应 Java com.alibaba.qlexpress4.runtime.operator.arithmetic
assign
赋值操作符,对应 Java com.alibaba.qlexpress4.runtime.operator.assign 包。
base
操作符基类包,对应 Java com.alibaba.qlexpress4.runtime.operator.base
bit
位运算操作符包,对应 Java com.alibaba.qlexpress4.runtime.operator.bit
check_options
Script validation configuration, mirroring Java CheckOptions.
class_supplier
类型供应契约,对应 Java com.alibaba.qlexpress4.ClassSupplier (@FunctionalInterface,Class<?> loadCls(String clsQualifiedName))。
collection
集合包含操作符,对应 Java com.alibaba.qlexpress4.runtime.operator.collection 包。
compare
比较操作符包,对应 Java com.alibaba.qlexpress4.runtime.operator.compare
compiletimefunction
Compile-time function mechanism, mirroring Java com.alibaba.qlexpress4.aparser.compiletimefunction.
context
外部变量上下文,对应 Java com.alibaba.qlexpress4.runtime.context 包。
convert
Type-conversion 子包,对应 Java runtime/data/convert/
data
Data-holding Value implementations, mirroring Java runtime/data/.
default_class_supplier
默认类型供应器,对应 Java com.alibaba.qlexpress4.DefaultClassSupplier
enums
Java com.alibaba.qlexpress4.enums 子包:仅 mod 声明 + re-export。
exception
Exception system mirroring Java com.alibaba.qlexpress4.exception.
express4_runner
引擎门面,对应 Java com.alibaba.qlexpress4.Express4Runner
function
脚本可调用函数,对应 Java com.alibaba.qlexpress4.runtime.function 包。
init_options
Runner-initialization options, mirroring Java InitOptions.
instruction
QVM instructions, mirroring Java com.alibaba.qlexpress4.runtime.instruction (all 42 classes).
lambda
Lambda 数据对象。对应 Java 包 com.alibaba.qlexpress4.runtime.data.lambda
logic
逻辑操作符包,对应 Java com.alibaba.qlexpress4.runtime.operator.logic
lsp
LSP-style error location model, mirroring Java exception/lsp/.
member
成员处理,对应 Java com.alibaba.qlexpress4.member 包。
number
数值数学域,对应 Java com.alibaba.qlexpress4.runtime.operator.number 包。 按 SPEC §5.5 一类一文件:NumberMath 门面 + 五个数值域实现 (Integer/Long/FloatingPoint/BigInteger/BigDecimal),参考 Groovy 的 类型提升矩阵(见 number_math.rs 注释)。
operator
Operator-related public types mirroring Java com.alibaba.qlexpress4.operator. Stage 0 delivers only the OperatorCheckStrategy family required by CheckOptions; the operator implementations arrive in Stage 4.
parsecache
Serializable parse cache, mirroring Java com.alibaba.qlexpress4.api.parsecache(12 个类一一对应)。
proxy
Java com.alibaba.qlexpress4.proxy 子包:仅 mod 声明 + re-export。
ql_options
Execution options, mirroring Java QLOptions (Builder pattern).
ql_precedences
Operator precedence constants, mirroring Java QLPrecedences.
ql_result
脚本执行的公开结果,对应 Java com.alibaba.qlexpress4.QLResult。 (VM 内部的 QResult 已拆至 crate::runtime::q_result。)
runtime
Runtime model mirroring Java com.alibaba.qlexpress4.runtime.
scope
Scope chain, mirroring Java com.alibaba.qlexpress4.runtime.scope (QScope + QvmBlockScope). The global scope lives in runtime/qvm_global_scope.rs.
security
Security model mirroring Java com.alibaba.qlexpress4.security.
string
字符串操作符,对应 Java com.alibaba.qlexpress4.runtime.operator.string 包。
trace
Expression tracing model, mirroring Java runtime/trace/.
unary
一元操作符,对应 Java com.alibaba.qlexpress4.runtime.operator.unary 包。
util
VM helper utilities, mirroring Java com.alibaba.qlexpress4.runtime.util.
utils
Utility helpers mirroring Java com.alibaba.qlexpress4.utils.

Derive Macros§

QLExpressType
为宿主类型生成 NativeTypeNativeObject 实现的派生宏。 Derive macro for QLExpress-native types.