Intake Layer
The intake layer is LINC’s frontend-neutral source contract.
It defines what LINC needs from an upstream frontend without coupling to any specific parser AST or source extraction implementation.
SourcePackage
The primary intake type is SourcePackage.
An upstream frontend such as parc produces this after scanning and
extracting source-level information.
#![allow(unused)]
fn main() {
use linc::{
analyze_source_package,
SourceDeclaration,
SourceFunction,
SourcePackage,
SourceType,
};
let mut source = SourcePackage::default();
source.source_path = Some("mylib.h".into());
source.declarations.push(SourceDeclaration::Function(SourceFunction {
name: "init".into(),
parameters: vec![],
return_type: SourceType::Int,
variadic: false,
source_offset: None,
}));
let analysis = analyze_source_package(&source);
assert!(analysis.resolved_link_plan.is_some() || analysis.diagnostics.len() >= 0);
}
Declaration Types
The intake layer supports these declaration kinds:
SourceFunctionfor function declarationsSourceRecordfor struct/union declarationsSourceEnumfor enum declarations with variantsSourceTypeAliasfor typedef and alias declarationsSourceVariablefor external variable declarations
Records may be opaque when fields is None.
Type Model
SourceType is a simplified, language-neutral type representation. It is not
a full lossless C type system.
It covers:
- primitive types such as
Void,Bool,Char,Int,UInt, andLong - pointers and const pointers
- arrays
- function pointers
- references to typedefs, records, and enums
ConstandVolatilewrappers
Intake Contract
The intended intake path is:
- produce
SourcePackage - call
analyze_source_package - consume
LinkAnalysisPackage
Any adapter code that converts a serialized source artifact into SourcePackage
belongs in tests, examples, or an external harness.
Design Principles
- LINC core logic should say “analyze this normalized source surface”, not “parse this”
- adapter code is separate from core analysis logic
parcmay be used in tests, but not as a library-level dependency of LINC- another frontend should be able to replace
parcwithout rewriting LINC