00001 00002 // 00003 // "if less than or equal" 00004 // compares the first and the second subtree value 00005 // if first "lte" second, execute third, else fourth subtree 00006 // 00007 class IfLTE : public Tree::Primitives::Primitive 00008 { 00009 public: 00010 IfLTE() 00011 { 00012 nArguments_ = 4; 00013 name_ = "iflte"; 00014 } 00015 00016 void execute(void* result, Tree::Tree& tree) 00017 { 00018 double first, second; 00019 getNextArgument(&first, tree); 00020 getNextArgument(&second, tree); 00021 00022 if(first <= second) { 00023 // if yes, execute the third subtree 00024 getNextArgument(result, tree); 00025 // and skip the fourth one 00026 skipNextArgument(tree); 00027 } else { 00028 // otherwise... 00029 skipNextArgument(tree); 00030 getNextArgument(result, tree); 00031 } 00032 } 00033 00034 ~IfLTE() 00035 { } 00036 };