diff --git a/StgScala/acn_scala.stg b/StgScala/acn_scala.stg index 12b5ca23c..872875aff 100644 --- a/StgScala/acn_scala.stg +++ b/StgScala/acn_scala.stg @@ -1,6 +1,6 @@ group scala_acn; -getStringSize(p) ::= "ULong.fromRaw(

.indexOf(0x00.toRawUByte))" +getStringSize(p) ::= "ULong.fromRaw(

.indexOfOrLength(0x00.toRawUByte))" getSizeableSize(p, sAcc, bIsUnsigned) ::= << @@ -450,11 +450,11 @@ val

= codec.dec_String_Ascii_FixSize() >> Acn_String_Ascii_Null_Terminated_encode(p, sErrCode, nAsn1Max, arruNullBytes) ::= << -codec.enc_String_Ascii_Null_Terminated_mult(, Array({}), ,

) +codec.enc_String_Ascii_Null_Terminated_multVec(, Array({}), ,

) >> Acn_String_Ascii_Null_Terminated_decode(p, sErrCode, nAsn1Max, arruNullBytes) ::= << -val

= codec.dec_String_Ascii_Null_Terminated_mult(, Array({}), ) +val

= codec.dec_String_Ascii_Null_Terminated_multVec(, Array({}), ) >> Acn_String_Ascii_External_Field_Determinant_encode(p, sErrCode, nAsn1Max, sExtFld) ::= "codec.enc_String_Ascii_External_Field_Determinant(,

)" @@ -625,7 +625,7 @@ val

= oct_sqf_null_terminated_encode(p, sAcc, i, sInternalItem, noSizeMin, nSizeMax, arruNullBytes, nBitPatternLength, sErrCode, nIntItemMinSize, nIntItemMaxSize) ::= << -codec.base.bitStream.appendBitsMSBFirst(Array({}), ) +codec.base.bitStream.appendBitsMSBFirstVec(Array({}), ) >> oct_sqf_null_terminated_decode(p, sAcc, i, sInternalItem, noSizeMin, nSizeMax, arruNullBytes, nBitPatternLength, sErrCode, nIntItemMinSize, nIntItemMaxSize) ::= << @@ -648,7 +648,7 @@ else if checkBitPatternPresentResult.get then >> bit_string_external_field_encode(sTypeDefName, p, sErrCode, sAcc, noSizeMin, nSizeMax, sExtFld) ::= << -codec.base.bitStream.appendBitsMSBFirst(

arr,

nCount) +codec.base.bitStream.appendBitsMSBFirstVec(

arr,

nCount) >> bit_string_external_field_decode(sTypeDefName, p, sErrCode, sAcc, noSizeMin, nSizeMax, sExtFld) ::= << @@ -659,7 +659,7 @@ val

= >> bit_string_external_field_fixed_size_encode(sTypeDefName, p, sErrCode, sAcc, noSizeMin, nSizeMax, sExtFld) ::= << -codec.base.bitStream.appendBitsMSBFirst(

arr, ) +codec.base.bitStream.appendBitsMSBFirstVec(

arr, ) >> bit_string_external_field_fixed_size_decode(sTypeDefName, p, sErrCode, sAcc, noSizeMin, nSizeMax, sExtFld) ::= << @@ -670,7 +670,7 @@ val

= >> bit_string_null_terminated_encode(sTypeDefName, p, sErrCode, sAcc, i, noSizeMin, nSizeMax, arruNullBytes, nBitPatternLength) ::= << -codec.base.bitStream.appendBitsMSBFirst(

arr,

arr.length*8) // TODO: re-introduce nCount? -> codec.base.bitStream.appendBitsMSBFirst(

arr,

nCount) +codec.base.bitStream.appendBitsMSBFirstVec(

arr,

arr.length*8) // TODO: re-introduce nCount? -> codec.base.bitStream.appendBitsMSBFirst(

arr,

nCount) codec.base.bitStream.appendBitsMSBFirst(Array({}), ) >> @@ -1078,7 +1078,7 @@ octet_string_containing_ext_field_func_decode(p, sFuncName, sReqBytesForUperEnco >> bit_string_containing_ext_field_func_encode(p, sFuncName, sReqBytesForUperEncoding, sReqBitsForUperEncoding, sExtField, sErrCode) ::= << -codec.base.bitStream.appendBitsMSBFirst(arr, .toInt) +codec.base.bitStream.appendBitsMSBFirstVec(arr, .toInt) >> bit_string_containing_ext_field_func_decode(p, sFuncName, sReqBytesForUperEncoding, sReqBitsForUperEncoding, sExtField, sErrCode) ::= << diff --git a/StgScala/equal_scala.stg b/StgScala/equal_scala.stg index c72920981..627818a37 100644 --- a/StgScala/equal_scala.stg +++ b/StgScala/equal_scala.stg @@ -78,7 +78,12 @@ def (: , : ): Boole isEqual_Primitive(p1, p2) ::= " == " -isEqual_String(p1, p2) ::= ".toScala.sameElements(.toScala)" +isEqual_String(p1, p2) ::= << +locally { + val zero = .indexOfOrLength(UByte.fromRaw(0)) + .toScala.slice(0, zero).sameElements(.toScala.slice(0, zero)) +} +>> isEqual_Integer(p1, p2) /*nogen*/::= "ret = ( == )" @@ -90,7 +95,12 @@ isEqual_Boolean(p1, p2) /*nogen*/::= "ret = ( ( && ) || (! && !) isEqual_Real(p1, p2) ::= "Asn1Real_Equal(, )" -isEqual_IA5String(p1, p2) /*nogen*/::= "ret = .toScala.sameElements(.toScala)" +isEqual_IA5String(p1, p2) /*nogen*/::= << +locally { + val zero = .indexOfOrLength(UByte.fromRaw(0)) + ret = .toScala.slice(0, zero).sameElements(.toScala.slice(0, zero)) +} +>> isEqual_NumericString(p1, p2) /*nogen*/::= "" isEqual_NullType()/*nogen*/ ::= "ret = true" diff --git a/StgScala/init_scala.stg b/StgScala/init_scala.stg index 5b86c9147..23c7bc0cd 100644 --- a/StgScala/init_scala.stg +++ b/StgScala/init_scala.stg @@ -119,11 +119,11 @@ val = Vector.fill()(UByte.fromRaw(0)) val allowedCharSet: Array[UByte] = Array(.toRawUByte}; wrap, anchor, separator=",">) -val _tmp = scala.collection.immutable.Vector.tabulate()( => if == - 1 then 0.toByte else allowedCharSet( % )) -val = Vector.fromScala(_tmp) +val _tmp = scala.collection.immutable.Vector.tabulate()( => if == - 1 then UByte.fromRaw(0) else allowedCharSet( % )) +val = Vector.fromScala(_tmp :+ UByte.fromRaw(0)) -val _tmp = scala.collection.immutable.Vector.tabulate()( => UByte.fromRaw(if == - 1 then 0.toByte else if % 128 == 0 then 'A'.toByte else ( % 128).toByte)) -val = Vector.fromScala(_tmp) +val _tmp = scala.collection.immutable.Vector.tabulate()( => UByte.fromRaw(if == - 1 then 0.toByte else if % 128 == 0 then 'A'.toByte else ( % 128).toByte)) +val = Vector.fromScala(_tmp :+ UByte.fromRaw(0)) >> diff --git a/StgScala/isvalid_scala.stg b/StgScala/isvalid_scala.stg index dcad543fa..e6062b18d 100644 --- a/StgScala/isvalid_scala.stg +++ b/StgScala/isvalid_scala.stg @@ -187,9 +187,9 @@ StatementForLoop(p, sAcc, i, bIsFixedSize, nFixedSize, sInnerStatement) ::= << Print_AlphabetCheckFunc(sFuncName, arrsAlphaConBody) ::= << -def (str0: Array[UByte]): Boolean = +def (str0: Vector[UByte]): Boolean = { - val str = str0.toArrayRaws + val str = str0.toVectorRaws var valid: Boolean = true var i: Int = 0 (while (i \< str.length && (str(i) != CHAR_0000) && valid) { diff --git a/StgScala/uper_scala.stg b/StgScala/uper_scala.stg index 66eb9410b..57d650a9a 100644 --- a/StgScala/uper_scala.stg +++ b/StgScala/uper_scala.stg @@ -431,7 +431,7 @@ str_FixedSize_decode(p, sTasName, i, sInternalItem, nFixedSize, nIntItemMinSize, str_VarSize_encode(p, sPIden, sTasName, i, sInternalItem, nSizeMin, nSizeMax, nSizeInBits, nIntItemMinSize, nIntItemMaxSize, nAlignSize, soInitExpr, soCallAux) ::= << -nStringLength =

.indexOf(0x00.toRawUByte) +nStringLength =

.indexOfOrLength(0x00.toRawUByte) /*ret = nStringLength >= && nStringLength \<= ;*/ codec.base.encodeConstrainedWholeNumber(nStringLength, , ) val _nCount = nStringLength diff --git a/asn1scala/src/main/scala/asn1scala/asn1jvm_Codec_ACN.scala b/asn1scala/src/main/scala/asn1scala/asn1jvm_Codec_ACN.scala index b33663e40..356335299 100644 --- a/asn1scala/src/main/scala/asn1scala/asn1jvm_Codec_ACN.scala +++ b/asn1scala/src/main/scala/asn1scala/asn1jvm_Codec_ACN.scala @@ -1505,6 +1505,10 @@ case class ACN(base: Codec) { i += 1 } + def enc_String_Ascii_Null_Terminated_multVec(max: Long, null_character: Array[Byte], null_character_size: Int, strVal: Vector[ASCIIChar]): Unit = { + enc_String_Ascii_Null_Terminated_mult(max, null_character, null_character_size, strVal.toScala.toArray) + } + def enc_String_Ascii_External_Field_Determinant(max: Long, strVal: Array[ASCIIChar]): Unit = { enc_String_Ascii_private(max, strVal) @@ -1690,6 +1694,10 @@ case class ACN(base: Codec) { strVal } + def dec_String_Ascii_Null_Terminated_multVec(max: Long, null_character: Array[ASCIIChar], null_character_size: Int): Vector[ASCIIChar] = { + val res = dec_String_Ascii_Null_Terminated_mult(max, null_character, null_character_size) + Vector.fromScala(res.toVector) + } @opaque @inlineOnce def dec_String_Ascii_External_Field_Determinant(max: Long, extSizeDeterminantFld: Long): Array[ASCIIChar] = {