Pseudo-code Semantics
A few words about the pseudo-code language we use to define the behavior of the Architecture parts.
The language used is Python-like, with nearly intuitive semantics.
We would like to highlight the following:
- For basic values like
Ints
andBools
, the assignment operator copies the value. - For complex data types (objects), the assignment operator copies a reference to the object instead of creating a new instance.
- The call
obj.clone()
creates a deep copy of the objectobj
. - The input arguments are passed by reference, so, mutating them within the function would mutate them for the caller also.
- Sometimes, the default value is irrelevant and not specified explicitly. Default values for structure fields are:
0
forInts
False
forBools
None
forOption
- For
Enum
types, the default value is the first item in the enumeration.
- In few places, we use idiomatic
Python
values swap:a, b = b, a
This construct exchanges the values ofa
andb
. - The object method syntax is used in few places, for example:
obj.method(p1, p2,...) = method(obj, p1, p2,...)
. - Types and namespaces begin with uppercase letter, for example:
TransactionExecutor.TrExecutorError()
denotes the objectTrExecutorError
residing in the namespaceTransactionExecutor
- We use is operator to do type test. For example, to test that message is internal, we use the following construct:
if in_msg.header is IntMsgInfo:
return ExecuteInternalMessage(in_msg, ...)
- We omit details of some global objects, and just assume they exist. For example, the virtual machine is created using some abstract TVM object. The same goes for system error enumerations. It is done this way not to overload the pseudo-code with easily recoverable details.