Writes a constant value to a target register. This includes
integers,
rationals,
lists,
sets,
maps, etc. For example, the following Whiley code:
function f(int x) => int: xs = {1,2.12} return |xs| + 1
can be translated into the following WyIL code:
function f(int x) => int: body: var xs const %2 = 1 : int convert %2 = % 2 int|real : int const %3 = 2.12 : real convert %3 = % 3 int|real : real newset %1 = (%2, %3) : {int|real} assign %3 = %1 : {int|real} lengthof %3 = % 3 : {int|real} const %4 = 1 : int add %2 = % 3, %4 : int return %2 : int
Here, we see two kinds of constants values being used: integers (i.e.
const %2 = 1
) and rationals (i.e.
const %3 = 2.12
).
@author David J. Pearce