simc-ast-builder
Version:
Parser and AST generator for SimulationCraft files
45 lines • 1.82 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleHyperthreadWristwraps = void 0;
const SimCVisitorError_1 = require("../../errors/SimCVisitorError");
const fieldMaps_1 = require("../../utils/fieldMaps");
/**
* Handler for hyperthread_wristwraps access contexts
* This handles access to hyperthread_wristwraps-specific properties
*
* Special case for hyperthread_wristwraps which can be accessed as:
* - hyperthread_wristwraps.spellName (e.g., hyperthread_wristwraps.fire_blast)
* - hyperthread_wristwraps.spellName.charges
* - hyperthread_wristwraps.count
*/
const handleHyperthreadWristwraps = ({ ctx, parts }) => {
if (parts.length < 2) {
throw new SimCVisitorError_1.SimCVisitorError("Hyperthread wristwraps access requires a field", ctx);
}
// Determine field and actionName based on parts
let actionName = parts[1];
let fieldDef;
let expressionType;
if (parts.length === 3) {
fieldDef = (0, fieldMaps_1.getFieldDef)(parts[2]);
expressionType = fieldDef.type;
}
else if (parts.length === 2) {
const defaultField = (0, fieldMaps_1.getDefaultField)("hyperthread_wristwraps") || "";
fieldDef = (0, fieldMaps_1.getFieldDef)(defaultField);
expressionType = fieldDef.type;
}
else {
// This should never happen due to the earlier throw, but for type safety:
throw new SimCVisitorError_1.SimCVisitorError("Invalid number of parts for hyperthread_wristwraps access", ctx);
}
return {
actionName,
expressionType,
field: fieldDef,
kind: "expression",
nodeType: "hyperthread_wristwraps",
};
};
exports.handleHyperthreadWristwraps = handleHyperthreadWristwraps;
//# sourceMappingURL=HyperthreadWristwrapsHandler.js.map