Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members

numunif.cpp

Go to the documentation of this file.
00001 // +-------------------------------------------------------------------------+
00002 // |               I__n__t__e__L__i__b           0.6.10 development          |
00003 // | Copyright (c) Andrey Vikt. Stolyarov <crocodil_AT_croco.net> 2000-2007. |
00004 // |                                                                         |
00005 // | This is free software. The library part is available under              |
00006 // |                               GNU LESSER GENERAL PUBLIC LICENSE v.2.1.  |
00007 // | GNU LGPL v2.1 is found in docs/gnu_gpl2.txt,  or at  http://www.gnu.org |
00008 // |     Please see also docs/readme.txt and visit http://www.intelib.org    |
00009 // |                                                                         |
00010 // | !!! THERE IS NO WARRANTY OF ANY KIND, NEITHER EXPRESSED NOR IMPLIED !!! |
00011 // +-------------------------------------------------------------------------+
00012 
00013 
00014 
00015 
00016 #include "../sexpress/sexpress.hpp"
00017 
00018 const IntelibTypeId&
00019 LispUnifyNumbericTypes(SReference &l1, SReference &l2)
00020 {
00021     const IntelibTypeId *t1;
00022     const IntelibTypeId *t2;
00023     if((t1 = &(l1->TermType())) == (t2 = &(l2->TermType()))) return *t1;
00024     // We assume there are only SExpressionInt and SExpressionFloat around
00025     // This will likely change in a close future
00026     // For this time, however, this rule allows us to cast both args
00027     // to FLOAT and relax ;-) In fact, since the args have different
00028     // types, we only need to convert only the one which is integer
00029     if(*t1 == SExpressionInt::TypeId) {
00030         l1 = new SExpressionFloat(static_cast<intelib_float_t>(l1.GetInt()));
00031     } else
00032         if(*t2 == SExpressionInt::TypeId) {
00033             l2 = new SExpressionFloat(static_cast<intelib_float_t>(l2.GetInt()));
00034         }
00035     return SExpressionFloat::TypeId;
00036 }

Generated on Tue Dec 18 00:39:44 2007 for InteLib by  doxygen 1.4.1