Appearance
PrimeNumbersUpTo100
100以下の素数を列挙します。候補ごとの内側ループ、剰余判定、真偽値による分岐を含むサンプルです。
json
{
"version": 1,
"comment": "100以下の素数を列挙します。候補ごとの内側ループ、剰余判定、真偽値による分岐を含むサンプルです。",
"data": [
{
"name": "__n",
"type": "SystemInt32",
"value": 0
},
{
"name": "__n_next",
"type": "SystemInt32",
"value": 0
},
{
"name": "__d",
"type": "SystemInt32",
"value": 0
},
{
"name": "__d_next",
"type": "SystemInt32",
"value": 0
},
{
"name": "__d_squared",
"type": "SystemInt32",
"value": 0
},
{
"name": "__remainder",
"type": "SystemInt32",
"value": 0
},
{
"name": "__one",
"type": "SystemInt32",
"value": 1
},
{
"name": "__two",
"type": "SystemInt32",
"value": 2
},
{
"name": "__hundred",
"type": "SystemInt32",
"value": 100
},
{
"name": "__zero",
"type": "SystemInt32",
"value": 0
},
{
"name": "__true",
"type": "SystemBoolean",
"value": true
},
{
"name": "__false",
"type": "SystemBoolean",
"value": false
},
{
"name": "__is_prime",
"type": "SystemBoolean",
"value": false
},
{
"name": "__condition",
"type": "SystemBoolean",
"value": false
}
],
"code": [
{
"name": "_start",
"export": true,
"instructions": [
{
"op": "PUSH",
"operand": "__two"
},
{
"op": "PUSH",
"operand": "__n"
},
{
"op": "COPY"
},
{
"op": "JUMP",
"operand": "_candidate"
}
]
},
{
"name": "_candidate",
"export": false,
"instructions": [
{
"op": "PUSH",
"operand": "__n"
},
{
"op": "PUSH",
"operand": "__hundred"
},
{
"op": "EXTERN",
"signature": "SystemInt32.__op_LessThanOrEqual__SystemInt32_SystemInt32__SystemBoolean",
"argumentCount": 2,
"return": "__condition"
},
{
"op": "JUMP_IF_FALSE",
"operand": "_end"
},
{
"op": "PUSH",
"operand": "__true"
},
{
"op": "PUSH",
"operand": "__is_prime"
},
{
"op": "COPY"
},
{
"op": "PUSH",
"operand": "__two"
},
{
"op": "PUSH",
"operand": "__d"
},
{
"op": "COPY"
},
{
"op": "JUMP",
"operand": "_divisor_test"
}
]
},
{
"name": "_divisor_test",
"export": false,
"instructions": [
{
"op": "PUSH",
"operand": "__d"
},
{
"op": "PUSH",
"operand": "__d"
},
{
"op": "EXTERN",
"signature": "SystemInt32.__op_Multiplication__SystemInt32_SystemInt32__SystemInt32",
"argumentCount": 2,
"return": "__d_squared"
},
{
"op": "PUSH",
"operand": "__n"
},
{
"op": "EXTERN",
"signature": "SystemInt32.__op_LessThanOrEqual__SystemInt32_SystemInt32__SystemBoolean",
"argumentCount": 2,
"return": "__condition"
},
{
"op": "JUMP_IF_FALSE",
"operand": "_emit"
},
{
"op": "PUSH",
"operand": "__n"
},
{
"op": "PUSH",
"operand": "__d"
},
{
"op": "EXTERN",
"signature": "SystemInt32.__op_Remainder__SystemInt32_SystemInt32__SystemInt32",
"argumentCount": 2,
"return": "__remainder"
},
{
"op": "PUSH",
"operand": "__zero"
},
{
"op": "EXTERN",
"signature": "SystemInt32.__op_Equality__SystemInt32_SystemInt32__SystemBoolean",
"argumentCount": 2,
"return": "__condition"
},
{
"op": "JUMP_IF_FALSE",
"operand": "_next_divisor"
},
{
"op": "PUSH",
"operand": "__false"
},
{
"op": "PUSH",
"operand": "__is_prime"
},
{
"op": "COPY"
},
{
"op": "JUMP",
"operand": "_emit"
}
]
},
{
"name": "_next_divisor",
"export": false,
"instructions": [
{
"op": "PUSH",
"operand": "__d"
},
{
"op": "PUSH",
"operand": "__one"
},
{
"op": "EXTERN",
"signature": "SystemInt32.__op_Addition__SystemInt32_SystemInt32__SystemInt32",
"argumentCount": 2,
"return": "__d_next"
},
{
"op": "PUSH",
"operand": "__d"
},
{
"op": "COPY"
},
{
"op": "JUMP",
"operand": "_divisor_test"
}
]
},
{
"name": "_emit",
"export": false,
"instructions": [
{
"op": "PUSH",
"operand": "__is_prime"
},
{
"op": "JUMP_IF_FALSE",
"operand": "_next_candidate"
},
{
"op": "PUSH",
"operand": "__n"
},
{
"op": "EXTERN",
"signature": "UnityEngineDebug.__Log__SystemObject__SystemVoid",
"argumentCount": 1
},
{
"op": "JUMP",
"operand": "_next_candidate"
}
]
},
{
"name": "_next_candidate",
"export": false,
"instructions": [
{
"op": "PUSH",
"operand": "__n"
},
{
"op": "PUSH",
"operand": "__one"
},
{
"op": "EXTERN",
"signature": "SystemInt32.__op_Addition__SystemInt32_SystemInt32__SystemInt32",
"argumentCount": 2,
"return": "__n_next"
},
{
"op": "PUSH",
"operand": "__n"
},
{
"op": "COPY"
},
{
"op": "JUMP",
"operand": "_candidate"
}
]
},
{
"name": "_end",
"export": false,
"instructions": []
}
]
}