Bases: ExpressionModuleVisitorMixin, ExpressionMutationVisitorMixin, ExpressionClassVisitorMixin, ExpressionOperatorVisitorMixin, ExpressionArrayVisitorMixin, ExpressionTensorBufferVisitorMixin, ExpressionLiteralVisitorMixin
Compose the expression-focused semantic mixins so the analyzer keeps the
same visitor surface while the implementation stays split by concern.
Methods:
visit
visit(node: FunctionCall) -> None
Source code in packages/irx/src/irx/analysis/handlers/_expressions/modules.py
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376 | @SemanticAnalyzerCore.visit.dispatch
def visit(self, node: astx.FunctionCall) -> None:
"""
title: Visit FunctionCall nodes.
parameters:
node:
type: astx.FunctionCall
"""
arg_types: list[astx.DataType | None] = []
for arg in node.args:
self.visit(arg)
arg_types.append(self._expr_type(arg))
binding = self.bindings.resolve(node.fn)
if binding is None:
self.context.diagnostics.add(
f"cannot resolve function '{node.fn}'",
node=node,
code=DiagnosticCodes.SEMANTIC_UNRESOLVED_NAME,
)
return
if binding.kind != "function" or binding.function is None:
self.context.diagnostics.add(
f"name '{node.fn}' does not resolve to a function",
node=node,
code=DiagnosticCodes.SEMANTIC_UNRESOLVED_NAME,
)
return
function = binding.function
target_function = function
validation_function = function
if function.template_params:
resolved_specialization = self._resolve_template_call_target(
function,
arg_types,
node,
)
if resolved_specialization is None:
self._set_type(node, None)
return
target_function = resolved_specialization
validation_function = replace(
resolved_specialization,
name=function.name,
)
self._set_function(node, target_function)
call_resolution = validate_call(
self.context.diagnostics,
function=validation_function,
arg_types=arg_types,
node=node,
)
if validation_function is not target_function:
call_resolution = replace(
call_resolution,
callee=self.factory.make_callable_resolution(target_function),
signature=target_function.signature,
result_type=target_function.signature.return_type,
)
self._set_call(node, call_resolution)
self._set_type(node, call_resolution.result_type)
|