All files / transpiler/logic/symbols/cnext/utils SymbolNameUtils.ts

100% Statements 5/5
100% Branches 2/2
100% Functions 1/1
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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                              2213x 2213x 1878x   335x       69x        
/**
 * Utility functions for symbol name manipulation.
 */
 
/**
 * Get the transpiled C name for a symbol (e.g., "Geometry_Point" for Point in Geometry scope).
 * Use only at the output layer for C code generation, not for input-side logic.
 *
 * @param symbol Object with name and scope.name properties
 * @returns The C output name (e.g., "Motor_init") or bare name if global scope
 */
function getTranspiledCName(symbol: {
  name: string;
  scope: { name: string };
}): string {
  const scopeName = symbol.scope.name;
  if (scopeName === "") {
    return symbol.name;
  }
  return `${scopeName}_${symbol.name}`;
}
 
class SymbolNameUtils {
  static readonly getTranspiledCName = getTranspiledCName;
}
 
export default SymbolNameUtils;