solidity

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package solidity implements the CKG parser for .sol files (spec §4.6.3).

We use a vendored copy of github.com/JoranHonig/tree-sitter-solidity v1.2.11 (LANGUAGE_VERSION=14). Upstream github.com/tree-sitter/go-tree-sitter v0.25 supports the ABI window MIN_COMPATIBLE_LANGUAGE_VERSION..LANGUAGE_VERSION (13..15 at the time of writing), so the vendored grammar loads without regeneration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ABISig

type ABISig struct {
	ContractName string
	FunctionName string
	ParamTypes   []string
}

ABISig is a stripped-down function signature used by the cross-language linker (T20). We avoid pulling in solc; signatures are recovered from the AST per spec §4.6.3 ("ABI 추출 부산물"). ParamTypes is left nil in V0 since name-match is sufficient for the typechain-style binds_to heuristic.

type Parser

type Parser struct {
	// contains filtered or unexported fields
}

Parser implements parse.Parser for Solidity source.

abi accumulates per-contract function signatures across ParseFile calls so that the cross-language linker (T20) can match them to TypeScript classes by name. Mutated in place from declVisitor.collectABI under abiMu — buildpipe runs ParseFile concurrently across files.

func New

func New(srcRoot string) *Parser

New returns a Parser rooted at srcRoot (used for relative file paths).

func (*Parser) ABI

func (p *Parser) ABI() map[string][]ABISig

ABI returns the per-contract signatures collected during ParseFile. Used by the cross-language linker (T20). Caller is expected to invoke ABI only after all ParseFile calls have completed (buildpipe enforces this by collecting all results before reading ABI). The mutex guard is defensive — under the documented call sequence there is no contention.

func (*Parser) Extensions

func (p *Parser) Extensions() []string

Extensions reports the file extensions this parser handles.

func (*Parser) ParseFile

func (p *Parser) ParseFile(path string, src []byte) (*parse.ParseResult, error)

ParseFile runs Pass 1 over a single .sol file.

func (*Parser) Resolve

func (p *Parser) Resolve(results []*parse.ParseResult) (*parse.ResolvedGraph, error)

Resolve unions per-file results. V0 cross-file resolution is name-based: pending edges (emits_event, has_modifier, writes_mapping) are matched against any node whose Name (or QualifiedName for mappings) equals the pending TargetQName. Cross-file matches are tagged INFERRED; same-file matches stay EXTRACTED. Mirrors the TypeScript resolver.

W1 (Sol inheritance, 2026-05-11): adds resolution for `is`-clause PendingRefs (DispatchKind="inherit"). The detector (inheritance.go) emits these with a provisional EdgeType=EdgeExtends; this resolver reclassifies to EdgeImplements when the resolved parent is an Interface node. Contract / Interface lookups share the byName index keyed by NodeType.

W2 (Sol virtual/override, 2026-05-11): adds resolution for override-specifier PendingRefs (DispatchKind="override" / "override_explicit"). Bare overrides walk the inheritance graph emitted in W1 to find every parent that declares a same-name function; explicit `override(A, B)` looks up "Parent.method" directly. Both paths emit EdgeOverrides (child → parent) at ConfExtracted (same-file) or ConfInferred (cross-file).

W3 (Sol interface dispatch, 2026-05-11): adds resolution for `IFoo(addr).bar()` PendingRefs (DispatchKind="interface_dispatch"). Two-step lookup: (1) TypeName must resolve to a NodeInterface; (2) `TypeName.MethodName` must resolve to a Function declared on that interface. Both hits → emit EdgeInvokes at ConfAmbiguous (§5.0 Q5 — confidence is constant regardless of file boundary; runtime dispatch makes the resolved target an over-approximation). Any miss → drop (V0 strict-purge — keeps the AMBIGUOUS bucket scoped to real interface dispatch only).

Directories

Path Synopsis
Package binding wraps the tree-sitter-solidity grammar (vendored from github.com/JoranHonig/tree-sitter-solidity v1.2.11, MIT-licensed) into a *sitter.Language usable by github.com/tree-sitter/go-tree-sitter.
Package binding wraps the tree-sitter-solidity grammar (vendored from github.com/JoranHonig/tree-sitter-solidity v1.2.11, MIT-licensed) into a *sitter.Language usable by github.com/tree-sitter/go-tree-sitter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL