Allow the user to customize the evaluation/execution of expressions/
statements with something that implements functions that perform
those tasks. This additional functionality will make it possible for
the "classic" evaluator not to waste time checking for the presence
of interlopers and give implementers additional customization opportunities.
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
Centralize the execution of statements and evaluation of expressions
so that the user can specify a debugging "callback" after every
execution/evaluation.
The callback can be used for myriad things, but it seems likely that
it will be useful for implementing:
1. Testing
2. Debugger
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
When a function is called, if there is an (in)out parameter,
make sure that updated values are propogated to the calling
function.
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
The type system (and the value system) now include attributes
for each type (things like direction, const-ness).
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
Add support for directions on parameters and attributed types. The
latter is necessary to support the former, but is not limited to
the direction use case. An attributed type is a P4 type with attributes
(like its direction, whether it is read only, etc.) Other attributes
will be added in the future.
Changes necessary to support attributed types include:
1. Global instances tracked during compilation are not attributed
types and not simply types.
2. (future) Type checking will have to make sure that a types
attributes do not affect type compatibility.
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
Fields were not given default values when a struct was declared
without initializers.
Also, cleanup code in the helper function for binary operations
on struct instances.
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
1. Add support for field access
2. Add support for proper type checking of array access
3. Add tests for nested field and array access
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>
Refactor into four major components:
1. Common: Things shared among all other components.
2. Lang: P4-language-related components.
3. Runtime: Components required to run a P4 program.
4. Parser: Components for parsing a P4 program from source.
Other components:
1. Macros
2. Tests
3. TreeSitterExtensions: Extra tree sitter functionality
Signed-off-by: Will Hawkins <hawkinsw@obs.cr>