All files / transform/passes RegisterPrimitiveAnnotation.js

20% Statements 1/5
0% Branches 0/2
50% Functions 1/2
25% Lines 1/4
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22                    19x                      
import Transformation from '../transformation.js';
import TokenType from '../../parser/vsltokentype';
import t from '../../parser/nodes';
 
/**
 * This resolves and mangles a function declaration. This applies to functions
 * and does not support lambdas or such.
 */
export default class RegisterPrimitiveAnnotation extends Transformation {
    constructor() {
        super(t.Annotation, "Register::PrimitiveAnnotation");
    }
    
    modify(node: Node, tool: ASTTool) {
        // Check that it's the correct type
        if (node.name !== "primitive") return;
        let type = node.args[0];
 
        tool.context.addPrimitive(type, tool.nthParent(2));
    }
}