MCPcopy Create free account
hub / github.com/ForLoveOfCats/fae / generate_statement

Function generate_statement

src/codegen/codegen.rs:203–314  ·  view source on GitHub ↗

True means break statement loop

(
	context: &mut Context<'a, 'b>,
	generator: &mut G,
	statement: &'b Statement<'a>,
	block_start_defer_len: usize,
	should_generate_defer_stack: &mut bool,
)

Source from the content-addressed store, hash-verified

201
202// True means break statement loop
203fn generate_statement<'a, 'b, G: Generator>(
204 context: &mut Context<'a, 'b>,
205 generator: &mut G,
206 statement: &'b Statement<'a>,
207 block_start_defer_len: usize,
208 should_generate_defer_stack: &mut bool,
209) -> bool {
210 let debug_location = statement.debug_location;
211
212 match &statement.kind {
213 StatementKind::Expression(expression) => {
214 generate_statement_expression(context, generator, expression);
215
216 if let ExpressionKind::Call(call) = &expression.kind {
217 let is_noreturn = context.function_store.shapes.read()[call.function_id.function_shape_index]
218 .as_ref()
219 .unwrap()
220 .read()
221 .return_type
222 .item
223 .is_noreturn(context.type_store);
224
225 if is_noreturn {
226 return true;
227 }
228 }
229 }
230
231 StatementKind::When(block) => {
232 for statement in &block.statements {
233 if generate_statement(context, generator, statement, block_start_defer_len, should_generate_defer_stack) {
234 return true;
235 }
236 }
237 }
238
239 StatementKind::Block(block) => {
240 generate_block(context, generator, block);
241 }
242
243 StatementKind::While(statement) => {
244 let start_index = context.defer_stack.len();
245 context.loop_stack.push(DeferMarker { start_index });
246 generate_while(context, generator, statement, debug_location);
247 context.loop_stack.pop();
248 }
249
250 StatementKind::For(statement) => {
251 let start_index = context.defer_stack.len();
252 context.loop_stack.push(DeferMarker { start_index });
253 generate_for(context, generator, statement, debug_location);
254 context.loop_stack.pop();
255 }
256
257 StatementKind::Binding(binding) => generate_binding(context, generator, binding, debug_location),
258
259 StatementKind::Defer(statement) => {
260 context.defer_stack.push(&statement.statement);

Callers 1

generate_blockFunction · 0.85

Calls 12

generate_blockFunction · 0.85
generate_whileFunction · 0.85
generate_forFunction · 0.85
generate_bindingFunction · 0.85
generate_breakFunction · 0.85
generate_continueFunction · 0.85
generate_expressionFunction · 0.85
generate_yieldMethod · 0.80
as_refMethod · 0.80
generate_returnMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected