@@ -73,14 +73,17 @@ impl BrilligArtifact {
73
73
}
74
74
}
75
75
76
- /// Creates an entry point artifact wrapping the bytecode of the function provided.
77
- pub ( crate ) fn to_entry_point_artifact ( artifact : & BrilligArtifact ) -> BrilligArtifact {
78
- let mut entry_point_artifact =
79
- BrilligArtifact :: new ( artifact. arguments . clone ( ) , artifact. return_parameters . clone ( ) ) ;
76
+ /// Creates an entry point artifact that will jump to the function label provided.
77
+ pub ( crate ) fn new_entry_point_artifact (
78
+ arguments : Vec < BrilligParameter > ,
79
+ return_parameters : Vec < BrilligParameter > ,
80
+ target_function : Label ,
81
+ ) -> BrilligArtifact {
82
+ let mut entry_point_artifact = BrilligArtifact :: new ( arguments, return_parameters) ;
80
83
entry_point_artifact. entry_point_instruction ( ) ;
81
84
82
- entry_point_artifact. add_unresolved_jumps_and_calls ( artifact ) ;
83
- entry_point_artifact . byte_code . extend_from_slice ( & artifact . byte_code ) ;
85
+ entry_point_artifact
86
+ . add_unresolved_external_call ( BrilligOpcode :: Call { location : 0 } , target_function ) ;
84
87
85
88
entry_point_artifact. exit_point_instruction ( ) ;
86
89
entry_point_artifact
@@ -126,16 +129,6 @@ impl BrilligArtifact {
126
129
// We want all functions to follow the calling convention of returning
127
130
// their results in the first `n` registers. So we modify the bytecode of the
128
131
// function to move the return values to the first `n` registers once completed.
129
- //
130
- // Swap the stop opcode with a jump to the exit point section
131
-
132
- let stop_position =
133
- self . byte_code . iter ( ) . position ( |opcode| matches ! ( opcode, BrilligOpcode :: Stop ) ) ;
134
-
135
- let stop_position = stop_position. expect ( "expected a stop opcode" ) ;
136
-
137
- let exit_section = self . index_of_next_opcode ( ) ;
138
- self . byte_code [ stop_position] = BrilligOpcode :: Jump { location : exit_section } ;
139
132
140
133
// TODO: this _seems_ like an abstraction leak, we need to know about the reserved
141
134
// TODO: registers in order to do this.
0 commit comments