logo       
Google Custom Search
    AddThis Social Bookmark Button

rev 562 - in trunk: . include/prothon src: msg#00129

Subject: rev 562 - in trunk: . include/prothon src
Author: mark
Date: 2004-05-30 17:00:47 -0400 (Sun, 30 May 2004)
New Revision: 562

Modified:
   trunk/STATUS.txt
   trunk/include/prothon/prothon.h
   trunk/include/prothon/prothon_dll.h
   trunk/src/builtins-int.c
   trunk/src/object.c
Log:
long ints finished and untested, build probably broken badly, status update

Modified: trunk/STATUS.txt
===================================================================
--- trunk/STATUS.txt    2004-05-28 20:57:33 UTC (rev 561)
+++ trunk/STATUS.txt    2004-05-30 21:00:47 UTC (rev 562)
@@ -5,11 +5,15 @@
 --- check for OverflowError in math routines
 --- implement bigints
 
+--- put in skeleton code for + _"abc"
+
+--- add resolution order combining prototypes and scope chains
+
 --- Add properties methods: get_,  set_, delete_
 
 --- getAttr(name), setAttr(name, value), delAttr(name)
 
---- Auto-function capitalization scheme
+--- Auto-function scheme
 
 --- Strings -> 24-bit ords
 --- resolve binary vs. strings vs. unicode

Modified: trunk/include/prothon/prothon.h
===================================================================
--- trunk/include/prothon/prothon.h     2004-05-28 20:57:33 UTC (rev 561)
+++ trunk/include/prothon/prothon.h     2004-05-30 21:00:47 UTC (rev 562)
@@ -933,7 +933,8 @@
                                "expected a integer in parameter " #index);     
                                \
                return (index > 0 ? parms[((index)-1)*2+1] : list_item(ist, 
parms[1], -index));                                                             
                                            \
        }                                                                       
                                                                        \
-       (var) = int2i32t(index > 0 ? parms[((index)-1)*2+1] : list_item(ist, 
parms[1], -index)); }
+       (var) = int2i32t(ist, index > 0 ? parms[((index)-1)*2+1] : 
list_item(ist, parms[1], -index)); }
+i32_t int2i32t(isp ist, obj_p self);
 
 #define INT_64_PARAM(index, var)       /* i64_t var; */                        
                        \
 {      if (!has_proto(ist, (index > 0 ? parms[((index)-1)*2+1] : 
list_item(ist, parms[1], -index)), OBJ(INT_PROTO))) {                           
              \
@@ -941,7 +942,8 @@
                                "expected a integer in parameter " #index);     
                                \
                return (index > 0 ? parms[((index)-1)*2+1] : list_item(ist, 
parms[1], -index));                                                             
                                            \
        }                                                                       
                                                                        \
-       (var) = int2i64t(index > 0 ? parms[((index)-1)*2+1] : list_item(ist, 
parms[1], -index)); }
+       (var) = int2i64t(ist, index > 0 ? parms[((index)-1)*2+1] : 
list_item(ist, parms[1], -index)); }
+i64_t int2i64t(isp ist, obj_p self);
 
 #define STRING_PARAM(index, var)   \
 {      if (!has_proto(ist, (index > 0 ? parms[((index)-1)*2+1] : 
list_item(ist, parms[1], -index)), OBJ(STRING_PROTO))) {                        
              \

Modified: trunk/include/prothon/prothon_dll.h
===================================================================
--- trunk/include/prothon/prothon_dll.h 2004-05-28 20:57:33 UTC (rev 561)
+++ trunk/include/prothon/prothon_dll.h 2004-05-30 21:00:47 UTC (rev 562)
@@ -123,6 +123,8 @@
        int                     (*proto_len)(isp ist, obj_p obj);
        obj_p           (*proto_item)(isp ist, obj_p obj, int i);
        void            (*dump)(isp ist, char* dumpfilename, obj_p obj);
+       i32_t           (*int2i32t)(isp ist, obj_p self);
+       i64_t           (*int2i64t)(isp ist, obj_p self);
 
        void*           (*pr_malloc)(size_t nbytes);
        void*           (*pr_realloc)(void *p, size_t nbytes);
@@ -345,6 +347,8 @@
 #define clr_archived           (*services->clr_archived)
 #define is_archived                    (*services->is_archived)
 #define dump                           (*services->dump)
+#define int2i64t                       (*services->int2i64t)
+#define int2i32t                       (*services->int2i32t)
 
 #endif // OBJECT_H
 

Modified: trunk/src/builtins-int.c
===================================================================
--- trunk/src/builtins-int.c    2004-05-28 20:57:33 UTC (rev 561)
+++ trunk/src/builtins-int.c    2004-05-30 21:00:47 UTC (rev 562)
@@ -2047,7 +2047,36 @@
        return x;
 }
 
+i32_t int2i32t(isp ist, obj_p self) {
+       if (self->data_type == DATA_TYPE_NONE) {                                
        
+               raise_exception(ist, OBJ(INTERNAL_EXC),                         
        
+                       "object has no binary data, expected Integer"); 
+               return 0; }                                                     
                                
+       if (!proto_owns_binary(ist, OBJ(INT_PROTO), self)) {                    
        
+               raise_exception(ist, OBJ(INTERNAL_EXC),                         
        
+                       "object has wrong binary data, expected Integer");      
+               return 0; }                                                     
                                
+       if (self->data_type == DATA_TYPE_IMMDATA)
+               return (i32_t) self->data.i64;
+       else
+               return (i32_t) longp2int64(self->data.ptr);
+}
 
+i64_t int2i64t(isp ist, obj_p self) {
+       if (self->data_type == DATA_TYPE_NONE) {                                
        
+               raise_exception(ist, OBJ(INTERNAL_EXC),                         
        
+                       "object has no binary data, expected Integer"); 
+               return 0; }                                                     
                                
+       if (!proto_owns_binary(ist, OBJ(INT_PROTO), self)) {                    
        
+               raise_exception(ist, OBJ(INTERNAL_EXC),                         
        
+                       "object has wrong binary data, expected Integer");      
+               return 0; }                                                     
                                
+       if (self->data_type == DATA_TYPE_IMMDATA)
+               return (i32_t) self->data.i64;
+       else
+               return longp2int64(self->data.ptr);
+}
+
 // ***************************** INT MODULE ***********************************
 
 #define        INT_DATA_SIZE           8
@@ -2556,16 +2585,19 @@
 
 MODULE_START(IntGen)
 {
-       IntGen_OBJ = NEW_OBJ(NULL);
+       IntGen_OBJ = NEW_OBJ(OBJ(INT_PROTO));
        MODULE_SET_DOC(IntGen, "number generator object prototype");
        set_obj_id(IntGen_OBJ, *, IntGen);
 }
 
 DEF(IntGen, next, NULL) {
-       obj_p limit, res;
+       obj_p limit, tmp, res;
        BIN_CONTENT_CHK(IntGen);
        if ( !(limit=get_attr(ist, self, SYM_LIMIT)) ||
-                int_imm_value(self) == int_imm_value(limit) ) {
+                (  self->data_type == DATA_TYPE_IMMDATA && 
+                  limit->data_type == DATA_TYPE_IMMDATA ?
+                        (self->data.i64 == limit->data.i64) :
+                        !(call_func1(ist, self, SYM(CMP), limit)->data.i64) ) 
) {
                if (limit) {
                        read_unlock(ist, self);
                        del_attr(ist, self, SYM_LIMIT);
@@ -2574,14 +2606,21 @@
                raise_exception(ist, OBJ(STOP_ITERATION_EXC), NULL);
                return NULL;
        }
-       res = NEW_INT(int_imm_value(self));
-       def_write_lock(self);
-       int_imm_value(self)++;
-       def_write_unlock(self);
+       if (self->data_type == DATA_TYPE_IMMDATA)
+               res = NEW_INT(self->data.i64);
+       else
+               res = new_int_long_obj(ist, self->data.ptr);
+       if (self->data_type == DATA_TYPE_IMMDATA) {
+               def_write_lock(self);
+               int_imm_value(self)++;
+               def_write_unlock(self);
+       } else {
+               call_func1(ist, self, SYM(CMP), tmp = NEW_INT(1));
+               del_unlock(tmp);
+       }
        return res;
 }
 
-
 MAIN_MODULE_INIT(Int)
 {
        SYM_LIMIT = sym(ist, "limit");

Modified: trunk/src/object.c
===================================================================
--- trunk/src/object.c  2004-05-28 20:57:33 UTC (rev 561)
+++ trunk/src/object.c  2004-05-30 21:00:47 UTC (rev 562)
@@ -200,6 +200,8 @@
        dll_services.proto_len             = proto_len;   
        dll_services.proto_item            = proto_item;                 
        dll_services.dump                          = dump;               
+       dll_services.int2i32t              = int2i32t;           
+       dll_services.int2i64t              = int2i64t;           
        dll_services.proto_owns_binary = proto_owns_binary;              
        dll_services.obj_set_data_owner = obj_set_data_owner;            
 





Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>