From 15b6d4921a746828ac869e891372690222729796 Mon Sep 17 00:00:00 2001 From: "Mariano A. Nicolini" Date: Tue, 11 Jul 2023 13:27:30 -0300 Subject: [PATCH] Fix naming convention (#9) --- pkg/vm/instruction.go | 22 +++++++++++----------- pkg/vm/memory/memory.go | 4 ++-- pkg/vm/memory/relocatable.go | 10 +++++----- pkg/vm/memory/segments.go | 4 ++-- pkg/vm/program.go | 3 +-- pkg/vm/vm_core.go | 6 +++--- 6 files changed, 24 insertions(+), 25 deletions(-) diff --git a/pkg/vm/instruction.go b/pkg/vm/instruction.go index e27e075..710cdde 100644 --- a/pkg/vm/instruction.go +++ b/pkg/vm/instruction.go @@ -19,17 +19,17 @@ package vm // Some instructions spread over two words when they use an immediate value, so // representing the first one with this struct is enougth. type Instruction struct { - off_dst int - off_op0 int - off2_op1 int - dst_reg Register - op0_reg Register - op1_addr Op1Src - res_logic ResLogic - pc_update PcUpdate - ap_update ApUpdate - fp_update FpUpdate - opcode Opcode + offDst int + offOp0 int + offOp1 int + dstReg Register + op0Reg Register + op1Addr Op1Src + resLogic ResLogic + pcUpdate PcUpdate + apUpdate ApUpdate + fpUpdate FpUpdate + opcode Opcode } // x-----------------------------x diff --git a/pkg/vm/memory/memory.go b/pkg/vm/memory/memory.go index 4125ca3..fba6a05 100644 --- a/pkg/vm/memory/memory.go +++ b/pkg/vm/memory/memory.go @@ -20,7 +20,7 @@ func (m *Memory) Insert(addr *Relocatable, val *MaybeRelocatable) error { // FIXME: There should be a special handling if the key // segment index is negative. This is an edge // case, so for now let's raise an error. - if addr.segment_index < 0 { + if addr.segmentIndex < 0 { return errors.New("Segment index of key is negative - unimplemented") } @@ -61,7 +61,7 @@ func (m *Memory) Get(addr *Relocatable) (*MaybeRelocatable, error) { // FIXME: There should be a special handling if the key // segment index is negative. This is an edge // case, so for now let's raise an error. - if addr.segment_index < 0 { + if addr.segmentIndex < 0 { return nil, errors.New("Segment index of key is negative - unimplemented") } diff --git a/pkg/vm/memory/relocatable.go b/pkg/vm/memory/relocatable.go index fff5529..8a6654a 100644 --- a/pkg/vm/memory/relocatable.go +++ b/pkg/vm/memory/relocatable.go @@ -5,8 +5,8 @@ package memory // these values are replaced by real memory addresses, // represented by a field element. type Relocatable struct { - segment_index int - offset uint + segmentIndex int + offset uint } // Creates a new Relocatable struct with the specified segment index @@ -18,12 +18,12 @@ func NewRelocatable(segment_idx int, offset uint) *Relocatable { // Get the the indexes of the Relocatable struct. // Returns a tuple with both values (segment_index, offset) func (r *Relocatable) into_indexes() (uint, uint) { - if r.segment_index < 0 { - corrected_segment_idx := uint(-(r.segment_index + 1)) + if r.segmentIndex < 0 { + corrected_segment_idx := uint(-(r.segmentIndex + 1)) return corrected_segment_idx, r.offset } - return uint(r.segment_index), r.offset + return uint(r.segmentIndex), r.offset } // Int in the Cairo VM represents a value in memory that diff --git a/pkg/vm/memory/segments.go b/pkg/vm/memory/segments.go index 9c9fc6f..3fc1c02 100644 --- a/pkg/vm/memory/segments.go +++ b/pkg/vm/memory/segments.go @@ -4,6 +4,6 @@ package memory // Also holds metadata useful for the relocation process of // the memory at the end of the VM run. type MemorySegmentManager struct { - segment_sizes map[uint]uint - memory Memory + segmentSizes map[uint]uint + memory Memory } diff --git a/pkg/vm/program.go b/pkg/vm/program.go index a8acb06..287ed4e 100644 --- a/pkg/vm/program.go +++ b/pkg/vm/program.go @@ -1,6 +1,5 @@ package vm type Program struct { - // FIXME: Should be a list of felts or MaybeRelocatables. - data []uint + Data []uint } diff --git a/pkg/vm/vm_core.go b/pkg/vm/vm_core.go index a168762..38abb8c 100644 --- a/pkg/vm/vm_core.go +++ b/pkg/vm/vm_core.go @@ -5,7 +5,7 @@ import "github.com/lambdaclass/cairo-vm.go/pkg/vm/memory" // VirtualMachine represents the Cairo VM. // Runs Cairo assembly and produces an execution trace. type VirtualMachine struct { - run_conext RunContext - current_step uint - segments memory.MemorySegmentManager + runContext RunContext + currentStep uint + segments memory.MemorySegmentManager }