IntegerLiteral

IntegerLiteral

sealed class IntegerLiteral

From the docs:

The allowed syntax for integer literals depends on size and signedness. Moreover, their value must lie within the range of the respective type


sign       ::= empty => +
'+' => +
'-' => -
uN         ::= n:num         => n (if n < 2^N)
'0x' n:hexnum => n (if n < 2^N)
sN         ::= plusminus:sign n:num => plusminus * n (if -2^(N-1) <= plusminus n < 2^(N-1))
plusminus:sign n:hexnum => plusminus * n (same conditions as above)


Uninterpreted integers can be written as either signed or unsigned, and are normalized to
unsigned in the abstract syntax.

</code></pre><p>iN         ::= n:uN => n
    i:sN => n (if i = signed(n))</p><pre><code class="language-"></code></pre>

Fields

Name Description
val value: Type
var magnitude: Int
val sequence: CharSequence
open context: ParseContext?

Location of where the token was found in the .wast file.

Methods

parseValue

protected abstract fun parseValue(): Type

ReturnValue

Name Description
Type

checkMagnitude

protected abstract fun checkMagnitude(value: Type, magnitude: Int): Boolean

Parameters

Name Description
value: Type
magnitude: Int

ReturnValue

Name Description
Boolean

toUnsigned

abstract fun toUnsigned(): Unsigned

ReturnValue

Name Description
Unsigned

toSigned

abstract fun toSigned(): Signed

ReturnValue

Name Description
Signed

Extensions

isKeyword

fun Token.isKeyword(keywordValue: String): Boolean

Determines whether or not the Token is a Keyword matching the provided keywordValue.

Receiver

Name Description
Token

Parameters

Name Description
keywordValue: String

ReturnValue

Name Description
Boolean

asKeywordMatching

fun Token.asKeywordMatching(value: String): Keyword?

Casts the Token into a Keyword and returns it if its Keyword.value is value. Returns null if either condition is unmet.

Receiver

Name Description
Token

Parameters

Name Description
value: String

ReturnValue

Name Description
Keyword?

asKeywordMatching

fun Token.asKeywordMatching(regex: Regex): Pair<Keyword, MatchResult>?

Casts the Token into a Keyword and returns it, along with the match, if its Keyword.value matches regexp.

Returns null if neither condition is met.

Receiver

Name Description
Token

Parameters

Name Description
regex: Regex

ReturnValue

Name Description
Pair<Keyword, MatchResult>?

assertIsKeyword

fun Token.assertIsKeyword(keywordValue: String)

Asserts that the Token is a Keyword matching the provided keywordValue.

Receiver

Name Description
Token

Parameters

Name Description
keywordValue: String

ReturnValue

Name Description
Unit