MCPcopy Create free account
hub / github.com/aspizu/goboscript / proc

Method proc

src/codegen/sb3.rs:912–984  ·  view source on GitHub ↗
(&mut self, s: S, d: D, proc: &Proc, definition: &[Stmt])

Source from the content-addressed store, hash-verified

910 }
911
912 pub fn proc(&mut self, s: S, d: D, proc: &Proc, definition: &[Stmt]) -> io::Result<()> {
913 let this_id = self.id.new_id();
914 let prototype_id = self.id.new_id();
915 let next_id = self.id.new_id();
916 self.begin_node(
917 Node::new("procedures_definition", this_id)
918 .some_next_id((!definition.is_empty()).then_some(next_id))
919 .top_level(true),
920 )?;
921 self.begin_inputs()?;
922 write!(self, r#""custom_block":[1,{prototype_id}]"#)?;
923 self.end_obj()?; // inputs
924 self.end_obj()?; // node
925 let mut qualified_args: Vec<(SmolStr, NodeID)> = Vec::new();
926 for arg in &proc.args {
927 match &arg.type_ {
928 Type::Value => {
929 let arg_id = self.id.new_id();
930 self.begin_node(
931 Node::new("argument_reporter_string_number", arg_id)
932 .parent_id(prototype_id)
933 .shadow(true),
934 )?;
935 self.single_field("VALUE", &arg.name)?;
936 self.end_obj()?; // node
937 qualified_args.push((arg.name.clone(), arg_id));
938 }
939 Type::Struct {
940 name: type_name,
941 span: type_span,
942 } => {
943 let Some(struct_) = s.get_struct(type_name) else {
944 d.report(
945 DiagnosticKind::UnrecognizedStruct(type_name.clone()),
946 type_span,
947 );
948 continue;
949 };
950 for field in &struct_.fields {
951 let qualified_arg_name = qualify_struct_var_name(&field.name, &arg.name);
952 let arg_id = self.id.new_id();
953 self.begin_node(
954 Node::new("argument_reporter_string_number", arg_id)
955 .parent_id(prototype_id)
956 .shadow(true),
957 )?;
958 self.single_field("VALUE", &qualified_arg_name)?;
959 self.end_obj()?; // node
960 qualified_args.push((qualified_arg_name, arg_id));
961 }
962 }
963 }
964 }
965 self.begin_node(
966 Node::new("procedures_prototype", prototype_id)
967 .parent_id(this_id)
968 .shadow(true),
969 )?;

Callers 1

spriteMethod · 0.80

Calls 15

newFunction · 0.85
qualify_struct_var_nameFunction · 0.85
write_comma_ioFunction · 0.85
new_idMethod · 0.80
begin_nodeMethod · 0.80
top_levelMethod · 0.80
some_next_idMethod · 0.80
begin_inputsMethod · 0.80
end_objMethod · 0.80
shadowMethod · 0.80
parent_idMethod · 0.80
single_fieldMethod · 0.80

Tested by

no test coverage detected