diff --git a/taichi/analysis/gen_offline_cache_key.cpp b/taichi/analysis/gen_offline_cache_key.cpp index a121e25fe14d3..f14297399d845 100644 --- a/taichi/analysis/gen_offline_cache_key.cpp +++ b/taichi/analysis/gen_offline_cache_key.cpp @@ -55,6 +55,8 @@ class ASTSerializer : public IRVisitor, public ExpressionVisitor { public: ASTSerializer(Program *prog, std::ostream *os) : ExpressionVisitor(true), prog_(prog), os_(os) { + // TODO(PGZXB): Set allow_undefined_visitor as false. (blocked by + // constant-folding) this->allow_undefined_visitor = true; } @@ -272,6 +274,12 @@ class ASTSerializer : public IRVisitor, public ExpressionVisitor { emit(expr->var); } + void visit(GetElementExpression *expr) override { + emit(ExprOpCode::GetElementExpression); + emit(expr->src); + emit(expr->index); + } + void visit(Block *block) override { emit(StmtOpCode::EnterBlock); emit(static_cast(block->statements.size())); diff --git a/taichi/inc/expressions.inc.h b/taichi/inc/expressions.inc.h index b311e6fb5a441..eaf498ea9598e 100644 --- a/taichi/inc/expressions.inc.h +++ b/taichi/inc/expressions.inc.h @@ -24,3 +24,4 @@ PER_EXPRESSION(MeshIndexConversionExpression) PER_EXPRESSION(ReferenceExpression) PER_EXPRESSION(TextureOpExpression) PER_EXPRESSION(TexturePtrExpression) +PER_EXPRESSION(GetElementExpression)