@@ -1097,7 +1097,7 @@ public PObject getTypeInfoByRelId(uint ti_relid)
1097
1097
/// <exception cref="Exception">Symbol syntax error</exception>
1098
1098
private void calcAccessSeqFor1DimArray ( ref string symbol , PVartypeListElement varType , VarInfo varInfo )
1099
1099
{
1100
- Regex re = new Regex ( @"^\[(\d+)\]" ) ;
1100
+ Regex re = new Regex ( @"^\[(-? \d+)\]" ) ;
1101
1101
Match m = re . Match ( symbol ) ;
1102
1102
if ( ! m . Success ) throw new Exception ( "Symbol syntax error" ) ;
1103
1103
parseSymbolLevel ( ref symbol ) ; // remove index from symbol string
@@ -1122,16 +1122,14 @@ private void calcAccessSeqFor1DimArray(ref string symbol, PVartypeListElement va
1122
1122
/// <exception cref="Exception">Symbol syntax error</exception>
1123
1123
private void calcAccessSeqForMDimArray ( ref string symbol , PVartypeListElement varType , VarInfo varInfo )
1124
1124
{
1125
- Regex re = new Regex ( @"^\[([0-9, ] +)\]" ) ;
1125
+ Regex re = new Regex ( @"^\[( ?-?\d+ ?(, ?-?\d+ ?) +)\]" ) ;
1126
1126
Match m = re . Match ( symbol ) ;
1127
1127
if ( ! m . Success ) throw new Exception ( "Symbol syntax error" ) ;
1128
1128
parseSymbolLevel ( ref symbol ) ; // remove index from symbol string
1129
1129
string idxs = m . Groups [ 1 ] . Value . Replace ( " " , "" ) ;
1130
1130
1131
- uint [ ] indexes = Array . ConvertAll ( idxs . Split ( ',' ) , e => uint . Parse ( e ) ) ;
1131
+ int [ ] indexes = Array . ConvertAll ( idxs . Split ( ',' ) , e => int . Parse ( e ) ) ;
1132
1132
var ioit = ( IOffsetInfoType_MDim ) varType . OffsetInfoType ;
1133
- uint ArrayElementCount = ioit . GetArrayElementCount ( ) ;
1134
- int ArrayLowerBounds = ioit . GetArrayLowerBounds ( ) ;
1135
1133
uint [ ] MdimArrayElementCount = ( uint [ ] ) ioit . GetMdimArrayElementCount ( ) . Clone ( ) ;
1136
1134
int [ ] MdimArrayLowerBounds = ioit . GetMdimArrayLowerBounds ( ) ;
1137
1135
@@ -1141,7 +1139,7 @@ private void calcAccessSeqForMDimArray(ref string symbol, PVartypeListElement va
1141
1139
// check bounds
1142
1140
for ( int i = 0 ; i < dimCount ; ++ i )
1143
1141
{
1144
- indexes [ i ] = ( uint ) ( indexes [ i ] - MdimArrayLowerBounds [ dimCount - i - 1 ] ) ;
1142
+ indexes [ i ] = ( indexes [ i ] - MdimArrayLowerBounds [ dimCount - i - 1 ] ) ;
1145
1143
if ( indexes [ i ] > MdimArrayElementCount [ dimCount - i - 1 ] ) throw new Exception ( "Out of bounds" ) ;
1146
1144
if ( indexes [ i ] < 0 ) throw new Exception ( "Out of bounds" ) ;
1147
1145
}
@@ -1161,10 +1159,10 @@ private void calcAccessSeqForMDimArray(ref string symbol, PVartypeListElement va
1161
1159
dimSize [ dimCount - 1 ] = g ;
1162
1160
1163
1161
// calc id
1164
- uint arrayIndex = 0 ;
1162
+ int arrayIndex = 0 ;
1165
1163
for ( int i = 0 ; i < dimCount ; ++ i )
1166
1164
{
1167
- arrayIndex += indexes [ i ] * dimSize [ dimCount - i - 1 ] ;
1165
+ arrayIndex += indexes [ i ] * ( int ) dimSize [ dimCount - i - 1 ] ;
1168
1166
}
1169
1167
1170
1168
varInfo . AccessSequence += "." + String . Format ( "{0:X}" , arrayIndex ) ;
0 commit comments