6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/milk_tea/tooling/cli/commands/emit_c.rb', line 6
def emit_c_command
args = @argv.dup
@argv = []
until args.empty?
arg = args.shift
@argv << arg
end
unless @argv.any?
@err.puts("missing source file path")
print_usage(@err)
return 1
end
resolution =
input_paths = @argv.dup
return 1 unless ensure_known_source_operands!("emit-c", input_paths)
program_paths = input_paths.map { |p| resolve_program_path(p) }
return 1 if program_paths.include?(nil)
ensure_current_lockfiles!(input_paths) if resolution[:frozen]
multiple = program_paths.length > 1
program_paths.each_with_index do |path, index|
program = make_module_loader(path, locked: resolution[:locked], platform: ModuleLoader.default_host_platform).check_program(path)
if multiple
@out.puts("/* --- #{path} --- */")
end
@out.write(CBackend.generate_c(Lowering.lower(program), emit_line_directives: false))
@out.puts if multiple && index < program_paths.length - 1
end
0
end
|