#!/usr/bin/env bash

@operation.condition.eq() {
    @symbol '=='
    @infix 3
    @in.string left
    @in.string right
    @out.bool result

    @do() {
        local left
        local right

        left=$(@in left)
        right=$(@in right)
        if [[ "$left" = "$right" ]]; then
            @out.bool result true
        else
            @out.bool result false
        fi
        @return.out
    }
}

@type.port() {
    @is() {
        local value="$1"
        @int.is "$value"
        if (( value < 1 || value > 65535 )); then
            @throw "port-out-of-range" "port must be between 1 and 65535"
        fi
        @return "$value"
    }
}
