# Node

Function and structure nodes are a direct representation of Lexica source code. They are part of an abstract syntax tree. This module deals with the processing and verification of parsed nodes.

## Structure

| Structure        | Description                                                     |
| ---------------- | --------------------------------------------------------------- |
| Function Type    | Represents the signature of a function including any parameters |
| Node Function    | Represents a parsed function                                    |
| Function Context | Contains the expressions of a function                          |
| Structure        | Represents a structure and its fields                           |

## Queries

### Function Type

#### Return

The processed function type of the requested function.

#### Dependencies

The parsed function type of the requested function.

### Function

#### Return

The function node of the requested function.

#### Dependencies

The directly parsed function of the requested function.

## Expressions

In Lexica, every logical unit of code is an expression. Every expression returns a particular value and type. Code that appears to not have any value such as bindings or mutations have the unit type.

Expressions are stored in a function context object and are accessed through an `ExpressionKey`. Nested expressions are denoted with an `ExpressionKey` rather than the nested expression itself. This indirection makes it cheaper to copy and process expressions.

## Intentions

{% hint style="warning" %}
As the inference query depends on a fully processed function node, type information is not available at this stage of processing a function.
{% endhint %}

### Shadow

Variables are implicitly shadowed when a new binding is made of an already bound variable name. The shadow module assigns generations to variables within the node to distinguish between shadowed variables with the same identifier.

Parameter variables always have a generation of zero as there can never be duplicate parameter identifiers in a function signature.

### Resolution

When ascriptions and function calls are parsed, the actual path to the types and functions are unknown. The resolution module uses the context of a module and its inclusions to resolve the full path of a structure or function.
