aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/ast/walk.go
Commit message (Collapse)AuthorAgeFilesLines
* pkg/ast: support expressions with ast.TypeAleksandr Nogikh2024-02-191-3/+12
| | | | | | | | | | | | | | | | | | | | | So far they have the following grammar: OP = "==", "!=", "&" value-expr = value-expr OP value-expr | factor factor = "(" and-expr ")" | integer | identifier | string Operators are left associative, e.g. A & B & C is the same as (A & B) & C. Further restrictions will be imposed in pkg/compiler. This will help implement conditionally included fields.
* pkg/ast, pkg/compiler: support per-file metadataDmitry Vyukov2022-04-291-0/+4
| | | | | | | | | | | | | | | | | | | | | We have a bunch of hacks in syz-extract, syz-sysgen and syz-check with respect to description files unsupported on some arches, or that must not be part of make extract. Add 2 meta attribtues to files: meta noextract Tells `make extract` to not extract constants for this file. Though, `syz-extract` can still be invoked manually on this file. meta arches["arch1", "arch2"] Restricts this file only to the given set of architectures. `make extract` and ``make generate` will not use it on other architectures. Later we can potentially use meta attributes to specify git tree/commit that must be used for extraction. Maybe something else. Fixes #2754
* pkg, prog: add per-field direction attributeNecip Fazil Yildiran2020-08-131-0/+3
|
* pkg/ast: add call attributesDmitry Vyukov2020-04-191-0/+3
|
* pkg/ast: unexport Node.Walk()Paul Chaignon2019-10-231-18/+18
| | | | | | | Other packages should use ast.Recursive and ast.PostRecursive to ensure the root node is visited as well. Signed-off-by: Paul Chaignon <paul.chaignon@orange.com>
* pkg/compiler: fix infinite recursion in template instantiationDmitry Vyukov2019-10-101-1/+10
| | | | | | | | | Currently we replace a template argument and then recurse into the new type AST to see if there is more to replace. If the description is buggy and the template argument contains itself, then we will recurse infintiely trying to replace it more and more. Use post-order traversal when replacing template argument to fix this.
* pkg/compiler: support type templatesDmitry Vyukov2018-01-131-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Netlink descriptions contain tons of code duplication, and need much more for proper descriptions. Introduce type templates to simplify writing such descriptions and remove code duplication. Note: type templates are experimental, have poor error handling and are subject to change. Type templates can be declared as follows: ``` type buffer[DIR] ptr[DIR, array[int8]] type fileoff[BASE] BASE type nlattr[TYPE, PAYLOAD] { nla_len len[parent, int16] nla_type const[TYPE, int16] payload PAYLOAD } [align_4] ``` and later used as follows: ``` syscall(a buffer[in], b fileoff[int64], c ptr[in, nlattr[FOO, int32]]) ```
* pkg/ast: refactor WalkDmitry Vyukov2018-01-111-72/+93
| | | | | Refactor Walk so that it's possible to abort or wrap walk of child nodes. Will be needed for future changes.
* sys: support type aliases (aka typedefs)Dmitry Vyukov2018-01-081-0/+3
| | | | | | | | | | | | | | | | | | | | | | Complex types that are often repeated can be given short type aliases using the following syntax: ``` type identifier underlying_type ``` For example: ``` type signalno int32[0:65] type net_port proc[20000, 4, int16be] ``` Then, type alias can be used instead of the underlying type in any contexts. Underlying type needs to be described as if it's a struct field, that is, with the base type if it's required. However, type alias can be used as syscall arguments as well. Underlying types are currently restricted to integer types, `ptr`, `ptr64`, `const`, `flags` and `proc` types.
* pkg/compiler: more static error checkingDmitry Vyukov2017-08-271-26/+26
| | | | Update #217
* pkg/compiler: move more const-processing code to compilerDmitry Vyukov2017-08-271-40/+26
|
* pkg/compiler, sys/syz-sysgen: move const handling to pkg/compilerDmitry Vyukov2017-08-271-26/+26
| | | | Now pkg/compiler deals with consts.
* sys/syz-extract: switch to the new parserDmitry Vyukov2017-08-181-0/+94