GCC Code Coverage Report


src/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
14 / 21
66.7%
Branches:
3 / 8
37.5%
Functions:
5 / 5
100.0%

model/interface.spice
Line Branch Exec Source
1 // Copyright (c) 2021-2026 ChilliBits. All rights reserved.
2
3 // Std imports
4 import "std/data/vector";
5 import "std/text/stringstream";
6
7 // Own imports
8 import "@/ast/ast-nodes";
9 import "@/model/struct-base";
10 import "@/model/function";
11 import "@/model/generic-type";
12 import "@/symboltablebuilder/qual-type";
13 import "@/symboltablebuilder/symbol-table-entry";
14 import "@/symboltablebuilder/scope";
15 import "@/util/common-util";
16
17 // Constants
18 const string INTERFACE_SCOPE_PREFIX = "interface:";
19
20 4307 public type Interface struct {
21 public compose StructBase structBase
22 public Vector<Function*> methods
23 }
24
25 322 public p Interface.ctor(const String& name, SymbolTableEntry* entry, Scope* scope, const Vector<Function*>& methods, const Vector<GenericType>& templateTypes, ASTNode* declNode) {
26 322 this.structBase = StructBase(name, entry, scope, templateTypes, declNode);
27 322 this.methods = methods;
28 322 }
29
30 /**
31 * Retrieve the name of the scope, where signatures are placed. This is used to navigate to the scope of the interface
32 * from the parent scope.
33 *
34 * @return Name of the interface scope
35 */
36 1296 public f<String> Interface.getScopeName() {
37
2/2
✓ Branch 0 taken 648 times.
✓ Branch 1 taken 648 times.
1296 const String& appendix = this.structBase.isGenericSubstantiation() ? this.structBase.getSignature() : this.name;
38 2592 return String(INTERFACE_SCOPE_PREFIX) + appendix;
39 1296 }
40
41 /**
42 * Retrieve the name of the scope, where signatures are placed, from just a name and concrete template
43 * types — usable without a live Interface instance. See getStructScopeName (struct.spice) for the same
44 * pattern; mirrors StructBase.getSignature's 2-arg overload, which does not read 'this'.
45 *
46 * @param name Interface name
47 * @param concreteTemplateTypes Concrete template types
48 * @return Name of the interface scope
49 */
50 346 public f<String> getInterfaceScopeName(const String& name, const QualTypeList& concreteTemplateTypes) {
51 346 StringStream templateTyStr;
52
1/2
✓ Branch 0 taken 346 times.
✗ Branch 1 not taken.
346 if !concreteTemplateTypes.isEmpty() {
53 ✗ templateTyStr << "<";
54
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ foreach unsigned long i, const QualType& templateType : concreteTemplateTypes {
55
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ if i > 0ul { templateTyStr << ","; }
56 ✗ templateType.getName(templateTyStr, false, true);
57 ✗ }
58 ✗ templateTyStr << ">";
59 ✗ }
60 692 return String(INTERFACE_SCOPE_PREFIX) + getLastFragment(name, SCOPE_ACCESS_TOKEN) + templateTyStr.str();
61 346 }
62