@@ -870,3 +870,52 @@ op.getcodelocation = function(code) {
870
870
op . getcodecuid = function ( codeRef ) {
871
871
return codeRef . cuid ;
872
872
} ;
873
+
874
+ op . numdimensions = function ( array ) {
875
+ if ( array instanceof Array ) {
876
+ return 1 ;
877
+ }
878
+ } ;
879
+
880
+ op . dimensions = function ( array ) {
881
+ if ( array instanceof Array ) {
882
+ return [ array . length ] ;
883
+ }
884
+ } ;
885
+
886
+ op . setdimensions = function ( ctx , array , dimensions ) {
887
+ if ( array instanceof Array ) {
888
+ if ( dimensions . length != 1 ) {
889
+ ctx . die ( "A dynamic array can only have a single dimension" ) ;
890
+ } else {
891
+ //console.log("setting ", array, dimensions);
892
+ array . length = dimensions [ 0 ] ;
893
+ }
894
+ }
895
+ } ;
896
+
897
+ op . atposnd = function ( ctx , array , idx ) {
898
+ if ( array instanceof Array ) {
899
+ if ( idx . length != 1 ) {
900
+ ctx . die ( "A dynamic array can only be indexed with a single dimension" ) ;
901
+ }
902
+ return array [ idx [ 0 ] ] ;
903
+ }
904
+ } ;
905
+
906
+ op . atposnd_n = op . atposnd ;
907
+ op . atposnd_s = op . atposnd ;
908
+ op . atposnd_i = op . atposnd ;
909
+
910
+ op . bindposnd = function ( ctx , array , idx , value ) {
911
+ if ( array instanceof Array ) {
912
+ if ( idx . length != 1 ) {
913
+ ctx . die ( "A dynamic array can only be indexed with a single dimension" ) ;
914
+ }
915
+ return ( array [ idx [ 0 ] ] = value ) ;
916
+ }
917
+ } ;
918
+
919
+ op . bindposnd_n = op . bindposnd ;
920
+ op . bindposnd_s = op . bindposnd ;
921
+ op . bindposnd_i = op . bindposnd ;
0 commit comments