@@ -611,6 +611,25 @@ GL_Value gl_eval_index2_expr(
611
611
throw Exception (acx, " 2 indexes (a[i,j]) not supported for this array" );
612
612
}
613
613
614
+ // compile array[i,j,k] expression
615
+ GL_Value gl_eval_index3_expr (
616
+ GL_Value array, Operation& op_ix1, Operation& op_ix2, Operation& op_ix3,
617
+ GL_Frame& f, const Context& acx)
618
+ {
619
+ if (array.type .rank_ == 2 && array.type .base_info ().rank == 1 ) {
620
+ // 2D array of vector.
621
+ auto ix1 = gl_eval_expr (f, op_ix1, GL_Type::Num ());
622
+ auto ix2 = gl_eval_expr (f, op_ix2, GL_Type::Num ());
623
+ auto ix3 = gl_eval_expr (f, op_ix3, GL_Type::Num ());
624
+ GL_Value result = f.gl .newvalue (GL_Type::Num ());
625
+ f.gl .out << " " << result.type << " " << result << " = " << array
626
+ << " [int(" << ix1 << " )*" << array.type .dim1_
627
+ << " +" << " int(" << ix2 << " )][int(" << ix3 << " )];\n " ;
628
+ return result;
629
+ }
630
+ throw Exception (acx, " 3 indexes (a[i,j,k]) not supported for this array" );
631
+ }
632
+
614
633
GL_Value Call_Expr::gl_eval (GL_Frame& f) const
615
634
{
616
635
GL_Value glval;
@@ -627,6 +646,10 @@ GL_Value Call_Expr::gl_eval(GL_Frame& f) const
627
646
if (list->size () == 2 )
628
647
return gl_eval_index2_expr (glval, *list->at (0 ), *list->at (1 ), f,
629
648
At_GL_Phrase (arg_->syntax_ , f));
649
+ if (list->size () == 3 )
650
+ return gl_eval_index3_expr (glval,
651
+ *list->at (0 ), *list->at (1 ), *list->at (2 ),
652
+ f, At_GL_Phrase (arg_->syntax_ , f));
630
653
}
631
654
Value val = gl_constify (*fun_, f);
632
655
Value v = val;
0 commit comments