dtr_to_rust 0.2.3 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb46c1422d17df3435c4e14aeb89f533cd11254e2403b5d3bbb5ac096601c36b
4
- data.tar.gz: 170d3fa2036398a08eafad71dafd930c08809c0cb996026a97762c867a8211ea
3
+ metadata.gz: b0e88ee729d6b75560b0b721116d5d01a09b0461be73ce60f7866811ac852ddb
4
+ data.tar.gz: ec23afaf87408739dc2e85a6c205dc70b58518a200c8aa7452d8cc65e867c3a7
5
5
  SHA512:
6
- metadata.gz: dbe8b2b0266cd6a5aa7446fcf26c986dd41e54662d59f186e2b446ad124a71c70f893b786eb300d67a51aea1392dc325c12c60f05ec568aa48007aacda5d2cd5
7
- data.tar.gz: ad1e85bd2f9b50ad00e802de6244f88a853c6861d54dff172df4e319d669131ecd898e9495a27b3515fc1e5d88bdea4e042931b79d085834d21cc784721a5c10
6
+ metadata.gz: b81c54febc129a193a215dd67fd29e88b6378d469752d39c3a3a258eb3d702230f48f92560938cf0ba176360ad13c2e05d1fa78e2802dc67bccd173875a72024
7
+ data.tar.gz: 00ad6c66f66e8c162860db52d7518b1633e8ecf2877c0ccd3bc09bf0c28157fbdb1627b046039af04ca570828bf2cb6a6ecf8514a7aa5d32f7a8adf272bcfd13
data/lib/dtr_to_rust.rb CHANGED
@@ -7,11 +7,12 @@ module DTRToRust
7
7
 
8
8
  # This module contains all the classes that handle the different types of instructions.
9
9
  module Instruction
10
- autoload :Handler, 'instruction/handler'
10
+ autoload :AddAndAssign, 'instruction/add_and_assign'
11
+ autoload :CreateList, 'instruction/create_list'
11
12
  autoload :Evaluate, 'instruction/evaluate'
12
- autoload :Return, 'instruction/return'
13
13
  autoload :LogString, 'instruction/log_string'
14
- autoload :AddAndAssign, 'instruction/add_and_assign'
14
+ autoload :Handler, 'instruction/handler'
15
+ autoload :Return, 'instruction/return'
15
16
  end
16
17
 
17
18
  # This module contains all the classes that handle common logic.
data/lib/generator.rb CHANGED
@@ -94,6 +94,10 @@ module DTRToRust
94
94
  case type
95
95
  when 'String'
96
96
  'Symbol'
97
+ when 'Vec<String>'
98
+ 'Vec<Symbol>'
99
+ when 'List<String>'
100
+ 'Vec<Symbol>'
97
101
  else
98
102
  type
99
103
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DTRToRust
4
+ module Instruction
5
+ # This class is responsible for generating Rust code for the AddAndAssign instruction.
6
+ class CreateList < Handler
7
+ def handle
8
+ form_rust_string("let #{@instruction[:assign]} = vec![#{handle_inputs}];",
9
+ @instruction[:scope])
10
+ end
11
+
12
+ private
13
+
14
+ def handle_inputs
15
+ @instruction[:inputs].map { |input| handle_input(input) }.join(', ')
16
+ end
17
+
18
+ def handle_input(input)
19
+ if (input.start_with?('"') && input[-1] == ('"'))
20
+ "symbol_short!(#{input})"
21
+ else
22
+ input
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -17,6 +17,8 @@ module DTRToRust
17
17
  Instruction::AddAndAssign.handle(@instruction)
18
18
  when 'evaluate'
19
19
  Instruction::Evaluate.handle(@instruction)
20
+ when 'create_list'
21
+ Instruction::CreateList.handle(@instruction)
20
22
  else
21
23
  raise "Unknown instruction type: #{@instruction[:instruction]}"
22
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dtr_to_rust
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Durst
@@ -21,6 +21,7 @@ files:
21
21
  - lib/dtr_to_rust.rb
22
22
  - lib/generator.rb
23
23
  - lib/instruction/add_and_assign.rb
24
+ - lib/instruction/create_list.rb
24
25
  - lib/instruction/evaluate.rb
25
26
  - lib/instruction/handler.rb
26
27
  - lib/instruction/log_string.rb