MCPcopy Create free account
hub / github.com/devosoft/avida / VisitExpressionUnary

Method VisitExpressionUnary

avida-core/source/script/cDirectInterpretASTVisitor.cc:816–860  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

814
815
816void cDirectInterpretASTVisitor::VisitExpressionUnary(cASTExpressionUnary& node)
817{
818 node.GetExpression()->Accept(*this);
819
820 switch (node.GetOperator()) {
821 case TOKEN(OP_BIT_NOT):
822 switch (m_rtype.type) {
823 case TYPE(CHAR):
824 m_rvalue.as_char = ~m_rvalue.as_char;
825 break;
826 case TYPE(INT):
827 m_rvalue.as_int = ~m_rvalue.as_int;
828 break;
829
830 default:
831 INTERPRET_ERROR(UNDEFINED_TYPE_OP, mapToken(TOKEN(OP_BIT_NOT)), mapType(m_rtype));
832 }
833 break;
834
835 case TOKEN(OP_LOGIC_NOT):
836 m_rvalue.as_bool = !asBool(m_rtype, m_rvalue, node);
837 m_rtype = TYPE(BOOL);
838 break;
839
840 case TOKEN(OP_SUB):
841 switch (m_rtype.type) {
842 case TYPE(CHAR):
843 m_rvalue.as_char = -m_rvalue.as_char;
844 break;
845 case TYPE(INT):
846 m_rvalue.as_int = -m_rvalue.as_int;
847 break;
848 case TYPE(FLOAT):
849 m_rvalue.as_float = -m_rvalue.as_float;
850 break;
851
852 default:
853 INTERPRET_ERROR(UNDEFINED_TYPE_OP, mapToken(TOKEN(OP_BIT_NOT)), mapType(m_rtype));
854 }
855 break;
856
857 default:
858 INTERPRET_ERROR(INTERNAL);
859 }
860}
861
862
863void cDirectInterpretASTVisitor::VisitBuiltInCall(cASTBuiltInCall& node)

Callers

nothing calls this directly

Calls 3

AcceptMethod · 0.80
GetExpressionMethod · 0.45
GetOperatorMethod · 0.45

Tested by

no test coverage detected