Skip to content

Commit b88c28f

Browse files
committed
Use keyword arguments for Immediate#initialize (closes #63).
1 parent 2a55fc7 commit b88c28f

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

lib/ronin/asm/immediate.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class Immediate < Operand
5555
# @param [nil, 1, 2, 4, 8] width
5656
# The size in bytes of the value.
5757
#
58-
def initialize(value,width=nil)
58+
def initialize(value, width: nil)
5959
@value = value.to_i
6060
@width = width || if @value == 0
6161
1

lib/ronin/asm/program.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def byte(operand)
300300
width: 1
301301
)
302302
else
303-
Immediate.new(operand,1)
303+
Immediate.new(operand, width: 1)
304304
end
305305
end
306306

@@ -324,7 +324,7 @@ def word(operand)
324324
width: 2
325325
)
326326
else
327-
Immediate.new(operand,2)
327+
Immediate.new(operand, width: 2)
328328
end
329329
end
330330

@@ -348,7 +348,7 @@ def dword(operand)
348348
width: 4
349349
)
350350
else
351-
Immediate.new(operand,4)
351+
Immediate.new(operand, width: 4)
352352
end
353353
end
354354

@@ -372,7 +372,7 @@ def qword(operand)
372372
width: 8
373373
)
374374
else
375-
Immediate.new(operand,8)
375+
Immediate.new(operand, width: 8)
376376
end
377377
end
378378

spec/immediate_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
context "with a width" do
99
let(:width) { 2 }
1010

11-
subject { described_class.new(value,width) }
11+
subject { described_class.new(value, width: width) }
1212

1313
it "must set the width" do
1414
expect(subject.width).to eq(width)
@@ -20,7 +20,7 @@
2020
context "when #width is 1" do
2121
let(:width) { 1 }
2222

23-
subject { described_class.new(value,width) }
23+
subject { described_class.new(value, width: width) }
2424

2525
it "must return :imm8" do
2626
expect(subject.type).to eq(:imm8)
@@ -30,7 +30,7 @@
3030
context "when #width is 2" do
3131
let(:width) { 2 }
3232

33-
subject { described_class.new(value,width) }
33+
subject { described_class.new(value, width: width) }
3434

3535
it "must return :imm16" do
3636
expect(subject.type).to eq(:imm16)
@@ -40,7 +40,7 @@
4040
context "when #width is 4" do
4141
let(:width) { 4 }
4242

43-
subject { described_class.new(value,width) }
43+
subject { described_class.new(value, width: width) }
4444

4545
it "must return :imm32" do
4646
expect(subject.type).to eq(:imm32)
@@ -50,7 +50,7 @@
5050
context "when #width is 8" do
5151
let(:width) { 8 }
5252

53-
subject { described_class.new(value,width) }
53+
subject { described_class.new(value, width: width) }
5454

5555
it "must return :imm64" do
5656
expect(subject.type).to eq(:imm64)

spec/instruction_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
describe Ronin::ASM::Instruction do
99
let(:register) { Ronin::ASM::Register.new(:eax, width: 4) }
10-
let(:immediate) { Ronin::ASM::Immediate.new(0xff, 1) }
10+
let(:immediate) { Ronin::ASM::Immediate.new(0xff, width: 1) }
1111

1212
describe "#initialize" do
1313
let(:name) { :mov }

spec/syntax/att_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
end
2020

2121
describe ".emit_immediate" do
22-
let(:operand) { Ronin::ASM::Immediate.new(255, 1) }
22+
let(:operand) { Ronin::ASM::Immediate.new(255, width: 1) }
2323

2424
it "must prepend a '$' to the immediate" do
2525
expect(subject.emit_immediate(operand)).to eq("$0xff")
@@ -87,7 +87,7 @@
8787

8888
context "with one operand" do
8989
context "with width of 1" do
90-
let(:immediate) { Ronin::ASM::Immediate.new(0x80, 1) }
90+
let(:immediate) { Ronin::ASM::Immediate.new(0x80, width: 1) }
9191
let(:instruction) { Ronin::ASM::Instruction.new(:int, immediate) }
9292

9393
it "must not append a size specifier to the instruction name" do
@@ -98,7 +98,7 @@
9898

9999
context "with multiple operands" do
100100
let(:register) { Ronin::ASM::Register.new(:eax, width: 4) }
101-
let(:immediate) { Ronin::ASM::Immediate.new(0xff, 1) }
101+
let(:immediate) { Ronin::ASM::Immediate.new(0xff, width: 1) }
102102
let(:instruction) { Ronin::ASM::Instruction.new(:mov, register, immediate) }
103103

104104
it "must add a size specifier to the instruction name" do

spec/syntax/intel_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
end
2020

2121
describe ".emit_immediate" do
22-
let(:operand) { Ronin::ASM::Immediate.new(255, 1) }
22+
let(:operand) { Ronin::ASM::Immediate.new(255, width: 1) }
2323

2424
it "must prepend a size specifier" do
2525
expect(subject.emit_immediate(operand)).to eq("BYTE 0xff")
@@ -96,7 +96,7 @@
9696

9797
context "with multiple operands" do
9898
let(:register) { Ronin::ASM::Register.new(:eax, width: 4) }
99-
let(:immediate) { Ronin::ASM::Immediate.new(0xff, 1) }
99+
let(:immediate) { Ronin::ASM::Immediate.new(0xff, width: 1) }
100100
let(:instruction) { Ronin::ASM::Instruction.new(:mov, register, immediate) }
101101

102102
it "must emit the operands" do

0 commit comments

Comments
 (0)