dtr_to_rust 0.14.2 → 0.14.4

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 +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89096f004528aaecd190ff234014d8c49044387b63972e287641e7489f989f18
4
- data.tar.gz: 434c3a8dced0b5e66fe8479365f54d743206066b7ab44520f71ba0a04d42b511
3
+ metadata.gz: 4e272b782fcef4516963edca1e54f7c4e6b810c052d3056e0ad4db64cb7940eb
4
+ data.tar.gz: 6ea83a903fa9354a2d686e185b6a6fa10df4dde2f6817a37fd088badfae0141b
5
5
  SHA512:
6
- metadata.gz: cc4a2fe2c2169d03ab942b8fd851ecb77b5f288471982b0d0d9c3975bbff53864cf2784d7a665842505603cd1ee75b5ff8226f71e1576e5b0bb646afd0e86a6c
7
- data.tar.gz: 354c272f2823a9caab439bfc799fca79b4c38b64c0ac908fa6e1aa41a61238696721a25e2e2cb47bad39c6cbb29a9f281faf3cf3de696c3eec9ba9c8d70ee8a1
6
+ metadata.gz: 4eff1cc6d80e34af630f638e852decd536c80bcd20451bb71e9aaf5a45d79b2352cd086982c9d9f8cfa76a84edb729939251ef187ddf0ded673b1f0058bb544e
7
+ data.tar.gz: 8098bdeb63b552c6f92b00b4a0eedd77d787d4f0ecf3f0feb3d0fe2440ab3ee849940d168086d55dffe6899aebc303a9ce95868e0e677dfbaaf1b3711575be99
@@ -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,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.14.2
4
+ version: 0.14.4
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-07-16 00:00:00.000000000 Z
11
+ date: 2024-07-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Rust to DTR translator (Digicus Textual Representation).
14
14
  email: