aboutsummaryrefslogblamecommitdiff
path: root/model.cpp
blob: d53a9bf29547857b0fea3ee6583a321b32ead3d6 (plain) (tree)
1
2
3
4
5
6
7
8
9
                 

                  
                                                       
 


                                            
 
                                                     
 




                                                      
                                

 
                                                                             
 
                                  
 
                               








                               
 

            



                                                           
      




                         
                                        

                                                              

                                                     
 

                                                 
 
                           
                                                           


                                     
                                     




                                                  
                                                                      
 


                                                                     

                                     
 
                                                                 
 



                                                      

                                                   
 
                                                              
 



                                                   
                                                        





                                                                
                                                        

                                                                 

                                                           
                                                                        
                                                            
                                                                               
                                                    
                                                                    

                                                                
                                                                      
                                                                    


                                                                      
                                                             
 







                                                    
                                                             

                                        
                                                              

                                                                             
                                                           
                                    

                                                                   
 


                                                

            
                                                           
      

                                                                            
 


                                                                             
                                     
                
 
 
                                             

                                                
 
                              
                                                            
     

                                                
     
                                                       



                                                          
                                                   
                                                     
                                
#include <cstdio>
#include "model.h"

FrameObj::FrameObj(ClassType _ftype) : ftype(_ftype) {}

EmptyList *empty_list = new EmptyList();

EmptyList::EmptyList() : Cons(NULL, NULL) {}

string EmptyList::ext_repr() { return string("()"); }

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

bool FrameObj::is_ret_addr() { 
    return ftype & CLS_RET_ADDR;
}

EvalObj::EvalObj(ClassType _otype) : FrameObj(CLS_EVAL_OBJ), otype(_otype) {}

void EvalObj::prepare(Cons *pc) {}

bool EvalObj::is_simple_obj() {
    return otype & CLS_SIM_OBJ;
}

bool EvalObj::is_sym_obj() {
    return otype & CLS_SYM_OBJ;
}

bool EvalObj::is_opt_obj() {
    return otype & CLS_OPT_OBJ;
}

#ifdef DEBUG
void EvalObj::_debug_print() {
    printf("mem: 0x%llX\n%s\n\n", (unsigned long long)this,
            _debug_repr().c_str());
}
#endif

bool EvalObj::is_true() {
    return true;
}

Cons::Cons(EvalObj *_car, Cons *_cdr) : 
    EvalObj(CLS_CONS_OBJ), car(_car), cdr(_cdr), skip(false), 
    next(cdr == empty_list ? NULL : cdr) {}

string Cons::ext_repr() { return string("#<Cons>"); }

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

void Cons::_debug_print() {
    printf("mem: 0x%llX (0x%llX . 0x%llX) | 0x%llX\n%s\n", 
            (unsigned long long)this,
            (unsigned long long)car,
            (unsigned long long)cdr,
            (unsigned long long)next,
    ("car: " + car -> ext_repr() + "\n" + \
     "cdr: " + cdr -> ext_repr() + "\n").c_str());
}
#endif

RetAddr::RetAddr(Cons *_addr) : FrameObj(CLS_RET_ADDR), addr(_addr) {}

#ifdef DEBUG
string RetAddr::_debug_repr() { return string("#<Return Address>"); }
#endif