Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
"""Shared data structures for the WGSL template engine."""
 
from __future__ import annotations
 
from dataclasses import dataclass, field
 
 
@dataclass
class CodeReference:
    """Where a parsed line came from in the original source."""
 
    file_path: str
    line_number: int  # 1-based
 
 
@dataclass
class ParsedLine:
    """A line after parsing, plus its origin."""
 
    line: str
    code_reference: CodeReference
 
 
@dataclass
class TemplatePass0:
    """Result of PASS0 (load): raw lines straight from disk."""
 
    file_path: str  # absolute resolved path on disk
    raw: list[str]  # split on /\r?\n/
 
 
@dataclass
class TemplatePass1:
    """Result of PASS1 (parse): pre-processed but not yet code-generated."""
 
    file_path: str
    raw: list[str]
    pass1: list[ParsedLine]
 
 
@dataclass
class GenerateResult:
    """Result of running PASS2 over a single template."""
 
    code: str
    params: dict[str, str] = field(default_factory=dict)  # name -> param-type
    variables: dict[str, str] = field(default_factory=dict)  # name -> variable-type
    has_main_function: bool = False
 
 
@dataclass
class TemplatePass2:
    """Result of PASS2: code-generated string + metadata."""
 
    file_path: str
    generate_result: GenerateResult
 
 
@dataclass
class TemplateRepository:
    """A collection of templates loaded from disk.
 
    ``templates`` may hold ``TemplatePass0``, ``TemplatePass1``, or
    ``TemplatePass2`` depending on which pipeline stage produced it.
    """
 
    base_path: str
    templates: dict[str, object]
 
 
# ----------------------------------------------------------------------
# Source directory specification (loader input)
# ----------------------------------------------------------------------
 
 
@dataclass
class SourceDir:
    """A source directory with an optional alias prefix.
 
    The CLI doesn't expose aliases, but the loader API still supports
    them so directory-aliased test fixtures keep working.
    """
 
    path: str
    alias: str | None = None