Steps 272-277: Phase 10c — type system, concurrency & scope annotations (68/68 tests)
- Step 272: Type layout/constraints — BitWidth, Endian, Layout, Nullability, Variance (37 tests) - Step 273: Type identity/mutability — Identity, Mut, TypeState (25 tests) - Step 274: Concurrency primitives — Atomic, Sync, ThreadModel, MemoryBarrier (25 tests) - Step 275: Async/error handling — Exec, Blocking, Parallel, Trap, Exception, Panic (36 tests) - Step 276: Scope/namespace — Binding, Lookup, Capture, Visibility, Namespace, Scope (32 tests) - Step 277: Integration tests — cross-subject workflows, sidecar roundtrip, RPC (16 tests) - 24 new annotation classes with JSON roundtrip, compact AST, sidecar persistence - Generic fallback in getSemanticAnnotations RPC for extensible annotation queries Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -58,6 +58,115 @@ inline json extractSemanticSummary(const ASTNode* node) {
|
||||
auto* ta = static_cast<const SemanticTagAnnotation*>(a);
|
||||
if (!ta->tags.empty()) sem["tags"] = ta->tags;
|
||||
}
|
||||
// Type System — Layout & Constraints (Step 272)
|
||||
else if (a->conceptType == "BitWidthAnnotation") {
|
||||
auto* ba = static_cast<const BitWidthAnnotation*>(a);
|
||||
sem["bitWidth"] = ba->width;
|
||||
}
|
||||
else if (a->conceptType == "EndianAnnotation") {
|
||||
auto* ea = static_cast<const EndianAnnotation*>(a);
|
||||
if (!ea->order.empty()) sem["endian"] = ea->order;
|
||||
}
|
||||
else if (a->conceptType == "LayoutAnnotation") {
|
||||
auto* la = static_cast<const LayoutAnnotation*>(a);
|
||||
json obj;
|
||||
if (!la->mode.empty()) obj["mode"] = la->mode;
|
||||
if (la->alignment > 0) obj["alignment"] = la->alignment;
|
||||
if (!obj.empty()) sem["layout"] = obj;
|
||||
}
|
||||
else if (a->conceptType == "NullabilityAnnotation") {
|
||||
auto* na = static_cast<const NullabilityAnnotation*>(a);
|
||||
json obj;
|
||||
obj["nullable"] = na->nullable;
|
||||
if (!na->strategy.empty()) obj["strategy"] = na->strategy;
|
||||
sem["nullability"] = obj;
|
||||
}
|
||||
else if (a->conceptType == "VarianceAnnotation") {
|
||||
auto* va = static_cast<const VarianceAnnotation*>(a);
|
||||
if (!va->variance.empty()) sem["variance"] = va->variance;
|
||||
}
|
||||
// Type System — Identity & Mutability (Step 273)
|
||||
else if (a->conceptType == "IdentityAnnotation") {
|
||||
auto* ia = static_cast<const IdentityAnnotation*>(a);
|
||||
if (!ia->mode.empty()) sem["identity"] = ia->mode;
|
||||
}
|
||||
else if (a->conceptType == "MutAnnotation") {
|
||||
auto* ma = static_cast<const MutAnnotation*>(a);
|
||||
if (!ma->depth.empty()) sem["mutability"] = ma->depth;
|
||||
}
|
||||
else if (a->conceptType == "TypeStateAnnotation") {
|
||||
auto* ts = static_cast<const TypeStateAnnotation*>(a);
|
||||
if (!ts->state.empty()) sem["typeState"] = ts->state;
|
||||
}
|
||||
// Concurrency (Step 274)
|
||||
else if (a->conceptType == "AtomicAnnotation") {
|
||||
auto* aa = static_cast<const AtomicAnnotation*>(a);
|
||||
if (!aa->consistency.empty()) sem["atomic"] = aa->consistency;
|
||||
}
|
||||
else if (a->conceptType == "SyncAnnotation") {
|
||||
auto* sa = static_cast<const SyncAnnotation*>(a);
|
||||
if (!sa->primitive.empty()) sem["sync"] = sa->primitive;
|
||||
}
|
||||
else if (a->conceptType == "ThreadModelAnnotation") {
|
||||
auto* tm = static_cast<const ThreadModelAnnotation*>(a);
|
||||
if (!tm->model.empty()) sem["threadModel"] = tm->model;
|
||||
}
|
||||
else if (a->conceptType == "MemoryBarrierAnnotation") {
|
||||
sem["memoryBarrier"] = true;
|
||||
}
|
||||
// Async, Parallelism & Error Handling (Step 275)
|
||||
else if (a->conceptType == "ExecAnnotation") {
|
||||
auto* ea = static_cast<const ExecAnnotation*>(a);
|
||||
json obj;
|
||||
if (!ea->mode.empty()) obj["mode"] = ea->mode;
|
||||
if (!ea->runtimeHint.empty()) obj["runtime"] = ea->runtimeHint;
|
||||
if (!obj.empty()) sem["exec"] = obj;
|
||||
}
|
||||
else if (a->conceptType == "BlockingAnnotation") {
|
||||
auto* ba = static_cast<const BlockingAnnotation*>(a);
|
||||
if (!ba->kind.empty()) sem["blocking"] = ba->kind;
|
||||
}
|
||||
else if (a->conceptType == "ParallelAnnotation") {
|
||||
auto* pa = static_cast<const ParallelAnnotation*>(a);
|
||||
if (!pa->kind.empty()) sem["parallel"] = pa->kind;
|
||||
}
|
||||
else if (a->conceptType == "TrapAnnotation") {
|
||||
auto* ta = static_cast<const TrapAnnotation*>(a);
|
||||
if (!ta->signal.empty()) sem["trap"] = ta->signal;
|
||||
}
|
||||
else if (a->conceptType == "ExceptionAnnotation") {
|
||||
auto* ea = static_cast<const ExceptionAnnotation*>(a);
|
||||
if (!ea->style.empty()) sem["exception"] = ea->style;
|
||||
}
|
||||
else if (a->conceptType == "PanicAnnotation") {
|
||||
auto* pa = static_cast<const PanicAnnotation*>(a);
|
||||
if (!pa->behavior.empty()) sem["panic"] = pa->behavior;
|
||||
}
|
||||
// Scope & Namespace (Step 276)
|
||||
else if (a->conceptType == "BindingAnnotation") {
|
||||
auto* ba = static_cast<const BindingAnnotation*>(a);
|
||||
if (!ba->time.empty()) sem["binding"] = ba->time;
|
||||
}
|
||||
else if (a->conceptType == "LookupAnnotation") {
|
||||
auto* la = static_cast<const LookupAnnotation*>(a);
|
||||
if (!la->mode.empty()) sem["lookup"] = la->mode;
|
||||
}
|
||||
else if (a->conceptType == "CaptureAnnotation") {
|
||||
auto* ca = static_cast<const CaptureAnnotation*>(a);
|
||||
if (!ca->strategy.empty()) sem["capture"] = ca->strategy;
|
||||
}
|
||||
else if (a->conceptType == "VisibilityAnnotation") {
|
||||
auto* va = static_cast<const VisibilityAnnotation*>(a);
|
||||
if (!va->level.empty()) sem["visibility"] = va->level;
|
||||
}
|
||||
else if (a->conceptType == "NamespaceAnnotation") {
|
||||
auto* na = static_cast<const NamespaceAnnotation*>(a);
|
||||
if (!na->style.empty()) sem["namespace"] = na->style;
|
||||
}
|
||||
else if (a->conceptType == "ScopeAnnotation") {
|
||||
auto* sa = static_cast<const ScopeAnnotation*>(a);
|
||||
if (!sa->kind.empty()) sem["scope"] = sa->kind;
|
||||
}
|
||||
}
|
||||
return sem.empty() ? json() : sem;
|
||||
}
|
||||
|
||||
@@ -1654,6 +1654,34 @@ inline json handleHeadlessAgentRequest(HeadlessEditorState& state,
|
||||
else if (type == "risk") conceptType = "RiskAnnotation";
|
||||
else if (type == "contract") conceptType = "ContractAnnotation";
|
||||
else if (type == "tags") conceptType = "SemanticTagAnnotation";
|
||||
// Type System (Steps 272-273)
|
||||
else if (type == "bitWidth") conceptType = "BitWidthAnnotation";
|
||||
else if (type == "endian") conceptType = "EndianAnnotation";
|
||||
else if (type == "layout") conceptType = "LayoutAnnotation";
|
||||
else if (type == "nullability") conceptType = "NullabilityAnnotation";
|
||||
else if (type == "variance") conceptType = "VarianceAnnotation";
|
||||
else if (type == "identity") conceptType = "IdentityAnnotation";
|
||||
else if (type == "mut") conceptType = "MutAnnotation";
|
||||
else if (type == "typeState") conceptType = "TypeStateAnnotation";
|
||||
// Concurrency (Step 274)
|
||||
else if (type == "atomic") conceptType = "AtomicAnnotation";
|
||||
else if (type == "sync") conceptType = "SyncAnnotation";
|
||||
else if (type == "threadModel") conceptType = "ThreadModelAnnotation";
|
||||
else if (type == "memoryBarrier") conceptType = "MemoryBarrierAnnotation";
|
||||
// Async / Error Handling (Step 275)
|
||||
else if (type == "exec") conceptType = "ExecAnnotation";
|
||||
else if (type == "blocking") conceptType = "BlockingAnnotation";
|
||||
else if (type == "parallel") conceptType = "ParallelAnnotation";
|
||||
else if (type == "trap") conceptType = "TrapAnnotation";
|
||||
else if (type == "exception") conceptType = "ExceptionAnnotation";
|
||||
else if (type == "panic") conceptType = "PanicAnnotation";
|
||||
// Scope & Namespace (Step 276)
|
||||
else if (type == "binding") conceptType = "BindingAnnotation";
|
||||
else if (type == "lookup") conceptType = "LookupAnnotation";
|
||||
else if (type == "capture") conceptType = "CaptureAnnotation";
|
||||
else if (type == "visibility") conceptType = "VisibilityAnnotation";
|
||||
else if (type == "namespace") conceptType = "NamespaceAnnotation";
|
||||
else if (type == "scope") conceptType = "ScopeAnnotation";
|
||||
else return headlessRpcError(id, -32602, "Unknown annotation type: " + type);
|
||||
|
||||
// Remove existing annotation of same type (update semantics)
|
||||
@@ -1722,6 +1750,12 @@ inline json handleHeadlessAgentRequest(HeadlessEditorState& state,
|
||||
} else if (a->conceptType == "SemanticTagAnnotation") {
|
||||
auto* ta = static_cast<SemanticTagAnnotation*>(a);
|
||||
entry = {{"type", "tags"}, {"tags", ta->tags}};
|
||||
} else {
|
||||
// Generic fallback for all other semantic annotations
|
||||
entry = {{"type", a->conceptType}};
|
||||
json props = propertiesToJson(a);
|
||||
for (auto& [k, v] : props.items())
|
||||
entry[k] = v;
|
||||
}
|
||||
if (!entry.empty()) annos.push_back(entry);
|
||||
}
|
||||
@@ -1749,6 +1783,11 @@ inline json handleHeadlessAgentRequest(HeadlessEditorState& state,
|
||||
} else if (a->conceptType == "SemanticTagAnnotation") {
|
||||
auto* ta = static_cast<SemanticTagAnnotation*>(a);
|
||||
entry = {{"type", "tags"}, {"tags", ta->tags}};
|
||||
} else {
|
||||
entry = {{"type", a->conceptType}};
|
||||
json props = propertiesToJson(a);
|
||||
for (auto& [k, v] : props.items())
|
||||
entry[k] = v;
|
||||
}
|
||||
if (!entry.empty()) annoList.push_back(entry);
|
||||
}
|
||||
|
||||
@@ -23,17 +23,50 @@ inline std::string sidecarPath(const std::string& workspaceRoot,
|
||||
return (base / (filePath + ".ast.json")).string();
|
||||
}
|
||||
|
||||
// --- Check if a node type is a semantic annotation ---
|
||||
inline bool isSemanticAnnotation(const std::string& conceptType) {
|
||||
return conceptType == "IntentAnnotation" ||
|
||||
conceptType == "ComplexityAnnotation" ||
|
||||
conceptType == "RiskAnnotation" ||
|
||||
conceptType == "ContractAnnotation" ||
|
||||
conceptType == "SemanticTagAnnotation" ||
|
||||
// Type System (Steps 272-273)
|
||||
conceptType == "BitWidthAnnotation" ||
|
||||
conceptType == "EndianAnnotation" ||
|
||||
conceptType == "LayoutAnnotation" ||
|
||||
conceptType == "NullabilityAnnotation" ||
|
||||
conceptType == "VarianceAnnotation" ||
|
||||
conceptType == "IdentityAnnotation" ||
|
||||
conceptType == "MutAnnotation" ||
|
||||
conceptType == "TypeStateAnnotation" ||
|
||||
// Concurrency (Step 274)
|
||||
conceptType == "AtomicAnnotation" ||
|
||||
conceptType == "SyncAnnotation" ||
|
||||
conceptType == "ThreadModelAnnotation" ||
|
||||
conceptType == "MemoryBarrierAnnotation" ||
|
||||
// Async / Error Handling (Step 275)
|
||||
conceptType == "ExecAnnotation" ||
|
||||
conceptType == "BlockingAnnotation" ||
|
||||
conceptType == "ParallelAnnotation" ||
|
||||
conceptType == "TrapAnnotation" ||
|
||||
conceptType == "ExceptionAnnotation" ||
|
||||
conceptType == "PanicAnnotation" ||
|
||||
// Scope & Namespace (Step 276)
|
||||
conceptType == "BindingAnnotation" ||
|
||||
conceptType == "LookupAnnotation" ||
|
||||
conceptType == "CaptureAnnotation" ||
|
||||
conceptType == "VisibilityAnnotation" ||
|
||||
conceptType == "NamespaceAnnotation" ||
|
||||
conceptType == "ScopeAnnotation";
|
||||
}
|
||||
|
||||
// --- Count semantic annotations in an AST ---
|
||||
inline int countSemanticAnnotations(const ASTNode* node) {
|
||||
if (!node) return 0;
|
||||
int count = 0;
|
||||
auto annos = node->getChildren("annotations");
|
||||
for (const auto* a : annos) {
|
||||
if (a->conceptType == "IntentAnnotation" ||
|
||||
a->conceptType == "ComplexityAnnotation" ||
|
||||
a->conceptType == "RiskAnnotation" ||
|
||||
a->conceptType == "ContractAnnotation" ||
|
||||
a->conceptType == "SemanticTagAnnotation")
|
||||
if (isSemanticAnnotation(a->conceptType))
|
||||
++count;
|
||||
}
|
||||
for (const auto* child : node->allChildren()) {
|
||||
@@ -77,15 +110,6 @@ inline SidecarSaveResult saveSidecarAST(const std::string& workspaceRoot,
|
||||
return result;
|
||||
}
|
||||
|
||||
// --- Check if a node type is a semantic annotation ---
|
||||
inline bool isSemanticAnnotation(const std::string& conceptType) {
|
||||
return conceptType == "IntentAnnotation" ||
|
||||
conceptType == "ComplexityAnnotation" ||
|
||||
conceptType == "RiskAnnotation" ||
|
||||
conceptType == "ContractAnnotation" ||
|
||||
conceptType == "SemanticTagAnnotation";
|
||||
}
|
||||
|
||||
// --- Find a matching node in the live AST ---
|
||||
// Tries ID match first, then falls back to concept+name match
|
||||
// (node IDs are ephemeral and change across re-parses).
|
||||
|
||||
@@ -182,3 +182,159 @@ public:
|
||||
std::vector<std::string> tags; // e.g. ["@serialize", "@validation"]
|
||||
SemanticTagAnnotation() { conceptType = "SemanticTagAnnotation"; }
|
||||
};
|
||||
|
||||
// Type System Annotations — Layout & Constraints (Step 272, Subject 2)
|
||||
|
||||
class BitWidthAnnotation : public Annotation {
|
||||
public:
|
||||
int width = 0; // e.g. 32 for Java int
|
||||
BitWidthAnnotation() { conceptType = "BitWidthAnnotation"; }
|
||||
};
|
||||
|
||||
class EndianAnnotation : public Annotation {
|
||||
public:
|
||||
std::string order; // "big" | "little"
|
||||
EndianAnnotation() { conceptType = "EndianAnnotation"; }
|
||||
};
|
||||
|
||||
class LayoutAnnotation : public Annotation {
|
||||
public:
|
||||
std::string mode; // "packed" | "aligned"
|
||||
int alignment = 0;
|
||||
LayoutAnnotation() { conceptType = "LayoutAnnotation"; }
|
||||
};
|
||||
|
||||
class NullabilityAnnotation : public Annotation {
|
||||
public:
|
||||
bool nullable = false;
|
||||
std::string strategy; // "strict" | "nullable"
|
||||
NullabilityAnnotation() { conceptType = "NullabilityAnnotation"; }
|
||||
};
|
||||
|
||||
class VarianceAnnotation : public Annotation {
|
||||
public:
|
||||
std::string variance; // "covariant" | "contravariant" | "invariant"
|
||||
VarianceAnnotation() { conceptType = "VarianceAnnotation"; }
|
||||
};
|
||||
|
||||
// Type System Annotations — Identity & Mutability (Step 273, Subject 2)
|
||||
|
||||
class IdentityAnnotation : public Annotation {
|
||||
public:
|
||||
std::string mode; // "nominal" | "structural"
|
||||
IdentityAnnotation() { conceptType = "IdentityAnnotation"; }
|
||||
};
|
||||
|
||||
class MutAnnotation : public Annotation {
|
||||
public:
|
||||
std::string depth; // "shallow" | "deep" | "interior"
|
||||
MutAnnotation() { conceptType = "MutAnnotation"; }
|
||||
};
|
||||
|
||||
class TypeStateAnnotation : public Annotation {
|
||||
public:
|
||||
std::string state; // "erased" | "reified"
|
||||
TypeStateAnnotation() { conceptType = "TypeStateAnnotation"; }
|
||||
};
|
||||
|
||||
// Concurrency Annotations — Primitives & Memory Model (Step 274, Subject 3)
|
||||
|
||||
class AtomicAnnotation : public Annotation {
|
||||
public:
|
||||
std::string consistency; // "seq_cst" | "relaxed" | "acquire" | "release"
|
||||
AtomicAnnotation() { conceptType = "AtomicAnnotation"; }
|
||||
};
|
||||
|
||||
class SyncAnnotation : public Annotation {
|
||||
public:
|
||||
std::string primitive; // "monitor" | "spin" | "semaphore"
|
||||
SyncAnnotation() { conceptType = "SyncAnnotation"; }
|
||||
};
|
||||
|
||||
class ThreadModelAnnotation : public Annotation {
|
||||
public:
|
||||
std::string model; // "green" | "os" | "fiber"
|
||||
ThreadModelAnnotation() { conceptType = "ThreadModelAnnotation"; }
|
||||
};
|
||||
|
||||
class MemoryBarrierAnnotation : public Annotation {
|
||||
public:
|
||||
MemoryBarrierAnnotation() { conceptType = "MemoryBarrierAnnotation"; }
|
||||
};
|
||||
|
||||
// Async, Parallelism & Error Handling Annotations (Step 275, Subject 3)
|
||||
|
||||
class ExecAnnotation : public Annotation {
|
||||
public:
|
||||
std::string mode; // "async" | "event"
|
||||
std::string runtimeHint; // e.g. "tokio", "libuv"
|
||||
ExecAnnotation() { conceptType = "ExecAnnotation"; }
|
||||
};
|
||||
|
||||
class BlockingAnnotation : public Annotation {
|
||||
public:
|
||||
std::string kind; // "io" | "compute"
|
||||
BlockingAnnotation() { conceptType = "BlockingAnnotation"; }
|
||||
};
|
||||
|
||||
class ParallelAnnotation : public Annotation {
|
||||
public:
|
||||
std::string kind; // "data" | "task"
|
||||
ParallelAnnotation() { conceptType = "ParallelAnnotation"; }
|
||||
};
|
||||
|
||||
class TrapAnnotation : public Annotation {
|
||||
public:
|
||||
std::string signal; // e.g. "SIGSEGV", "SIGFPE"
|
||||
TrapAnnotation() { conceptType = "TrapAnnotation"; }
|
||||
};
|
||||
|
||||
class ExceptionAnnotation : public Annotation {
|
||||
public:
|
||||
std::string style; // "checked" | "unchecked"
|
||||
ExceptionAnnotation() { conceptType = "ExceptionAnnotation"; }
|
||||
};
|
||||
|
||||
class PanicAnnotation : public Annotation {
|
||||
public:
|
||||
std::string behavior; // "abort" | "unwind"
|
||||
PanicAnnotation() { conceptType = "PanicAnnotation"; }
|
||||
};
|
||||
|
||||
// Scope & Namespace Annotations (Step 276, Subject 4)
|
||||
|
||||
class BindingAnnotation : public Annotation {
|
||||
public:
|
||||
std::string time; // "static" | "dynamic"
|
||||
BindingAnnotation() { conceptType = "BindingAnnotation"; }
|
||||
};
|
||||
|
||||
class LookupAnnotation : public Annotation {
|
||||
public:
|
||||
std::string mode; // "lexical" | "hoisted"
|
||||
LookupAnnotation() { conceptType = "LookupAnnotation"; }
|
||||
};
|
||||
|
||||
class CaptureAnnotation : public Annotation {
|
||||
public:
|
||||
std::string strategy; // "value" | "ref" | "move"
|
||||
CaptureAnnotation() { conceptType = "CaptureAnnotation"; }
|
||||
};
|
||||
|
||||
class VisibilityAnnotation : public Annotation {
|
||||
public:
|
||||
std::string level; // "private" | "internal" | "friend" | "public"
|
||||
VisibilityAnnotation() { conceptType = "VisibilityAnnotation"; }
|
||||
};
|
||||
|
||||
class NamespaceAnnotation : public Annotation {
|
||||
public:
|
||||
std::string style; // "qualified" | "flat"
|
||||
NamespaceAnnotation() { conceptType = "NamespaceAnnotation"; }
|
||||
};
|
||||
|
||||
class ScopeAnnotation : public Annotation {
|
||||
public:
|
||||
std::string kind; // "local" | "global_leaked" | "singleton"
|
||||
ScopeAnnotation() { conceptType = "ScopeAnnotation"; }
|
||||
};
|
||||
|
||||
@@ -163,6 +163,107 @@ inline json propertiesToJson(const ASTNode* node) {
|
||||
auto* n = static_cast<const SemanticTagAnnotation*>(node);
|
||||
if (!n->tags.empty()) props["tags"] = n->tags;
|
||||
}
|
||||
// Type System — Layout & Constraints (Step 272)
|
||||
else if (ct == "BitWidthAnnotation") {
|
||||
auto* n = static_cast<const BitWidthAnnotation*>(node);
|
||||
props["width"] = n->width;
|
||||
}
|
||||
else if (ct == "EndianAnnotation") {
|
||||
auto* n = static_cast<const EndianAnnotation*>(node);
|
||||
if (!n->order.empty()) props["order"] = n->order;
|
||||
}
|
||||
else if (ct == "LayoutAnnotation") {
|
||||
auto* n = static_cast<const LayoutAnnotation*>(node);
|
||||
if (!n->mode.empty()) props["mode"] = n->mode;
|
||||
props["alignment"] = n->alignment;
|
||||
}
|
||||
else if (ct == "NullabilityAnnotation") {
|
||||
auto* n = static_cast<const NullabilityAnnotation*>(node);
|
||||
props["nullable"] = n->nullable;
|
||||
if (!n->strategy.empty()) props["strategy"] = n->strategy;
|
||||
}
|
||||
else if (ct == "VarianceAnnotation") {
|
||||
auto* n = static_cast<const VarianceAnnotation*>(node);
|
||||
if (!n->variance.empty()) props["variance"] = n->variance;
|
||||
}
|
||||
// Type System — Identity & Mutability (Step 273)
|
||||
else if (ct == "IdentityAnnotation") {
|
||||
auto* n = static_cast<const IdentityAnnotation*>(node);
|
||||
if (!n->mode.empty()) props["mode"] = n->mode;
|
||||
}
|
||||
else if (ct == "MutAnnotation") {
|
||||
auto* n = static_cast<const MutAnnotation*>(node);
|
||||
if (!n->depth.empty()) props["depth"] = n->depth;
|
||||
}
|
||||
else if (ct == "TypeStateAnnotation") {
|
||||
auto* n = static_cast<const TypeStateAnnotation*>(node);
|
||||
if (!n->state.empty()) props["state"] = n->state;
|
||||
}
|
||||
// Concurrency — Primitives & Memory Model (Step 274)
|
||||
else if (ct == "AtomicAnnotation") {
|
||||
auto* n = static_cast<const AtomicAnnotation*>(node);
|
||||
if (!n->consistency.empty()) props["consistency"] = n->consistency;
|
||||
}
|
||||
else if (ct == "SyncAnnotation") {
|
||||
auto* n = static_cast<const SyncAnnotation*>(node);
|
||||
if (!n->primitive.empty()) props["primitive"] = n->primitive;
|
||||
}
|
||||
else if (ct == "ThreadModelAnnotation") {
|
||||
auto* n = static_cast<const ThreadModelAnnotation*>(node);
|
||||
if (!n->model.empty()) props["model"] = n->model;
|
||||
}
|
||||
// MemoryBarrierAnnotation has no extra fields
|
||||
// Async, Parallelism & Error Handling (Step 275)
|
||||
else if (ct == "ExecAnnotation") {
|
||||
auto* n = static_cast<const ExecAnnotation*>(node);
|
||||
if (!n->mode.empty()) props["mode"] = n->mode;
|
||||
if (!n->runtimeHint.empty()) props["runtimeHint"] = n->runtimeHint;
|
||||
}
|
||||
else if (ct == "BlockingAnnotation") {
|
||||
auto* n = static_cast<const BlockingAnnotation*>(node);
|
||||
if (!n->kind.empty()) props["kind"] = n->kind;
|
||||
}
|
||||
else if (ct == "ParallelAnnotation") {
|
||||
auto* n = static_cast<const ParallelAnnotation*>(node);
|
||||
if (!n->kind.empty()) props["kind"] = n->kind;
|
||||
}
|
||||
else if (ct == "TrapAnnotation") {
|
||||
auto* n = static_cast<const TrapAnnotation*>(node);
|
||||
if (!n->signal.empty()) props["signal"] = n->signal;
|
||||
}
|
||||
else if (ct == "ExceptionAnnotation") {
|
||||
auto* n = static_cast<const ExceptionAnnotation*>(node);
|
||||
if (!n->style.empty()) props["style"] = n->style;
|
||||
}
|
||||
else if (ct == "PanicAnnotation") {
|
||||
auto* n = static_cast<const PanicAnnotation*>(node);
|
||||
if (!n->behavior.empty()) props["behavior"] = n->behavior;
|
||||
}
|
||||
// Scope & Namespace (Step 276)
|
||||
else if (ct == "BindingAnnotation") {
|
||||
auto* n = static_cast<const BindingAnnotation*>(node);
|
||||
if (!n->time.empty()) props["time"] = n->time;
|
||||
}
|
||||
else if (ct == "LookupAnnotation") {
|
||||
auto* n = static_cast<const LookupAnnotation*>(node);
|
||||
if (!n->mode.empty()) props["mode"] = n->mode;
|
||||
}
|
||||
else if (ct == "CaptureAnnotation") {
|
||||
auto* n = static_cast<const CaptureAnnotation*>(node);
|
||||
if (!n->strategy.empty()) props["strategy"] = n->strategy;
|
||||
}
|
||||
else if (ct == "VisibilityAnnotation") {
|
||||
auto* n = static_cast<const VisibilityAnnotation*>(node);
|
||||
if (!n->level.empty()) props["level"] = n->level;
|
||||
}
|
||||
else if (ct == "NamespaceAnnotation") {
|
||||
auto* n = static_cast<const NamespaceAnnotation*>(node);
|
||||
if (!n->style.empty()) props["style"] = n->style;
|
||||
}
|
||||
else if (ct == "ScopeAnnotation") {
|
||||
auto* n = static_cast<const ScopeAnnotation*>(node);
|
||||
if (!n->kind.empty()) props["kind"] = n->kind;
|
||||
}
|
||||
// NullLiteral, ListLiteral, IndexAccess, Block, Assignment, IfStatement,
|
||||
// WhileLoop, Return, ExpressionStatement, ListType, SetType, MapType,
|
||||
// TupleType, ArrayType, OptionalType — no extra properties
|
||||
@@ -240,6 +341,35 @@ inline ASTNode* createNode(const std::string& conceptName) {
|
||||
if (conceptName == "RiskAnnotation") return new RiskAnnotation();
|
||||
if (conceptName == "ContractAnnotation") return new ContractAnnotation();
|
||||
if (conceptName == "SemanticTagAnnotation") return new SemanticTagAnnotation();
|
||||
// Type System — Layout & Constraints (Step 272)
|
||||
if (conceptName == "BitWidthAnnotation") return new BitWidthAnnotation();
|
||||
if (conceptName == "EndianAnnotation") return new EndianAnnotation();
|
||||
if (conceptName == "LayoutAnnotation") return new LayoutAnnotation();
|
||||
if (conceptName == "NullabilityAnnotation") return new NullabilityAnnotation();
|
||||
if (conceptName == "VarianceAnnotation") return new VarianceAnnotation();
|
||||
// Type System — Identity & Mutability (Step 273)
|
||||
if (conceptName == "IdentityAnnotation") return new IdentityAnnotation();
|
||||
if (conceptName == "MutAnnotation") return new MutAnnotation();
|
||||
if (conceptName == "TypeStateAnnotation") return new TypeStateAnnotation();
|
||||
// Concurrency (Step 274)
|
||||
if (conceptName == "AtomicAnnotation") return new AtomicAnnotation();
|
||||
if (conceptName == "SyncAnnotation") return new SyncAnnotation();
|
||||
if (conceptName == "ThreadModelAnnotation") return new ThreadModelAnnotation();
|
||||
if (conceptName == "MemoryBarrierAnnotation") return new MemoryBarrierAnnotation();
|
||||
// Async, Parallelism & Error Handling (Step 275)
|
||||
if (conceptName == "ExecAnnotation") return new ExecAnnotation();
|
||||
if (conceptName == "BlockingAnnotation") return new BlockingAnnotation();
|
||||
if (conceptName == "ParallelAnnotation") return new ParallelAnnotation();
|
||||
if (conceptName == "TrapAnnotation") return new TrapAnnotation();
|
||||
if (conceptName == "ExceptionAnnotation") return new ExceptionAnnotation();
|
||||
if (conceptName == "PanicAnnotation") return new PanicAnnotation();
|
||||
// Scope & Namespace (Step 276)
|
||||
if (conceptName == "BindingAnnotation") return new BindingAnnotation();
|
||||
if (conceptName == "LookupAnnotation") return new LookupAnnotation();
|
||||
if (conceptName == "CaptureAnnotation") return new CaptureAnnotation();
|
||||
if (conceptName == "VisibilityAnnotation") return new VisibilityAnnotation();
|
||||
if (conceptName == "NamespaceAnnotation") return new NamespaceAnnotation();
|
||||
if (conceptName == "ScopeAnnotation") return new ScopeAnnotation();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -396,6 +526,107 @@ inline void setPropertiesFromJson(ASTNode* node, const json& props) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Type System — Layout & Constraints (Step 272)
|
||||
else if (ct == "BitWidthAnnotation") {
|
||||
auto* n = static_cast<BitWidthAnnotation*>(node);
|
||||
if (props.contains("width")) n->width = props["width"].get<int>();
|
||||
}
|
||||
else if (ct == "EndianAnnotation") {
|
||||
auto* n = static_cast<EndianAnnotation*>(node);
|
||||
if (props.contains("order")) n->order = props["order"].get<std::string>();
|
||||
}
|
||||
else if (ct == "LayoutAnnotation") {
|
||||
auto* n = static_cast<LayoutAnnotation*>(node);
|
||||
if (props.contains("mode")) n->mode = props["mode"].get<std::string>();
|
||||
if (props.contains("alignment")) n->alignment = props["alignment"].get<int>();
|
||||
}
|
||||
else if (ct == "NullabilityAnnotation") {
|
||||
auto* n = static_cast<NullabilityAnnotation*>(node);
|
||||
if (props.contains("nullable")) n->nullable = props["nullable"].get<bool>();
|
||||
if (props.contains("strategy")) n->strategy = props["strategy"].get<std::string>();
|
||||
}
|
||||
else if (ct == "VarianceAnnotation") {
|
||||
auto* n = static_cast<VarianceAnnotation*>(node);
|
||||
if (props.contains("variance")) n->variance = props["variance"].get<std::string>();
|
||||
}
|
||||
// Type System — Identity & Mutability (Step 273)
|
||||
else if (ct == "IdentityAnnotation") {
|
||||
auto* n = static_cast<IdentityAnnotation*>(node);
|
||||
if (props.contains("mode")) n->mode = props["mode"].get<std::string>();
|
||||
}
|
||||
else if (ct == "MutAnnotation") {
|
||||
auto* n = static_cast<MutAnnotation*>(node);
|
||||
if (props.contains("depth")) n->depth = props["depth"].get<std::string>();
|
||||
}
|
||||
else if (ct == "TypeStateAnnotation") {
|
||||
auto* n = static_cast<TypeStateAnnotation*>(node);
|
||||
if (props.contains("state")) n->state = props["state"].get<std::string>();
|
||||
}
|
||||
// Concurrency (Step 274)
|
||||
else if (ct == "AtomicAnnotation") {
|
||||
auto* n = static_cast<AtomicAnnotation*>(node);
|
||||
if (props.contains("consistency")) n->consistency = props["consistency"].get<std::string>();
|
||||
}
|
||||
else if (ct == "SyncAnnotation") {
|
||||
auto* n = static_cast<SyncAnnotation*>(node);
|
||||
if (props.contains("primitive")) n->primitive = props["primitive"].get<std::string>();
|
||||
}
|
||||
else if (ct == "ThreadModelAnnotation") {
|
||||
auto* n = static_cast<ThreadModelAnnotation*>(node);
|
||||
if (props.contains("model")) n->model = props["model"].get<std::string>();
|
||||
}
|
||||
// MemoryBarrierAnnotation has no extra fields
|
||||
// Async, Parallelism & Error Handling (Step 275)
|
||||
else if (ct == "ExecAnnotation") {
|
||||
auto* n = static_cast<ExecAnnotation*>(node);
|
||||
if (props.contains("mode")) n->mode = props["mode"].get<std::string>();
|
||||
if (props.contains("runtimeHint")) n->runtimeHint = props["runtimeHint"].get<std::string>();
|
||||
}
|
||||
else if (ct == "BlockingAnnotation") {
|
||||
auto* n = static_cast<BlockingAnnotation*>(node);
|
||||
if (props.contains("kind")) n->kind = props["kind"].get<std::string>();
|
||||
}
|
||||
else if (ct == "ParallelAnnotation") {
|
||||
auto* n = static_cast<ParallelAnnotation*>(node);
|
||||
if (props.contains("kind")) n->kind = props["kind"].get<std::string>();
|
||||
}
|
||||
else if (ct == "TrapAnnotation") {
|
||||
auto* n = static_cast<TrapAnnotation*>(node);
|
||||
if (props.contains("signal")) n->signal = props["signal"].get<std::string>();
|
||||
}
|
||||
else if (ct == "ExceptionAnnotation") {
|
||||
auto* n = static_cast<ExceptionAnnotation*>(node);
|
||||
if (props.contains("style")) n->style = props["style"].get<std::string>();
|
||||
}
|
||||
else if (ct == "PanicAnnotation") {
|
||||
auto* n = static_cast<PanicAnnotation*>(node);
|
||||
if (props.contains("behavior")) n->behavior = props["behavior"].get<std::string>();
|
||||
}
|
||||
// Scope & Namespace (Step 276)
|
||||
else if (ct == "BindingAnnotation") {
|
||||
auto* n = static_cast<BindingAnnotation*>(node);
|
||||
if (props.contains("time")) n->time = props["time"].get<std::string>();
|
||||
}
|
||||
else if (ct == "LookupAnnotation") {
|
||||
auto* n = static_cast<LookupAnnotation*>(node);
|
||||
if (props.contains("mode")) n->mode = props["mode"].get<std::string>();
|
||||
}
|
||||
else if (ct == "CaptureAnnotation") {
|
||||
auto* n = static_cast<CaptureAnnotation*>(node);
|
||||
if (props.contains("strategy")) n->strategy = props["strategy"].get<std::string>();
|
||||
}
|
||||
else if (ct == "VisibilityAnnotation") {
|
||||
auto* n = static_cast<VisibilityAnnotation*>(node);
|
||||
if (props.contains("level")) n->level = props["level"].get<std::string>();
|
||||
}
|
||||
else if (ct == "NamespaceAnnotation") {
|
||||
auto* n = static_cast<NamespaceAnnotation*>(node);
|
||||
if (props.contains("style")) n->style = props["style"].get<std::string>();
|
||||
}
|
||||
else if (ct == "ScopeAnnotation") {
|
||||
auto* n = static_cast<ScopeAnnotation*>(node);
|
||||
if (props.contains("kind")) n->kind = props["kind"].get<std::string>();
|
||||
}
|
||||
}
|
||||
|
||||
inline std::string generateNodeId() {
|
||||
|
||||
Reference in New Issue
Block a user