%%%-------------------------------------------------------------------
%%% @author z.hua
%%% @copyright (C) 2021, <ShiYue>
%%% @doc
%%% 比较节点
%%% @end
%%%-------------------------------------------------------------------
-module(ebt_compare).
-author("z.hua").

-behavior(ebt_behavior).

-include("ebt.hrl").

%%-----------------------------------------------------------------------------
%% API Functions
%%-----------------------------------------------------------------------------
-export([on_enter/3, on_aback/3]).

on_enter(Tree, Rt, Node) ->
  Key = maps:get(key, Node#ebt_node.props),
  Op  = maps:get(op, Node#ebt_node.props),
  Val = maps:get(val, Node#ebt_node.props),
  Result = ?__if(ebt_runtime:test_variant(Rt, Key, Op, Val), ?SUCCESS, ?FAILURE),
  ebt_behavior:leave(Tree, Rt#ebt_rt{result = Result}).

on_aback(_Tree, _Rt, _Node) ->
  erlang:error(not_implemented).

%%-----------------------------------------------------------------------------
%% Internal Functions
%%-----------------------------------------------------------------------------
