dtr_to_rust 0.2.10 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/lib/aggregator/scope_block_aggregator.rb +72 -0
  3. data/lib/common/input_interpreter.rb +12 -1
  4. data/lib/common/reference_appender.rb +59 -0
  5. data/lib/common/type_translator.rb +22 -0
  6. data/lib/dtr_to_rust.rb +34 -4
  7. data/lib/generator.rb +105 -32
  8. data/lib/instruction/add.rb +12 -0
  9. data/lib/instruction/and.rb +19 -0
  10. data/lib/instruction/assign.rb +16 -0
  11. data/lib/instruction/divide.rb +12 -0
  12. data/lib/instruction/end_of_iteration_check.rb +11 -0
  13. data/lib/instruction/evaluate.rb +92 -17
  14. data/lib/instruction/exit_with_message.rb +18 -0
  15. data/lib/instruction/field.rb +3 -3
  16. data/lib/instruction/goto.rb +12 -0
  17. data/lib/instruction/handler.rb +11 -7
  18. data/lib/instruction/increment.rb +11 -0
  19. data/lib/instruction/instantiate_object.rb +78 -0
  20. data/lib/instruction/jump.rb +28 -0
  21. data/lib/instruction/label.rb +12 -0
  22. data/lib/instruction/multiply.rb +12 -0
  23. data/lib/instruction/or.rb +19 -0
  24. data/lib/instruction/{log_string.rb → print.rb} +2 -2
  25. data/lib/instruction/return.rb +1 -1
  26. data/lib/instruction/subtract.rb +13 -0
  27. data/lib/instruction_handler.rb +34 -18
  28. data/lib/optimization/binary_x_to_self_assignment_reduction.rb +93 -0
  29. data/lib/optimization/chained_invocation_assignment_reduction.rb +123 -0
  30. data/lib/optimization/field_to_assignment_conversion.rb +37 -0
  31. data/lib/user_defined_types/handler.rb +78 -0
  32. metadata +25 -7
  33. data/lib/instruction/add_and_assign.rb +0 -12
  34. data/lib/instruction/create_list.rb +0 -31
  35. data/lib/instruction/initialize_udt.rb +0 -22
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dtr_to_rust
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.10
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Durst
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-16 00:00:00.000000000 Z
11
+ date: 2024-06-23 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Rust to DTR translator (Digicus Textual Representation).
14
14
  email:
@@ -17,18 +17,36 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - lib/aggregator/scope_block_aggregator.rb
20
21
  - lib/common/input_interpreter.rb
22
+ - lib/common/reference_appender.rb
23
+ - lib/common/type_translator.rb
21
24
  - lib/dtr_to_rust.rb
22
25
  - lib/generator.rb
23
- - lib/instruction/add_and_assign.rb
24
- - lib/instruction/create_list.rb
26
+ - lib/instruction/add.rb
27
+ - lib/instruction/and.rb
28
+ - lib/instruction/assign.rb
29
+ - lib/instruction/divide.rb
30
+ - lib/instruction/end_of_iteration_check.rb
25
31
  - lib/instruction/evaluate.rb
32
+ - lib/instruction/exit_with_message.rb
26
33
  - lib/instruction/field.rb
34
+ - lib/instruction/goto.rb
27
35
  - lib/instruction/handler.rb
28
- - lib/instruction/initialize_udt.rb
29
- - lib/instruction/log_string.rb
36
+ - lib/instruction/increment.rb
37
+ - lib/instruction/instantiate_object.rb
38
+ - lib/instruction/jump.rb
39
+ - lib/instruction/label.rb
40
+ - lib/instruction/multiply.rb
41
+ - lib/instruction/or.rb
42
+ - lib/instruction/print.rb
30
43
  - lib/instruction/return.rb
44
+ - lib/instruction/subtract.rb
31
45
  - lib/instruction_handler.rb
46
+ - lib/optimization/binary_x_to_self_assignment_reduction.rb
47
+ - lib/optimization/chained_invocation_assignment_reduction.rb
48
+ - lib/optimization/field_to_assignment_conversion.rb
49
+ - lib/user_defined_types/handler.rb
32
50
  homepage: https://spaced-out-thoughts-dev-foundation.github.io/digicus/
33
51
  licenses:
34
52
  - MIT
@@ -49,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
67
  - !ruby/object:Gem::Version
50
68
  version: '0'
51
69
  requirements: []
52
- rubygems_version: 3.4.10
70
+ rubygems_version: 3.5.13
53
71
  signing_key:
54
72
  specification_version: 4
55
73
  summary: Rust to DTR translator (Digicus Textual Representation).
@@ -1,12 +0,0 @@
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 AddAndAssign < Handler
7
- def handle
8
- form_rust_string("#{@instruction[:inputs][0]} += #{@instruction[:inputs][1]};", @instruction[:scope])
9
- end
10
- end
11
- end
12
- end
@@ -1,31 +0,0 @@
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
- decorated_input = Common::InputInterpreter.interpret(input)
20
-
21
- if decorated_input[:type] == 'string'
22
- "symbol_short!(#{input})"
23
- elsif decorated_input[:needs_reference] && input == 'env'
24
- "&#{input}"
25
- else
26
- input
27
- end
28
- end
29
- end
30
- end
31
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module DTRToRust
4
- module Instruction
5
- # This class is responsible for generating Rust code for the Field instruction.
6
- class InitializeUDT < Handler
7
- def handle
8
- form_rust_string("#{handle_assign}#{handle_udt_part}", @instruction[:scope])
9
- end
10
-
11
- private
12
-
13
- def handle_udt_part
14
- "#{@instruction[:inputs][0]} { #{@instruction[:inputs][1..].join(' ')} };"
15
- end
16
-
17
- def handle_assign
18
- "let mut #{@instruction[:assign]} = " if @instruction[:assign]
19
- end
20
- end
21
- end
22
- end