aboutsummaryrefslogblamecommitdiff
path: root/builtin.cpp
blob: 806d91112b6afa4c96b6e564a5d00819f4f3fd68 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11

                   
                    
                 






                                                     
 
                                       
 
                                                                
 




                                                    
 




                           
 




                                                           
 




                              
 




                                                     
 








                                      
                                                    
                            

                                                 

                                                   
                                  
















                                                         
                                                         

                                                    
                          
 
 
                                                             
                                                                     
                                                           

               
                                                     



                                                                       

                                       
                                    

                                                       



                                                                          
 
            
                                                         



                                                         

                                                                  






                                          
                                                                 
                                                                         

                                                           
                                                                    





                                                                       
                                                              
 
                                                    



                                                                                  
 




                                                             
 







                                                                  
 
                                                                 
                                                     

                                                           


                             

                                  
     



                                                                   
                             


        

                                                          





                                                                   









                                                                        
                                 

                          
 
                                                                                  
 


                                                             






                                                      
                                                              
                                                                         

                                                           






                                                               
                                                             
                                                                     
                                 

                          
 
                                 
 
                                                                             
 


                                                          



















































                                                                  
#include "exc.h"
#include "consts.h"
#include "builtin.h"
#include <cstdio>
#include <sstream>

using std::stringstream;

extern EmptyList *empty_list;

BoolObj::BoolObj(bool _val) : EvalObj(), val(_val) {}

bool BoolObj::is_true() { return val; }

string BoolObj::ext_repr() { return string(val ? "#t" : "#f"); }

#ifdef DEBUG
string BoolObj::_debug_repr() { return ext_repr(); }
#endif

IntObj::IntObj(int _val) : NumberObj(), val(_val) {}

string IntObj::ext_repr() {
    stringstream ss;
    ss << val;
    return ss.str();
}

#ifdef DEBUG
string IntObj::_debug_repr() { return ext_repr(); }
#endif

FloatObj::FloatObj(double _val) : NumberObj(), val(_val) {}

string FloatObj::ext_repr() { 
    stringstream ss;
    ss << val;
    return ss.str();
}

#ifdef DEBUG
string FloatObj::_debug_repr() { return ext_repr(); }
#endif

SpecialOptIf::SpecialOptIf() : SpecialOptObj() {}

void SpecialOptIf::prepare(Cons *pc) {
    state = 0;  // Prepared
    pc = pc->cdr;
    pc->skip = false;
    pc->cdr->skip = true;
    if (pc->cdr->