MCPcopy Index your code
hub / github.com/aiscriptdev/aiscript / declare_functions

Method declare_functions

aiscript-vm/src/compiler/codegen.rs:152–242  ·  view source on GitHub ↗
(&mut self, stmt: &Stmt<'gc>)

Source from the content-addressed store, hash-verified

150 }
151
152 fn declare_functions(&mut self, stmt: &Stmt<'gc>) -> Result<(), VmError> {
153 match stmt {
154 Stmt::Block { statements, .. } => {
155 for stmt in statements {
156 self.declare_functions(stmt)?;
157 }
158 }
159 Stmt::If {
160 then_branch,
161 else_branch,
162 ..
163 } => {
164 self.declare_functions(then_branch)?;
165 if let Some(else_branch) = else_branch {
166 self.declare_functions(else_branch)?;
167 }
168 }
169 Stmt::Loop { body, .. } => {
170 self.declare_functions(body)?;
171 }
172 Stmt::Let(VariableDecl {
173 initializer: Some(Expr::Lambda { body, .. }),
174 ..
175 }) => {
176 if let Expr::Block { statements, .. } = &**body {
177 for stmt in statements {
178 self.declare_functions(stmt)?;
179 }
180 }
181 }
182 Stmt::Const {
183 initializer: Expr::Lambda { body, .. },
184 ..
185 } => {
186 if let Expr::Block { statements, .. } = &**body {
187 for stmt in statements {
188 self.declare_functions(stmt)?;
189 }
190 }
191 }
192 Stmt::Function(FunctionDecl {
193 name,
194 mangled_name,
195 body,
196 doc,
197 params,
198 ..
199 }) => {
200 if !self.named_id_map.contains_key(mangled_name) {
201 let chunk_id = CHUNK_ID.fetch_add(1, Ordering::AcqRel);
202 let primitive_params = params
203 .iter()
204 .map(|(name, param)| {
205 (
206 name.lexeme.to_owned(),
207 PrimitiveType::from(param.type_hint.unwrap_or_default()),
208 )
209 })

Callers 1

generateMethod · 0.80

Calls 1

error_atMethod · 0.45

Tested by

no test coverage detected