Skip to content

Commit febd25c

Browse files
committed
Reduce nesting blocks
1 parent af90f31 commit febd25c

File tree

1 file changed

+55
-54
lines changed

1 file changed

+55
-54
lines changed

ext/sass/Rakefile

Lines changed: 55 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ file 'true' do |t|
206206
# 400078: 31 ff xorl %edi, %edi
207207
# 40007a: b8 3c 00 00 00 movl $0x3c, %eax
208208
# 40007f: 0f 05 syscall
209-
entry_point = %w[31ff b83c000000 0f05].pack('H*H*H*')
209+
entry_point = %w[31ffb83c0000000f05].pack('H*')
210210
when 'i386'
211211
ei_class = ELF::ELFCLASS32
212212
ei_data = ELF::ELFDATA2LSB
@@ -217,68 +217,69 @@ file 'true' do |t|
217217
# 400054: 31 db xorl %ebx, %ebx
218218
# 400056: b8 01 00 00 00 movl $0x1, %eax
219219
# 40005b: cd 80 int $0x80
220-
entry_point = %w[31db b801000000 cd80].pack('H*H*H*')
220+
entry_point = %w[31dbb801000000cd80].pack('H*')
221221
else
222222
raise NotImplementedError
223223
end
224224

225-
File.open(t.name, 'wb', 0o755) do |file|
226-
ELF.allocate.instance_eval do
227-
case ei_class
228-
when ELF::ELFCLASS32
229-
e_ehsize = ELF::Elf32_Ehdr.sizeof
230-
e_phentsize = ELF::Elf32_Phdr.sizeof
231-
e_shentsize = ELF::Elf32_Shdr.sizeof
232-
when ELF::ELFCLASS64
233-
e_ehsize = ELF::Elf64_Ehdr.sizeof
234-
e_phentsize = ELF::Elf64_Phdr.sizeof
235-
e_shentsize = ELF::Elf64_Shdr.sizeof
236-
else
237-
raise EncodingError
238-
end
225+
case ei_class
226+
when ELF::ELFCLASS32
227+
e_ehsize = ELF::Elf32_Ehdr.sizeof
228+
e_phentsize = ELF::Elf32_Phdr.sizeof
229+
e_shentsize = ELF::Elf32_Shdr.sizeof
230+
when ELF::ELFCLASS64
231+
e_ehsize = ELF::Elf64_Ehdr.sizeof
232+
e_phentsize = ELF::Elf64_Phdr.sizeof
233+
e_shentsize = ELF::Elf64_Shdr.sizeof
234+
else
235+
raise EncodingError
236+
end
239237

240-
p_offset = e_ehsize + e_phentsize
241-
p_vaddr = (2**22) + p_offset
242-
p_filesz = entry_point.length
243-
p_memsz = p_filesz
244-
e_phoff = e_ehsize
245-
246-
e_entry = p_vaddr
247-
e_entry += 1 if Platform::CPU == 'arm'
248-
249-
@ehdr = {
250-
e_ident: [127, 69, 76, 70, ei_class, ei_data, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
251-
e_type: ELF::ET_EXEC,
252-
e_machine:,
253-
e_version: 1,
254-
e_entry:,
255-
e_phoff:,
256-
e_shoff: 0,
257-
e_flags:,
258-
e_ehsize:,
259-
e_phentsize:,
260-
e_phnum: 1,
261-
e_shentsize:,
262-
e_shnum: 0,
263-
e_shstrndx: 0
238+
e_phoff = e_ehsize
239+
240+
p_offset = e_phoff + e_phentsize
241+
p_vaddr = (2**22) + p_offset
242+
p_filesz = entry_point.length
243+
p_memsz = p_filesz
244+
245+
e_entry = p_vaddr
246+
e_entry += 1 if Platform::CPU == 'arm'
247+
248+
ELF.allocate.instance_eval do
249+
@ehdr = {
250+
e_ident: [127, 69, 76, 70, ei_class, ei_data, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
251+
e_type: ELF::ET_EXEC,
252+
e_machine:,
253+
e_version: 1,
254+
e_entry:,
255+
e_phoff:,
256+
e_shoff: 0,
257+
e_flags:,
258+
e_ehsize:,
259+
e_phentsize:,
260+
e_phnum: 1,
261+
e_shentsize:,
262+
e_shnum: 0,
263+
e_shstrndx: 0
264+
}
265+
@phdrs = [
266+
{
267+
p_type: ELF::PT_LOAD,
268+
p_flags: ELF::PF_R | ELF::PF_X,
269+
p_offset:,
270+
p_vaddr:,
271+
p_paddr: 0,
272+
p_filesz:,
273+
p_memsz:,
274+
p_align: 4096
264275
}
265-
@phdrs = [
266-
{
267-
p_type: ELF::PT_LOAD,
268-
p_flags: ELF::PF_R | ELF::PF_X,
269-
p_offset:,
270-
p_vaddr:,
271-
p_paddr: 0,
272-
p_filesz:,
273-
p_memsz:,
274-
p_align: 4096
275-
}
276-
]
277-
@shdrs = []
276+
]
277+
@shdrs = []
278278

279+
File.open(t.name, 'wb', 0o755) do |file|
279280
dump(file)
281+
file.write(entry_point)
280282
end
281-
file.write(entry_point)
282283
end
283284
end
284285

0 commit comments

Comments
 (0)