MCPcopy Create free account
hub / github.com/NethermindEth/cairo-vm-go / CasmToBytecode

Function CasmToBytecode

pkg/assembler/assembler.go:22–34  ·  view source on GitHub ↗

Given a CASM program it returns its encoded bytecode and a total size of processed instructions

(code string)

Source from the content-addressed store, hash-verified

20
21// Given a CASM program it returns its encoded bytecode and a total size of processed instructions
22func CasmToBytecode(code string) ([]*f.Element, uint8, error) {
23 casmAst, err := parser.ParseString("", code)
24 if err != nil {
25 return nil, 0, err
26 }
27 // Ast To Instruction List
28 wordList, err := astToInstruction(casmAst)
29 if err != nil {
30 return nil, 0, err
31 }
32 // Instruction to bytecode
33 return encodeInstructionListToBytecode(wordList)
34}
35
36// Given a CASM ast it returns a list of instructions
37func astToInstruction(ast *CasmProgram) ([]Word, error) {

Callers 5

AddInlineCASMMethod · 0.92
createProgramFunction · 0.92
TestDisasmFunction · 0.92
parseSingleInstructionFunction · 0.85

Calls 2

astToInstructionFunction · 0.85

Tested by 4

createProgramFunction · 0.74
TestDisasmFunction · 0.74
parseSingleInstructionFunction · 0.68