Skip to content

Instantly share code, notes, and snippets.

View mathieugarcia's full-sized avatar

Mathieu Garcia mathieugarcia

View GitHub Profile
@mathieugarcia
mathieugarcia / move-instructions-txn-cheat-sheet.csv
Created August 14, 2019 16:39
Facebook Move Instructions Cheat Sheet: Transaction (Txn) Built-In Instructions
Instruction Description
GetGasRemaining Push u64 representing remaining gas unit budget.
GetTxnSequenceNumber Push u64 encoding the transaction’s sequence number.
GetTxnPublicKey Push byte array encoding the transaction sender’s public key.
GetTxnSenderAddress Push address encoding the sender of the transaction.
GetTxnMaxGasUnits Push u64 representing the initial gas unit budget.
GetTxnGasUnitPrice Push u64 representing the Libra coin per gas unit price.
@mathieugarcia
mathieugarcia / move-instructions-stack-cheat-sheet.csv
Created August 14, 2019 16:38
Facebook Move Instructions Cheat Sheet: Stack Instructions
Instruction Description
Not Pop boolean 'b' and push !b.
Add† Pop two u64’s 'u1' and 'u2' and push u1 + u2. Fail on overflow.
Sub† Pop two u64’s 'u1' and 'u2' and push u1 - u2. Fail on underflow.
Mul† Pop two u64’s 'u1' and 'u2' and push u1 × u2. Fail on overflow.
Div† Pop two u64’s 'u1' and 'u2' and push u1 ÷ u2. Fail if 'u2' is zero.
Mod† Pop two u64’s 'u1' and 'u2' and push u1 mod 𝑢2. Fail if 'u2' is zero.
BitOr Pop two u64’s 'u1' and 'u2' and push u1 | u2.
BitAnd Pop two u64’s 'u1' and 'u2' and push u1 & u2.
Xor Pop two u64’s 'u1' and 'u2' and push u1 ⊕ u2.
@mathieugarcia
mathieugarcia / move-instructions-special-cheat-sheet.csv
Created August 14, 2019 16:38
Facebook Move Instructions Cheat Sheet: Special Instructions
Instruction Description
PopUnrestricted Pop a non-resource value.
RejectUnless† Pop bool 'b' and u64 'u', fail with error code 'u' if 'b' is false.
CreateAccount† Pop address 'a', create a LibraAccount.T under 'a'.
@mathieugarcia
mathieugarcia / move-instructions-reference-cheat-sheet.csv
Created August 14, 2019 16:37
Facebook Move Instructions Cheat Sheet: Reference Instructions
Instruction Description
ReadRef Pop 'r' and push '*r' on the stack.
WriteRef Pop two values 'v' and 'r', perform the write *r = v.
ReleaseRef Pop 'r' and decrement the appropriate refcount if 'r' is a global reference.
FreezeRef Pop mutable reference 'r', push immutable reference to the same value.
@mathieugarcia
mathieugarcia / move-instructions-module-cheat-sheet.csv
Created August 14, 2019 16:36
Facebook Move Instructions Cheat Sheet: Module Built-Ins
Instruction Description
Pack<n> Pop arguments 'v*', create struct of type n with 'f'_i: 'v'_i and push it on the stack.
Unpack<n> Pop struct of type 'n' from the stack and push its field values 'v*' on the stack.
BorrowField<f> Pop reference to a struct and push a reference to field 'f' of the struct.
MoveToSender<n>† Pop resource of type 'b' and publish it under the sender’s address.
MoveFrom<n>† Pop address 'a', remove resource of type 'b' from 'a', push it.
BorrowGlobal<n>† Pop address 'a', push a reference to the resource of type 'n' under 'a'.
Exists<n> Pop address 'a', push bool encoding "a resource of type 'n' exists under 'a'".
@mathieugarcia
mathieugarcia / move-instructions-local-cheat-sheet.csv
Created August 14, 2019 16:35
Facebook Move Instructions Cheat Sheet: Local Instructions
Instruction Description
MoveLoc<x> Push value stored in 'x' on the stack. 'x' is now unavailable.
CopyLoc<x> Push value stored in 'x' on the stack.
StoreLoc<x> Pop the stack and store the result in 'x'. 'x' is now available.
BorrowLoc<x> Create a reference to the value stored in 'x' and push it on the stack.
@mathieugarcia
mathieugarcia / move-instructions-control-flow-cheat-sheet.csv
Created August 14, 2019 16:35
Facebook Move Instructions Cheat Sheet: Control Flow Instructions
Instruction Description
Branch<l> Jump to instruction index 'l' in the current procedure.
BranchIfTrue<l> Pop boolean, jump to instruction index 'l' in the current procedure if true.
BranchIfFalse<l> Pop boolean, jump to instruction index 'l' in the current procedure if false.
@mathieugarcia
mathieugarcia / move-instructions-constant-cheat-sheet.csv
Created August 14, 2019 16:34
Facebook Move Instructions Cheat Sheet: Constant Instructions
Instruction Description
LoadTrue Push true on the stack.
LoadFalse Push false on the stack.
LoadU64<u> Push the u64 'u' on the stack.
LoadAddress<a> Push the address 'a' on the stack.
LoadBytes<b> Push the byte array 'b' on the stack.
@mathieugarcia
mathieugarcia / move-instructions-call-cheat-sheet.csv
Created August 14, 2019 16:32
Facebook Move Instructions Cheat Sheet : Call Instructions
Instruction Description
Call<p> Pop arguments 'r*' then load into 'p'’s formals x*' then transfer control to 'p'.
Return Return control to the previous frame in the call stack.
@mathieugarcia
mathieugarcia / xcode_cpp17_v1_ts.txt
Created September 16, 2017 17:38
Xcode 9.0.0 V1 TS
[mg@mac /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/experimental]$ ls
__config chrono functional memory_resource ratio string_view unordered_map
__memory deque iterator numeric regex system_error unordered_set
algorithm dynarray list optional set tuple utility
any forward_list map propagate_const string type_traits vector