simc-ast-builder
Version:
Parser and AST generator for SimulationCraft files
90 lines • 3.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleScorchExecute = exports.handleRemainingWintersChill = exports.handleMage = exports.handleImprovedScorch = exports.handleFirestarter = void 0;
const SimCVisitorError_1 = require("../../../errors/SimCVisitorError");
const fieldMaps_1 = require("../../../utils/fieldMaps");
/**
* Handler for mage access contexts
* This handles access to mage-specific properties
*/
const handleMage = ({ ctx, parts }) => {
if (parts.length < 2) {
throw new SimCVisitorError_1.SimCVisitorError("Mage access requires a field", ctx);
}
const field = parts[1] || "";
const fieldDef = (0, fieldMaps_1.getFieldDef)(field);
return {
expressionType: fieldDef.type,
field: fieldDef,
kind: "expression",
nodeType: "mage",
};
};
exports.handleMage = handleMage;
/**
* Handler for scorch_execute access contexts
* This handles access to scorch_execute-specific properties for Mage
*/
const handleScorchExecute = ({ ctx, parts, }) => {
if (parts.length < 2) {
throw new SimCVisitorError_1.SimCVisitorError("Scorch execute access requires a field", ctx);
}
const field = parts[1] || "";
const fieldDef = (0, fieldMaps_1.getFieldDef)(field);
return {
expressionType: fieldDef.type,
field: fieldDef,
kind: "expression",
nodeType: "scorch_execute",
};
};
exports.handleScorchExecute = handleScorchExecute;
/**
* Handler for improved_scorch access contexts
* This handles access to improved_scorch-specific properties for Mage
*/
const handleImprovedScorch = ({ ctx, parts, }) => {
if (parts.length < 2) {
throw new SimCVisitorError_1.SimCVisitorError("Improved scorch access requires a field", ctx);
}
const field = parts[1] || "";
const fieldDef = (0, fieldMaps_1.getFieldDef)(field);
return {
expressionType: fieldDef.type,
field: fieldDef,
kind: "expression",
nodeType: "improved_scorch",
};
};
exports.handleImprovedScorch = handleImprovedScorch;
/**
* Handler for firestarter access contexts
* This handles access to firestarter-specific properties for Mage
*/
const handleFirestarter = ({ ctx, parts, }) => {
if (parts.length < 2) {
throw new SimCVisitorError_1.SimCVisitorError("Firestarter access requires a field", ctx);
}
const field = parts[1] || "";
const fieldDef = (0, fieldMaps_1.getFieldDef)(field);
return {
expressionType: fieldDef.type,
field: fieldDef,
kind: "expression",
nodeType: "firestarter",
};
};
exports.handleFirestarter = handleFirestarter;
/**
* Handler for remaining_winters_chill access contexts
* This handles access to the remaining_winters_chill property for Mage
*/
const handleRemainingWintersChill = ({ parts }) => {
return {
expressionType: "numeric",
kind: "expression",
nodeType: "remaining_winters_chill",
};
};
exports.handleRemainingWintersChill = handleRemainingWintersChill;
//# sourceMappingURL=MageHandler.js.map