dtr_to_rust 0.14.2 → 0.14.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/soroban_rust_backend.rb +74 -34
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89096f004528aaecd190ff234014d8c49044387b63972e287641e7489f989f18
4
- data.tar.gz: 434c3a8dced0b5e66fe8479365f54d743206066b7ab44520f71ba0a04d42b511
3
+ metadata.gz: 8afcaa16021e50bca0453d0606605882221cb0c1ed4622e6e6020041017435a0
4
+ data.tar.gz: 43716ca6c7d168719830e1b1d4c409e5c08701add9fa24eb3e23c17c68a550bb
5
5
  SHA512:
6
- metadata.gz: cc4a2fe2c2169d03ab942b8fd851ecb77b5f288471982b0d0d9c3975bbff53864cf2784d7a665842505603cd1ee75b5ff8226f71e1576e5b0bb646afd0e86a6c
7
- data.tar.gz: 354c272f2823a9caab439bfc799fca79b4c38b64c0ac908fa6e1aa41a61238696721a25e2e2cb47bad39c6cbb29a9f281faf3cf3de696c3eec9ba9c8d70ee8a1
6
+ metadata.gz: b5bc17121cceac4499d34be2eef0cd0d9bf6573cdef8f34ab8932a040f4f5e878641ccfc32299e17427a44e0b0be4ad8b5c7647e8c0e61755f333258e57c3341
7
+ data.tar.gz: 5e77a1809d1d4cbcff4a5e59537591e74244d7e8a461d91b3b9220cfc1120f474e734def4a1fe0db08049707053560c9416f957bedc99e7b263d36b91f2af5cb
@@ -1,50 +1,90 @@
1
+ require 'dtr_core'
2
+
1
3
  # This is the main module for the DTR to Rust gem.
2
4
  module SorobanRustBackend
3
- autoload :LCPBT_Forrest, 'lcpbt_forrest'
4
- autoload :LeftChildPreferentialBinaryTree, 'left_child_preferential_binary_tree'
5
- autoload :Silviculturist, 'silviculturist'
6
- autoload :CodeGenerator, 'code_generator'
7
- autoload :Condenser, 'condenser'
8
- autoload :InstructionHandler, 'instruction_handler'
9
- autoload :UserDefinedTypesHandler, 'user_defined_types_handler'
10
- autoload :FunctionHandler, 'function_handler'
11
- autoload :ContractHandler, 'contract_handler'
5
+ autoload :LCPBT_Forrest, './lib/lcpbt_forrest'
6
+ autoload :LeftChildPreferentialBinaryTree, './lib/left_child_preferential_binary_tree'
7
+ autoload :Silviculturist, './lib/silviculturist'
8
+ autoload :CodeGenerator, './lib/code_generator'
9
+ autoload :Condenser, './lib/condenser'
10
+ autoload :InstructionHandler, './lib/instruction_handler'
11
+ autoload :UserDefinedTypesHandler, './lib/user_defined_types_handler'
12
+ autoload :FunctionHandler, './lib/function_handler'
13
+ autoload :ContractHandler, './lib/contract_handler'
12
14
 
13
15
  # This module contains all the classes that handle the different types of instructions.
14
16
  module Instruction
15
- autoload :Evaluate, 'instruction/evaluate'
16
- autoload :Field, 'instruction/field'
17
- autoload :Handler, 'instruction/handler'
18
- autoload :Print, 'instruction/print'
19
- autoload :Return, 'instruction/return'
20
- autoload :InstantiateObject, 'instruction/instantiate_object'
21
- autoload :Add, 'instruction/add'
22
- autoload :Subtract, 'instruction/subtract'
23
- autoload :Multiply, 'instruction/multiply'
24
- autoload :Divide, 'instruction/divide'
25
- autoload :Assign, 'instruction/assign'
26
- autoload :Jump, 'instruction/jump'
27
- autoload :Goto, 'instruction/goto'
28
- autoload :ExitWithMessage, 'instruction/exit_with_message'
29
- autoload :And, 'instruction/and'
30
- autoload :Or, 'instruction/or'
31
- autoload :EndOfIterationCheck, 'instruction/end_of_iteration_check'
32
- autoload :Increment, 'instruction/increment'
33
- autoload :TryAssign, 'instruction/try_assign'
34
- autoload :Break, 'instruction/break'
35
- autoload :BinaryInstruction, 'instruction/binary_instruction'
17
+ autoload :Evaluate, './lib/instruction/evaluate'
18
+ autoload :Field, './lib/instruction/field'
19
+ autoload :Handler, './lib/instruction/handler'
20
+ autoload :Print, './lib/instruction/print'
21
+ autoload :Return, './lib/instruction/return'
22
+ autoload :InstantiateObject, './lib/instruction/instantiate_object'
23
+ autoload :Add, './lib/instruction/add'
24
+ autoload :Subtract, './lib/instruction/subtract'
25
+ autoload :Multiply, './lib/instruction/multiply'
26
+ autoload :Divide, './lib/instruction/divide'
27
+ autoload :Assign, './lib/instruction/assign'
28
+ autoload :Jump, './lib/instruction/jump'
29
+ autoload :Goto, './lib/instruction/goto'
30
+ autoload :ExitWithMessage, './lib/instruction/exit_with_message'
31
+ autoload :And, './lib/instruction/and'
32
+ autoload :Or, './lib/instruction/or'
33
+ autoload :EndOfIterationCheck, './lib/instruction/end_of_iteration_check'
34
+ autoload :Increment, './lib/instruction/increment'
35
+ autoload :TryAssign, './lib/instruction/try_assign'
36
+ autoload :Break, './lib/instruction/break'
37
+ autoload :BinaryInstruction, './lib/instruction/binary_instruction'
36
38
  end
37
39
 
38
40
  module Common
39
- autoload :TypeTranslator, 'common/type_translator'
40
- autoload :InputInterpreter, 'common/input_interpreter'
41
+ autoload :TypeTranslator, './lib/common/type_translator'
42
+ autoload :InputInterpreter, './lib/common/input_interpreter'
41
43
  end
42
44
 
43
45
  module NonTranslatables
44
- autoload :Handler, 'non_translatables/handler'
46
+ autoload :Handler, './lib/non_translatables/handler'
45
47
  end
46
48
 
47
49
  module ContractState
48
- autoload :Handler, 'contract_state/handler'
50
+ autoload :Handler, './lib/contract_state/handler'
51
+ end
52
+ end
53
+
54
+ def silence_streams
55
+ original_stdout = $stdout
56
+ original_stderr = $stderr
57
+ $stdout = File.new('/dev/null', 'w')
58
+ $stderr = File.new('/dev/null', 'w')
59
+ yield
60
+ ensure
61
+ $stdout = original_stdout
62
+ $stderr = original_stderr
63
+ end
64
+
65
+ if __FILE__ == $PROGRAM_NAME
66
+ input = ARGV[0]
67
+
68
+ if input == 'version'
69
+ gemspec_path = 'dtr_to_rust.gemspec'
70
+
71
+ # Extract version from gemspec
72
+ gemspec = File.read(gemspec_path)
73
+ version_match = gemspec.match(/\.version\s*=\s*["']([^"']+)["']/)
74
+ version = version_match[1] if version_match
75
+
76
+ puts version
77
+ else
78
+
79
+ if input.nil?
80
+ puts 'Usage: ./soroban_rust_backend <file_path>'
81
+ exit(1)
82
+ end
83
+
84
+ json_for_web = silence_streams do
85
+ SorobanRustBackend::ContractHandler.generate(DTRCore::Contract.from_dtr_raw(File.read(input)))
86
+ end
87
+
88
+ puts json_for_web
49
89
  end
50
90
  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.14.2
4
+ version: 0.14.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Durst