[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[sc-dev] SF.net SVN: supercollider:[9600] trunk
Revision: 9600
http://supercollider.svn.sourceforge.net/supercollider/?rev=9600&view=rev
Author: timblech
Date: 2009-12-15 15:17:13 +0000 (Tue, 15 Dec 2009)
Log Message:
-----------
sclang access function type checks
Modified Paths:
--------------
trunk/Headers/lang/PyrSlot.h
trunk/Source/lang/LangPrimSource/OSCData.cpp
trunk/Source/lang/LangPrimSource/PyrArrayPrimitives.cpp
trunk/Source/lang/LangPrimSource/PyrFilePrim.cpp
trunk/Source/lang/LangPrimSource/PyrListPrim.cpp
trunk/Source/lang/LangPrimSource/PyrMathPrim.cpp
trunk/Source/lang/LangPrimSource/PyrPrimitive.cpp
trunk/Source/lang/LangPrimSource/PyrSched.cpp
trunk/Source/lang/LangSource/DumpParseNode.cpp
trunk/Source/lang/LangSource/PyrInterpreter3.cpp
trunk/Source/lang/LangSource/PyrMathOps.cpp
trunk/Source/lang/LangSource/PyrMessage.cpp
trunk/Source/lang/LangSource/PyrObject.cpp
trunk/Source/lang/LangSource/PyrParseNode.cpp
Modified: trunk/Headers/lang/PyrSlot.h
===================================================================
--- trunk/Headers/lang/PyrSlot.h 2009-12-15 15:16:35 UTC (rev 9599)
+++ trunk/Headers/lang/PyrSlot.h 2009-12-15 15:17:13 UTC (rev 9600)
@@ -201,6 +201,7 @@
inline void SetRaw(PyrSlot* slot, int val) { assert(IsInt(slot)); slot->ui = val; }
inline void SetRaw(PyrSlot* slot, PyrObject * val) { assert(IsObj(slot)); slot->uo = val; }
inline void SetRaw(PyrSlot* slot, PyrSymbol * val) { assert(IsSym(slot)); slot->us = val; }
+inline void SetRaw(PyrSlot* slot, void * val) { assert(IsPtr(slot)); slot->uptr = val; }
inline void SetRaw(PyrSlot* slot, double val) { assert(IsFloat(slot)); SetFloat(slot, val); }
void dumpPyrSlot(PyrSlot* slot);
@@ -352,7 +353,7 @@
inline double slotRawFloat(PyrSlot *slot)
{
assert(IsFloat(slot));
- return slot->s.u.f;
+ return slot->uf;
}
inline PyrObject* slotRawObject(PyrSlot *slot)
@@ -392,7 +393,7 @@
#undef uo
#undef uoi
#undef ui
-#undef uf
+//#undef uf
#undef uop
Modified: trunk/Source/lang/LangPrimSource/OSCData.cpp
===================================================================
--- trunk/Source/lang/LangPrimSource/OSCData.cpp 2009-12-15 15:16:35 UTC (rev 9599)
+++ trunk/Source/lang/LangPrimSource/OSCData.cpp 2009-12-15 15:17:13 UTC (rev 9600)
@@ -299,9 +299,9 @@
{
int err, port, addr;
- SC_TcpClientPort* comPort = (SC_TcpClientPort*)slotRawPtr(netAddrObj->slots + ivxNetAddr_Socket);
+ if (IsObj(netAddrObj->slots + ivxNetAddr_Socket)) {
+ SC_TcpClientPort* comPort = (SC_TcpClientPort*)slotRawObject(netAddrObj->slots + ivxNetAddr_Socket);
- if (comPort) {
// send TCP
int tcpSocket = comPort->Socket();
Modified: trunk/Source/lang/LangPrimSource/PyrArrayPrimitives.cpp
===================================================================
--- trunk/Source/lang/LangPrimSource/PyrArrayPrimitives.cpp 2009-12-15 15:16:35 UTC (rev 9599)
+++ trunk/Source/lang/LangPrimSource/PyrArrayPrimitives.cpp 2009-12-15 15:17:13 UTC (rev 9600)
@@ -855,7 +855,7 @@
break;
case obj_char :
if (NotChar(b)) return errWrongType;
- ((char*)slots)[array->size++] = slotRawInt(b);
+ ((char*)slots)[array->size++] = slotRawChar(b);
break;
case obj_symbol :
if (NotSym(b)) return errWrongType;
Modified: trunk/Source/lang/LangPrimSource/PyrFilePrim.cpp
===================================================================
--- trunk/Source/lang/LangPrimSource/PyrFilePrim.cpp 2009-12-15 15:16:35 UTC (rev 9599)
+++ trunk/Source/lang/LangPrimSource/PyrFilePrim.cpp 2009-12-15 15:17:13 UTC (rev 9600)
@@ -144,7 +144,7 @@
a = g->sp;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) return errNone;
SetPtr(&pfile->fileptr, NULL);
if (fclose(file)) return errFailed;
@@ -159,7 +159,7 @@
a = g->sp;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file != NULL) fflush(file);
return errNone;
}
@@ -174,7 +174,7 @@
a = g->sp;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) return errFailed;
if (fgetpos(file, &pos)) return errFailed;
@@ -199,7 +199,7 @@
a = g->sp;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) return errFailed;
// preserve file position
if (fgetpos(file, &pos)) return errFailed;
@@ -225,7 +225,7 @@
if (NotInt(b)) return errWrongType;
if (NotInt(c)) return errWrongType;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) return errFailed;
offset = slotRawInt(b);
origin = slotRawInt(c);
@@ -247,7 +247,7 @@
a = g->sp - 1;
b = g->sp;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) return errFailed;
switch (GetTag(b)) {
case tagInt :
@@ -260,7 +260,7 @@
fwrite(slotRawSymbol(b)->name, sizeof(char), slotRawSymbol(b)->length, file);
break;
case tagChar :
- chr = slotRawInt(b);
+ chr = slotRawChar(b);
fwrite(&chr, sizeof(char), 1, file);
break;
case tagNil :
@@ -350,7 +350,7 @@
a = g->sp - 1;
b = g->sp;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) return errFailed;
switch (GetTag(b)) {
case tagInt :
@@ -451,7 +451,7 @@
b = g->sp;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) return errFailed;
char* result = fgets(slotRawString(b)->s, MAXINDEXSIZE(slotRawObject(b)) - 1, file);
@@ -475,7 +475,7 @@
b = g->sp;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) return errFailed;
int val;
@@ -498,7 +498,7 @@
b = g->sp;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) return errFailed;
int val;
@@ -523,7 +523,7 @@
b = g->sp;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) return errFailed;
int val;
@@ -546,7 +546,7 @@
b = g->sp;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) return errFailed;
int val;
@@ -570,7 +570,7 @@
b = g->sp;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) return errFailed;
int val;
@@ -595,7 +595,7 @@
b = g->sp;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) return errFailed;
if (NotChar(b)) return errWrongType;
@@ -617,7 +617,7 @@
b = g->sp;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) {
dumpObjectSlot(a);
return errFailed;
@@ -643,7 +643,7 @@
b = g->sp;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) return errFailed;
@@ -668,7 +668,7 @@
b = g->sp;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) {
dumpObjectSlot(a);
return errFailed;
@@ -694,7 +694,7 @@
b = g->sp;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) return errFailed;
@@ -718,7 +718,7 @@
a = g->sp - 1;
b = g->sp;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) return errFailed;
if (NotObj(b) || slotRawObject(b)->classptr != class_string) return errWrongType;
string = slotRawString(b);
@@ -738,7 +738,7 @@
a = g->sp;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) return errFailed;
if (feof(file)) SetNil(a);
@@ -758,7 +758,7 @@
a = g->sp;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) return errFailed;
if (feof(file)) SetNil(a);
@@ -779,7 +779,7 @@
a = g->sp;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) return errFailed;
if (feof(file)) SetNil(a);
@@ -799,7 +799,7 @@
a = g->sp;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) return errFailed;
if (feof(file)) SetNil(a);
@@ -820,7 +820,7 @@
a = g->sp;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) return errFailed;
int count = fread(&z, sizeof(char), 1, file);
@@ -839,7 +839,7 @@
a = g->sp;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) return errFailed;
int count = fread(&z, sizeof(char), 1, file);
@@ -857,7 +857,7 @@
a = g->sp;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) return errFailed;
if (feof(file)) SetNil(a);
@@ -877,7 +877,7 @@
a = g->sp;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL)
return errFailed;
@@ -899,7 +899,7 @@
a = g->sp;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) return errFailed;
if (feof(file)) SetNil(a);
@@ -919,7 +919,7 @@
a = g->sp;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) return errFailed;
if (feof(file)) SetNil(a);
@@ -942,7 +942,7 @@
|| isKindOfSlot(b, class_symbolarray)) return errWrongType;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) return errFailed;
int elemSize = gFormatElemSize[slotRawObject(b)->obj_format];
@@ -1023,7 +1023,7 @@
|| isKindOfSlot(b, class_symbolarray)) return errWrongType;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) return errFailed;
int elemSize = gFormatElemSize[slotRawObject(b)->obj_format];
@@ -1152,7 +1152,7 @@
a = g->sp;
pfile = (PyrFile*)slotRawObject(a);
- file = (FILE*)slotRawInt(&pfile->fileptr);
+ file = (FILE*)slotRawPtr(&pfile->fileptr);
if (file == NULL) return errNone;
SetPtr(&pfile->fileptr, NULL);
int perr = pclose(file);
@@ -1502,7 +1502,7 @@
a = g->sp;
- SNDFILE *file = (SNDFILE*)slotRawInt(&slotRawObject(a)->slots[0]);
+ SNDFILE *file = (SNDFILE*)slotRawPtr(&slotRawObject(a)->slots[0]);
if (file) {
sf_close(file);
SetNil(slotRawObject(a)->slots + 0);
@@ -1516,30 +1516,30 @@
{
PyrSlot *a, *b;
- a = g->sp - 1;
+ a = g->sp - 1;
b = g->sp;
- SNDFILE *file = (SNDFILE*)slotRawInt(&slotRawObject(a)->slots[0]);
+ SNDFILE *file = (SNDFILE*)slotRawPtr(&slotRawObject(a)->slots[0]);
- if (!isKindOfSlot(b, class_rawarray)) return errWrongType;
+ if (!isKindOfSlot(b, class_rawarray)) return errWrongType;
- switch (slotRawObject(b)->obj_format) {
- case obj_int16 :
- slotRawObject(b)->size = sf_read_short(file, (short*)slotRawInt8Array(b)->b, slotRawObject(b)->size);
- break;
- case obj_int32 :
- slotRawObject(b)->size = sf_read_int(file, (int*)slotRawInt8Array(b)->b, slotRawObject(b)->size);
- break;
- case obj_float :
- slotRawObject(b)->size = sf_read_float(file, (float*)slotRawInt8Array(b)->b, slotRawObject(b)->size);
- break;
- case obj_double :
- slotRawObject(b)->size = sf_read_double(file, (double*)slotRawInt8Array(b)->b, slotRawObject(b)->size);
- break;
- default:
- error("sample format not supported.\n");
- return errFailed;
- }
+ switch (slotRawObject(b)->obj_format) {
+ case obj_int16 :
+ slotRawObject(b)->size = sf_read_short(file, (short*)slotRawInt8Array(b)->b, slotRawObject(b)->size);
+ break;
+ case obj_int32 :
+ slotRawObject(b)->size = sf_read_int(file, (int*)slotRawInt8Array(b)->b, slotRawObject(b)->size);
+ break;
+ case obj_float :
+ slotRawObject(b)->size = sf_read_float(file, (float*)slotRawInt8Array(b)->b, slotRawObject(b)->size);
+ break;
+ case obj_double :
+ slotRawObject(b)->size = sf_read_double(file, (double*)slotRawInt8Array(b)->b, slotRawObject(b)->size);
+ break;
+ default:
+ error("sample format not supported.\n");
+ return errFailed;
+ }
return errNone;
}
@@ -1552,7 +1552,7 @@
a = g->sp - 1;
b = g->sp;
- SNDFILE *file = (SNDFILE*)slotRawInt(&slotRawObject(a)->slots[0]);
+ SNDFILE *file = (SNDFILE*)slotRawPtr(&slotRawObject(a)->slots[0]);
if (!isKindOfSlot(b, class_rawarray)) return errWrongType;
@@ -1586,7 +1586,7 @@
b = g->sp - 1;
c = g->sp;
- SNDFILE *file = (SNDFILE*)slotRawInt(&slotRawObject(a)->slots[0]);
+ SNDFILE *file = (SNDFILE*)slotRawPtr(&slotRawObject(a)->slots[0]);
int origin, offset;
int err = slotIntVal(b, &offset);
@@ -1606,14 +1606,14 @@
PyrSlot *a;
a = g->sp;
- SNDFILE *file = (SNDFILE*)slotRawInt(&slotRawObject(a)->slots[0]);
+ SNDFILE *file = (SNDFILE*)slotRawPtr(&slotRawObject(a)->slots[0]);
if(file){
- static char strbuffer [(1 << 16)] ;
- sf_command (file, SFC_GET_LOG_INFO, strbuffer, (1 << 16)) ;
- PyrString *pstring = newPyrString(g->gc, strbuffer, 0, true);
- // post(strbuffer);
- SetObject(a, pstring);
- return errNone;
+ static char strbuffer [(1 << 16)] ;
+ sf_command (file, SFC_GET_LOG_INFO, strbuffer, (1 << 16)) ;
+ PyrString *pstring = newPyrString(g->gc, strbuffer, 0, true);
+ // post(strbuffer);
+ SetObject(a, pstring);
+ return errNone;
}
return errFailed;
}
Modified: trunk/Source/lang/LangPrimSource/PyrListPrim.cpp
===================================================================
--- trunk/Source/lang/LangPrimSource/PyrListPrim.cpp 2009-12-15 15:16:35 UTC (rev 9599)
+++ trunk/Source/lang/LangPrimSource/PyrListPrim.cpp 2009-12-15 15:17:13 UTC (rev 9600)
@@ -116,16 +116,14 @@
slots = array->slots;
for (i=start; i<end; i++) {
test = slots + i;
- if (IsNil(test) || (GetTag(test) == GetTag(key) && slotRawInt(test) == slotRawInt(key))) {
+ if (IsNil(test) || SlotEq(test, key))
return i;
- }
}
end = start - 1;
for (i=0; i<=end; i++) {
test = slots + i;
- if (IsNil(test) || (GetTag(test) == GetTag(key) && slotRawInt(test) == slotRawInt(key))) {
+ if (IsNil(test) || SlotEq(test, key))
return i;
- }
}
return -1;
}
@@ -161,16 +159,14 @@
slots = array->slots;
for (i=start; i<end; i+=2) {
test = slots + i;
- if (IsNil(test) || (GetTag(test) == GetTag(key) && slotRawInt(test) == slotRawInt(key))) {
+ if (IsNil(test) || SlotEq(test, key))
return i;
- }
}
end = start - 2;
for (i=0; i<=end; i+=2) {
test = slots + i;
- if (IsNil(test) || (GetTag(test) == GetTag(key) && slotRawInt(test) == slotRawInt(key))) {
+ if (IsNil(test) || SlotEq(test, key))
return i;
- }
}
return -2;
}
@@ -187,16 +183,14 @@
slots = array->slots;
for (i=start; i<end; i+=2) {
test = slots + i;
- if (IsNil(test) || (GetTag(test) == GetTag(key) && slotRawInt(test) == slotRawInt(key))) {
+ if (IsNil(test) || SlotEq(test, key))
return i;
- }
}
end = start - 2;
for (i=0; i<=end; i+=2) {
test = slots + i;
- if (IsNil(test) || (GetTag(test) == GetTag(key) && slotRawInt(test) == slotRawInt(key))) {
+ if (IsNil(test) || SlotEq(test, key))
return i;
- }
}
return -2;
}
Modified: trunk/Source/lang/LangPrimSource/PyrMathPrim.cpp
===================================================================
--- trunk/Source/lang/LangPrimSource/PyrMathPrim.cpp 2009-12-15 15:16:35 UTC (rev 9599)
+++ trunk/Source/lang/LangPrimSource/PyrMathPrim.cpp 2009-12-15 15:17:13 UTC (rev 9600)
@@ -47,6 +47,10 @@
{
return lhs + rhs;
}
+ static inline int run(int lhs, int rhs)
+ {
+ return lhs + rhs;
+ }
static inline PyrObject* signal_xf(VMGlobals *g, PyrObject* ina, float inb)
{
return signal_add_xf(g, ina, inb);
@@ -67,6 +71,10 @@
{
return lhs * rhs;
}
+ static inline int run(int lhs, int rhs)
+ {
+ return lhs * rhs;
+ }
static inline PyrObject* signal_xf(VMGlobals *g, PyrObject* ina, float inb)
{
return signal_mul_xf(g, ina, inb);
@@ -87,6 +95,10 @@
{
return lhs - rhs;
}
+ static inline int run(int lhs, int rhs)
+ {
+ return lhs - rhs;
+ }
static inline PyrObject* signal_xf(VMGlobals *g, PyrObject* ina, float inb)
{
return signal_sub_xf(g, ina, inb);
@@ -176,7 +188,7 @@
default : // double
switch (GetTag(b)) {
case tagInt :
- SetRaw(a, Functor::run(slotRawFloat(a), slotRawInt(b)));
+ SetRaw(a, Functor::run(slotRawFloat(a), (double)slotRawInt(b)));
break;
case tagChar :
case tagPtr :
@@ -244,7 +256,7 @@
goto send_normal_2;
break;
default :
- SetRaw(a, Functor::run((double)slotRawInt(a), slotRawFloat(b)));
+ SetFloat(a, Functor::run((double)slotRawInt(a), slotRawFloat(b)));
break;
}
g->sp-- ; // drop
Modified: trunk/Source/lang/LangPrimSource/PyrPrimitive.cpp
===================================================================
--- trunk/Source/lang/LangPrimSource/PyrPrimitive.cpp 2009-12-15 15:16:35 UTC (rev 9599)
+++ trunk/Source/lang/LangPrimSource/PyrPrimitive.cpp 2009-12-15 15:17:13 UTC (rev 9600)
@@ -511,11 +511,10 @@
a = g->sp - 1;
b = g->sp;
- if (slotRawInt(a) == slotRawInt(b) && GetTag(a) == GetTag(b)) {
+ if (SlotEq(a, b))
SetTrue(a);
- } else {
+ else
SetFalse(a);
- }
return errNone;
}
@@ -526,11 +525,10 @@
a = g->sp - 1;
b = g->sp;
- if (slotRawInt(a) != slotRawInt(b) || GetTag(a) != GetTag(b)) {
+ if ( !SlotEq(a, b) )
SetTrue(a);
- } else {
+ else
SetFalse(a);
- }
return errNone;
}
@@ -853,7 +851,7 @@
block = slotRawBlock(&closure->block);
context = slotRawFrame(&closure->context);
- proto = slotRawObject(&block->prototypeFrame);
+ proto = IsObj(&block->prototypeFrame) ? slotRawObject(&block->prototypeFrame) : 0;
methraw = METHRAW(block);
numtemps = methraw->numtemps;
caller = g->frame;
@@ -2808,10 +2806,10 @@
SetNil(&oldthread->block);
SetNil(&oldthread->receiver);
SetNil(&oldthread->frame);
- SetPtr(&oldthread->ip, 0);
- SetInt(&oldthread->sp, 0);
- SetInt(&oldthread->numArgsPushed, 0);
- SetInt(&oldthread->numpop, 0);
+ SetRaw(&oldthread->ip, (void*)0);
+ SetRaw(&oldthread->sp, (void*)0);
+ SetRaw(&oldthread->numArgsPushed, 0);
+ SetRaw(&oldthread->numpop, 0);
SetNil(&oldthread->parent);
} else if (oldstate == tInit) {
SetObject(&oldthread->stack, gc->Stack());
@@ -2822,10 +2820,10 @@
SetNil(&oldthread->block);
SetNil(&oldthread->receiver);
SetNil(&oldthread->frame);
- SetPtr(&oldthread->ip, 0);
- SetInt(&oldthread->sp, 0);
- SetInt(&oldthread->numArgsPushed, 0);
- SetInt(&oldthread->numpop, 0);
+ SetRaw(&oldthread->ip, (void*)0);
+ SetRaw(&oldthread->sp, (void*)0);
+ SetRaw(&oldthread->numArgsPushed, 0);
+ SetRaw(&oldthread->numpop, 0);
SetNil(&oldthread->parent);
} else {
// save old thread's state
@@ -2868,8 +2866,8 @@
g->method = slotRawMethod(&newthread->method);
g->block = slotRawBlock(&newthread->block);
g->frame = slotRawFrame(&newthread->frame);
- g->ip = (unsigned char *)slotRawInt(&newthread->ip);
- g->sp = (PyrSlot*)slotRawInt(&newthread->sp);
+ g->ip = (unsigned char *)slotRawPtr(&newthread->ip);
+ g->sp = (PyrSlot*)slotRawPtr(&newthread->sp);
slotCopy(&g->receiver,&newthread->receiver);
g->rgen = (RGen*)(slotRawObject(&newthread->randData)->slots);
@@ -2890,8 +2888,8 @@
SetNil(&newthread->method);
SetNil(&newthread->block);
SetNil(&newthread->frame);
- SetPtr(&newthread->ip, 0);
- SetRaw(&newthread->sp, 0);
+ SetRaw(&newthread->ip, (void*)0);
+ SetRaw(&newthread->sp, (void*)0);
SetNil(&newthread->receiver);
SetRaw(&newthread->state, tRunning);
@@ -2921,19 +2919,24 @@
PyrObject *array;
PyrGC* gc = g->gc;
- slotCopy(&thread->func,func);
+ slotCopy(&thread->func, func);
gc->GCWrite(thread, func);
array = newPyrArray(gc, stacksize, 0, collect);
SetObject(&thread->stack, array);
gc->GCWrite(thread, array);
- SetRaw(&thread->state, tInit);
+ SetInt(&thread->state, tInit);
+ SetPtr(&thread->ip, 0);
+ SetPtr(&thread->sp, 0);
+
SetObject(&thread->randData, rgenArray);
gc->GCWrite(thread, rgenArray);
- SetFloat(&thread->beats, beats); /// would raw access be possible?
- SetFloat(&thread->seconds, seconds); /// would raw access be possible?
+ SetFloat(&thread->beats, beats);
+ SetFloat(&thread->seconds, seconds);
+ SetInt(&thread->numArgsPushed, 0);
+ SetInt(&thread->numpop, 0);
if (IsNil(clock)) {
SetObject(&thread->clock, s_systemclock->u.classobj);
@@ -3168,12 +3171,12 @@
slotCopy(&threadSlot,a);
slotCopy(&value,b);
- //post("g->thread %08X\n", g->thread);
- //post("thread %08X\n", thread);
+ //post("g->thread %08X\n", g->thread);
+ //post("thread %08X\n", thread);
SetObject(&thread->parent, g->thread);
g->gc->GCWrite(thread, g->thread);
- slotCopy(&thread->clock,&g->thread->clock);
+ slotCopy(&thread->clock, &g->thread->clock);
g->gc->GCWrite(thread, &g->thread->clock);
//postfl("start into thread %08X from parent %08X\n", thread, g->thread);
@@ -3236,10 +3239,10 @@
SetNil(&thread->block);
SetNil(&thread->receiver);
SetNil(&thread->frame);
- SetPtr(&thread->ip, 0);
- SetInt(&thread->sp, 0);
- SetInt(&thread->numArgsPushed, 0);
- SetInt(&thread->numpop, 0);
+ SetRaw(&thread->ip, (void*)0);
+ SetRaw(&thread->sp, (void*)0);
+ SetRaw(&thread->numArgsPushed, 0);
+ SetRaw(&thread->numpop, 0);
SetNil(&thread->parent);
} else if (state == tDone) {
SetRaw(&thread->state, tInit);
@@ -3248,10 +3251,10 @@
SetNil(&thread->block);
SetNil(&thread->receiver);
SetNil(&thread->frame);
- SetPtr(&thread->ip, 0);
- SetInt(&thread->sp, 0);
- SetInt(&thread->numArgsPushed, 0);
- SetInt(&thread->numpop, 0);
+ SetRaw(&thread->ip, (void*)0);
+ SetRaw(&thread->sp, (void*)0);
+ SetRaw(&thread->numArgsPushed, 0);
+ SetRaw(&thread->numpop, 0);
SetNil(&thread->parent);
} else if (state == tInit) {
// do nothing
@@ -3496,8 +3499,7 @@
g->gc->SanityCheck();
#endif
- //post("doPrimitive %s:%s\n", meth->ownerclass.uoc->name.us->name, slotRawSymbol(&meth->name)->name);
- //printf("doPrimitive %s:%s\n", meth->ownerclass.uoc->name.us->name, slotRawSymbol(&meth->name)->name);
+ //post("doPrimitive %s:%s\n", slotRawSymbol(&slotRawClass(&meth->ownerclass)->name)->name, slotRawSymbol(&meth->name)->name);
PyrMethodRaw *methraw = METHRAW(meth);
int primIndex = methraw->specialIndex;
Modified: trunk/Source/lang/LangPrimSource/PyrSched.cpp
===================================================================
--- trunk/Source/lang/LangPrimSource/PyrSched.cpp 2009-12-15 15:16:35 UTC (rev 9599)
+++ trunk/Source/lang/LangPrimSource/PyrSched.cpp 2009-12-15 15:17:13 UTC (rev 9600)
@@ -94,7 +94,7 @@
{
PyrSlot *pmom, *pme, *pend;
short mom,me,size; /* parent and sibling in the heap, not in the task hierarchy */
- double tasktemp;
+ PyrSlot tasktemp;
double timetemp;
PyrGC* gc = g->gc;
bool isPartialScanObj = gc->IsPartialScanObject(heap);
@@ -113,7 +113,7 @@
pme = heap->slots + me;
pend = heap->slots + size;
timetemp = slotRawFloat(&pmom[0]);
- tasktemp = slotRawFloat(&pmom[1]);
+ slotCopy(&tasktemp, &pmom[1]);
for (;pme < pend;) { /* demote heap */
if (pme+2 < pend && slotRawFloat(&pme[0]) > slotRawFloat(&pme[2])) {
me += 2; pme += 2;
@@ -130,10 +130,9 @@
} else break;
}
SetRaw(&pmom[0], timetemp);
- SetRaw(&pmom[1], tasktemp);
- if (isPartialScanObj) {
+ slotCopy(&pmom[1], &tasktemp);
+ if (isPartialScanObj)
gc->GCWriteBlack(pmom+1);
- }
//dumpheap(heap);
//dumpheap(heap);
Modified: trunk/Source/lang/LangSource/DumpParseNode.cpp
===================================================================
--- trunk/Source/lang/LangSource/DumpParseNode.cpp 2009-12-15 15:16:35 UTC (rev 9599)
+++ trunk/Source/lang/LangSource/DumpParseNode.cpp 2009-12-15 15:17:13 UTC (rev 9600)
@@ -461,7 +461,7 @@
sprintf(str, "%d", slotRawInt(slot));
break;
case tagChar :
- sprintf(str, "%c", slotRawInt(slot));
+ sprintf(str, "%c", slotRawChar(slot));
break;
case tagSym :
str[0] = 0;
Modified: trunk/Source/lang/LangSource/PyrInterpreter3.cpp
===================================================================
--- trunk/Source/lang/LangSource/PyrInterpreter3.cpp 2009-12-15 15:16:35 UTC (rev 9599)
+++ trunk/Source/lang/LangSource/PyrInterpreter3.cpp 2009-12-15 15:17:13 UTC (rev 9600)
@@ -178,7 +178,7 @@
// fill class vars from prototypes:
classobj = gClassList;
while (classobj) {
- if (slotRawObject(&classobj->cprototype)) {
+ if (IsObj(&classobj->cprototype)) {
numClassVars = slotRawObject(&classobj->cprototype)->size;
if (numClassVars > 0) {
memcpy(g->classvars->slots + slotRawInt(&classobj->classVarIndex), slotRawObject(&classobj->cprototype)->slots, numClassVars * sizeof(PyrSlot));
Modified: trunk/Source/lang/LangSource/PyrMathOps.cpp
===================================================================
--- trunk/Source/lang/LangSource/PyrMathOps.cpp 2009-12-15 15:16:35 UTC (rev 9599)
+++ trunk/Source/lang/LangSource/PyrMathOps.cpp 2009-12-15 15:17:13 UTC (rev 9600)
@@ -524,16 +524,16 @@
case tagChar : {
if (IsChar(b)) {
switch (opcode) {
- case opEQ : res = BOOL(slotRawInt(a) == slotRawInt(b)); break;
- case opNE : res = BOOL(slotRawInt(a) != slotRawInt(b)); break;
- case opLT : res = BOOL(slotRawInt(a) < slotRawInt(b)); break;
- case opGT : res = BOOL(slotRawInt(a) > slotRawInt(b)); break;
- case opLE : res = BOOL(slotRawInt(a) <= slotRawInt(b)); break;
- case opGE : res = BOOL(slotRawInt(a) >= slotRawInt(b)); break;
- //case opIdentical : res = BOOL(slotRawInt(a) == slotRawInt(b)); break;
- //case opNotIdentical : res = BOOL(slotRawInt(a) != slotRawInt(b)); break;
- case opMin : SetInt(&res, slotRawInt(a) < slotRawInt(b) ? slotRawInt(a) : slotRawInt(b)); break;
- case opMax : SetInt(&res, slotRawInt(a) > slotRawInt(b) ? slotRawInt(a) : slotRawInt(b)); break;
+ case opEQ : res = BOOL(slotRawChar(a) == slotRawChar(b)); break;
+ case opNE : res = BOOL(slotRawChar(a) != slotRawChar(b)); break;
+ case opLT : res = BOOL(slotRawChar(a) < slotRawChar(b)); break;
+ case opGT : res = BOOL(slotRawChar(a) > slotRawChar(b)); break;
+ case opLE : res = BOOL(slotRawChar(a) <= slotRawChar(b)); break;
+ case opGE : res = BOOL(slotRawChar(a) >= slotRawChar(b)); break;
+ //case opIdentical : res = BOOL(slotRawChar(a) == slotRawChar(b)); break;
+ //case opNotIdentical : res = BOOL(slotRawChar(a) != slotRawChar(b)); break;
+ case opMin : SetInt(&res, slotRawChar(a) < slotRawChar(b) ? slotRawChar(a) : slotRawChar(b)); break;
+ case opMax : SetInt(&res, slotRawChar(a) > slotRawChar(b) ? slotRawChar(a) : slotRawChar(b)); break;
default : goto send_normal_2;
}
} else {
Modified: trunk/Source/lang/LangSource/PyrMessage.cpp
===================================================================
--- trunk/Source/lang/LangSource/PyrMessage.cpp 2009-12-15 15:16:35 UTC (rev 9599)
+++ trunk/Source/lang/LangSource/PyrMessage.cpp 2009-12-15 15:17:13 UTC (rev 9600)
@@ -1159,7 +1159,7 @@
blockraw = METHRAW(block);
g->frame = returnFrame;
- g->ip = (unsigned char *)slotRawInt(&returnFrame->ip);
+ g->ip = (unsigned char *)slotRawPtr(&returnFrame->ip);
g->block = slotRawBlock(&returnFrame->method);
homeContext = slotRawFrame(&returnFrame->homeContext);
meth = slotRawMethod(&homeContext->method);
@@ -1294,7 +1294,7 @@
}
// return to it
- g->ip = (unsigned char *)slotRawInt(&returnFrame->ip);
+ g->ip = (unsigned char *)slotRawPtr(&returnFrame->ip);
g->frame = returnFrame;
g->block = slotRawBlock(&returnFrame->method);
Modified: trunk/Source/lang/LangSource/PyrObject.cpp
===================================================================
--- trunk/Source/lang/LangSource/PyrObject.cpp 2009-12-15 15:16:35 UTC (rev 9599)
+++ trunk/Source/lang/LangSource/PyrObject.cpp 2009-12-15 15:17:13 UTC (rev 9600)
@@ -822,22 +822,25 @@
void indexClassTree(PyrClass *classobj, int numSuperMethods)
{
- PyrObject *subclasses;
- PyrObject *methods;
int i, numMethods;
if (!classobj) return;
- subclasses = slotRawObject(&classobj->subclasses);
- SetInt(&classobj->classIndex, gNumClasses);
+ SetInt(&classobj->classIndex, gNumClasses);
gNumClasses ++;
- methods = slotRawObject(&classobj->methods);
- numMethods = methods ? methods->size : 0;
+
+ if (IsObj(&classobj->methods)) {
+ PyrObject * methods = slotRawObject(&classobj->methods);
+ numMethods = methods->size;
+ }
+ else
+ numMethods = 0;
+
numMethods = numSuperMethods + numMethods;
- if (subclasses) {
- for (i=0; i<subclasses->size; ++i) {
+ if (IsObj(&classobj->subclasses)) {
+ PyrObject * subclasses = slotRawObject(&classobj->subclasses);
+ for (i=0; i<subclasses->size; ++i)
indexClassTree(slotRawClass(&subclasses->slots[i]), numMethods);
- }
}
SetInt(&classobj->maxSubclassIndex, gNumClasses - 1);
}
@@ -913,17 +916,14 @@
void setSelectorFlags()
{
- PyrClass *classobj;
- PyrObject *methods;
- PyrMethod *method;
int i;
- classobj = gClassList;
+ PyrClass * classobj = gClassList;
while (classobj) {
- methods = slotRawObject(&classobj->methods);
- if (methods) {
+ if (IsObj(&classobj->methods)) {
+ PyrObject *methods = slotRawObject(&classobj->methods);
for (i=0; i<methods->size; ++i) {
- method = slotRawMethod(&methods->slots[i]);
+ PyrMethod * method = slotRawMethod(&methods->slots[i]);
slotRawSymbol(&method->name)->flags |= sym_Selector;
//if (method->methType == methRedirect) {
// post("rd: %3d %s:%s\n", k++, slotRawSymbol(&classobj->name)->name,
@@ -1172,7 +1172,6 @@
void fillClassRow(PyrClass *classobj, PyrMethod** bigTable)
{
- PyrObject *subclasses, *methods;
PyrClass* superclassobj;
PyrMethod **superrow, **myrow, *method;
int i, selectorIndex;
@@ -1189,8 +1188,8 @@
memset(myrow, 0, gNumSelectors * sizeof(PyrMethod*));
}
- methods = slotRawObject(&classobj->methods);
- if (methods) {
+ if (IsObj(&classobj->methods)) {
+ PyrObject * methods = slotRawObject(&classobj->methods);
//postfl(" %d\n", methods->size);
for (i=0; i<methods->size; ++i) {
method = slotRawMethod(&methods->slots[i]);
@@ -1199,8 +1198,8 @@
}
}
- subclasses = slotRawObject(&classobj->subclasses);
- if (subclasses) {
+ if (IsObj(&classobj->subclasses)) {
+ PyrObject * subclasses = slotRawObject(&classobj->subclasses);
for (i=0; i<subclasses->size; ++i) {
fillClassRow(slotRawClass(&subclasses->slots[i]), bigTable);
}
@@ -1324,7 +1323,7 @@
gNumClassVars = 0;
gClassList = NULL;
gNullMethod = newPyrMethod();
- SetRaw(&gNullMethod->name, (PyrSymbol*)NULL);
+ SetSymbol(&gNullMethod->name, (PyrSymbol*)NULL);
methraw = METHRAW(gNullMethod);
methraw->methType = methNormal;
@@ -2312,7 +2311,13 @@
{
if (NotNil(slot)) {
PyrObject *obj;
- obj = slotRawObject(slot);
+ if (IsSym(slot))
+ obj = (PyrObject*)slotRawSymbol(slot); // i don't want to know, what this means for the gc
+ else if (IsObj(slot))
+ obj = slotRawObject(slot);
+ else
+ assert(false);
+
if (obj && obj->IsPermanent()) {
// don't deallocate these
if (obj != slotRawObject(&o_emptyarray) && obj != slotRawObject(&o_onenilarray) && obj != slotRawObject(&o_argnamethis)) {
@@ -2515,11 +2520,11 @@
break;
case obj_symbol :
if (NotSym(c)) return errWrongType;
- ((int*)(obj->slots))[index] = slotRawInt(c);
+ ((PyrSymbol**)(obj->slots))[index] = slotRawSymbol(c);
break;
case obj_char :
if (NotChar(c)) return errWrongType;
- ((unsigned char*)(obj->slots))[index] = slotRawInt(c);
+ ((unsigned char*)(obj->slots))[index] = slotRawChar(c);
break;
}
return errNone;
@@ -2558,15 +2563,22 @@
{
int hash;
switch (GetTag(a)) {
- case tagObj : hash = Hash(slotRawInt(a)); break;
+ case tagObj : hash = Hash((int32)slotRawObject(a)); break;
case tagInt : hash = Hash(slotRawInt(a)); break;
- case tagChar : hash = Hash(slotRawInt(a) & 255); break;
+ case tagChar : hash = Hash(slotRawChar(a) & 255); break;
case tagSym : hash = slotRawSymbol(a)->hash; break;
case tagNil : hash = 0xA5A5A5A5; break;
case tagFalse : hash = 0x55AA55AA; break;
case tagTrue : hash = 0x69696969; break;
- case tagPtr : hash = Hash(slotRawInt(a)); break;
- default : hash = Hash(GetTag(a) + Hash(slotRawInt(a))); break; // hash for a double
+ case tagPtr : hash = Hash((int32)slotRawPtr(a)); break;
+ default :
+ // hash for a double
+ union {
+ int32 i[2];
+ double d;
+ } u;
+ u.d = slotRawFloat(a);
+ hash = Hash(u.i[0] + Hash(u.i[1]));
}
return hash;
}
Modified: trunk/Source/lang/LangSource/PyrParseNode.cpp
===================================================================
--- trunk/Source/lang/LangSource/PyrParseNode.cpp 2009-12-15 15:16:35 UTC (rev 9599)
+++ trunk/Source/lang/LangSource/PyrParseNode.cpp 2009-12-15 15:17:13 UTC (rev 9600)
@@ -1233,14 +1233,14 @@
}
if (oldmethod) {
- char extPath[1024];
+ char extPath[1024];
- asRelativePath(gCompilingFileSym->name, extPath);
+ asRelativePath(gCompilingFileSym->name, extPath);
post("\tExtension overwriting %s:%s\n\t\tin file '%s'.\n",
slotRawSymbol(&slotRawClass(&oldmethod->ownerclass)->name)->name, slotRawSymbol(&oldmethod->name)->name,
extPath);
- asRelativePath(slotRawSymbol(&oldmethod->filenameSym)->name, extPath);
- post("\t\tOriginal method in file '%s'.\n", extPath);
+ asRelativePath(slotRawSymbol(&oldmethod->filenameSym)->name, extPath);
+ post("\t\tOriginal method in file '%s'.\n", extPath);
method = oldmethod;
freePyrSlot(&method->code);
@@ -1687,7 +1687,7 @@
PyrPushLitNode *node = (PyrPushLitNode*)mDefVal;
if (IsPtr(&node->mSlot)) {
- PyrParseNode* litnode = (PyrParseNode*)slotRawObject(&node->mSlot);
+ PyrParseNode* litnode = (PyrParseNode*)slotRawPtr(&node->mSlot);
if (litnode) {
if (litnode->mClassno == pn_BlockNode) {
//post("hasExpr B %s:%s %s %d\n", slotRawSymbol(&gCompilingClass->name)->name, slotRawSymbol(&gCompilingMethod->name)->name, mVarName->slotRawSymbol(&mSlot)->name, node->mClassno);
@@ -2190,7 +2190,7 @@
ByteCodes compileSubExpressionWithGoto(PyrPushLitNode* litnode, int branchLen, bool onTailBranch)
{
- PyrBlockNode *bnode = (PyrBlockNode*)slotRawObject(&litnode->mSlot);
+ PyrBlockNode *bnode = (PyrBlockNode*)slotRawPtr(&litnode->mSlot);
return compileBodyWithGoto(bnode->mBody, branchLen, onTailBranch);
}
@@ -2245,7 +2245,7 @@
PyrBlockNode *bnode;
anode = (PyrPushLitNode*)node;
if (IsPtr(&anode->mSlot)
- && (bnode = (PyrBlockNode*)(slotRawObject(&anode->mSlot)))->mClassno == pn_BlockNode) {
+ && (bnode = (PyrBlockNode*)(slotRawPtr(&anode->mSlot)))->mClassno == pn_BlockNode) {
if (bnode->mArglist || bnode->mVarlist) {
post("WARNING: FunctionDef contains variable declarations and so"
" will not be inlined.\n");
@@ -2268,7 +2268,7 @@
PyrBlockNode *bnode;
anode = (PyrPushLitNode*)node;
if (IsPtr(&anode->mSlot)
- && (bnode = (PyrBlockNode*)(slotRawObject(&anode->mSlot)))->mClassno == pn_BlockNode) {
+ && (bnode = (PyrBlockNode*)(slotRawPtr(&anode->mSlot)))->mClassno == pn_BlockNode) {
if (bnode->mArglist || bnode->mVarlist) {
post("WARNING: FunctionDef contains variable declarations and so"
" will not be inlined.\n");
@@ -2304,7 +2304,7 @@
PyrBlockNode *bnode;
anode = (PyrPushLitNode*)node;
if (IsPtr(&anode->mSlot)
- && (bnode = (PyrBlockNode*)(slotRawObject(&anode->mSlot)))->mClassno == pn_BlockNode) {
+ && (bnode = (PyrBlockNode*)(slotRawPtr(&anode->mSlot)))->mClassno == pn_BlockNode) {
if (bnode->mArglist || bnode->mVarlist) {
/*
post("WARNING: FunctionDef contains variable declarations and so"
@@ -2607,7 +2607,7 @@
PyrParseNode *arg2 = arg1->mNext;
PyrPushLitNode *litnode = (PyrPushLitNode*)arg1;
- PyrBlockNode *bnode = (PyrBlockNode*)slotRawObject(&litnode->mSlot);
+ PyrBlockNode *bnode = (PyrBlockNode*)slotRawPtr(&litnode->mSlot);
PyrParseNode *bbody = bnode->mBody;
if (bbody->mClassno == pn_DropNode) {
PyrDropNode* dropNode = (PyrDropNode*)bbody;
@@ -2760,7 +2760,7 @@
if (isAtomicLiteral(argnode)) {
key = &keyargnode->mSlot;
} else {
- PyrBlockNode *bnode = (PyrBlockNode*)slotRawObject(&keyargnode->mSlot);
+ PyrBlockNode *bnode = (PyrBlockNode*)slotRawPtr(&keyargnode->mSlot);
PyrDropNode *dropnode = (PyrDropNode*)bnode->mBody;
PyrPushLitNode* litnode = (PyrPushLitNode*)dropnode->mExpr1;
key = &litnode->mSlot;
@@ -3197,7 +3197,7 @@
//postfl("compilePyrPushLitNode\n");
if (IsPtr(&mSlot)) {
- PyrParseNode *literalObj = (PyrParseNode*)slotRawObject(&mSlot);
+ PyrParseNode *literalObj = (PyrParseNode*)slotRawPtr(&mSlot);
//index = conjureLiteralObjIndex(gCompilingBlock, literalObj);
if (literalObj->mClassno == pn_BlockNode) {
savedBytes = saveByteCodeArray();
@@ -3274,7 +3274,7 @@
ByteCodes savedBytes;
if (IsPtr(&mSlot)) {
- PyrParseNode* literalObj = (PyrParseNode*)slotRawObject(&mSlot);
+ PyrParseNode* literalObj = (PyrParseNode*)slotRawPtr(&mSlot);
if (literalObj->mClassno == pn_BlockNode) {
savedBytes = saveByteCodeArray();
COMPILENODE(literalObj, result, false);
@@ -3312,7 +3312,7 @@
compileOpcode(opSpecialOpcode, opcReturnSelf);
} else if (mExpr->mClassno == pn_PushLitNode) {
lit = (PyrPushLitNode*)mExpr;
- if (slotRawSymbol(&lit->mSlot) == s_this && IsSym(&(lit->mSlot))) {
+ if (IsSym(&(lit->mSlot)) && slotRawSymbol(&lit->mSlot) == s_this) {
compileOpcode(opSpecialOpcode, opcReturnSelf);
} else if (IsNil(&lit->mSlot)) {
compileOpcode(opSpecialOpcode, opcReturnNil);
@@ -4166,8 +4166,8 @@
}
}
- selectors = slotRawObject(&func->selectors);
- if (selectors) {
+ if (NotNil(&func->selectors)) {
+ selectors = slotRawObject(&func->selectors);
for (i=0; i<selectors->size; ++i) {
if (IsSym(&selectors->slots[i]) && slotRawSymbol(&selectors->slots[i]) == selector) {
*selType = selNormal;
@@ -4213,20 +4213,18 @@
flags = compilingCmdLine ? obj_immutable : obj_permanent | obj_immutable;
// lookup slot in selectors table
- selectors = slotRawObject(&func->selectors);
- /*if (selectors && selectors->classptr != class_array) {
- post("compiling %s:%s\n", slotRawSymbol(&gCompilingClass->name)->name, slotRawSymbol(&gCompilingMethod->name)->name);
- post("selectors is a '%s'\n", selectors->classptr->name.us->name);
- dumpObjectSlot(slot);
- Debugger();
- }*/
- if (selectors) {
- for (i=0; i<selectors->size; ++i) {
- if (GetTag(&selectors->slots[i]) == GetTag(slot)
- && slotRawInt(&selectors->slots[i]) == slotRawInt(slot)) {
+
+ if (IsObj(&func->selectors)) {
+ selectors = slotRawObject(&func->selectors);
+ /*if (selectors->classptr != class_array) {
+ post("compiling %s:%s\n", slotRawSymbol(&gCompilingClass->name)->name, slotRawSymbol(&gCompilingMethod->name)->name);
+ post("selectors is a '%s'\n", selectors->classptr->name.us->name);
+ dumpObjectSlot(slot);
+ Debugger();
+ }*/
+ for (i=0; i<selectors->size; ++i)
+ if (SlotEq(&selectors->slots[i], slot))
return i;
- }
- }
} else {
selectors = (PyrObject*)newPyrArray(compileGC(), 4, flags, false);
SetObject(&func->selectors, selectors);
@@ -4267,14 +4265,11 @@
flags = compilingCmdLine ? obj_immutable : obj_permanent | obj_immutable;
// lookup slot in constants table
- constants = slotRawObject(&func->constants);
- if (constants) {
- for (i=0; i<constants->size; ++i) {
- if (GetTag(&constants->slots[i]) == GetTag(slot)
- && slotRawInt(&constants->slots[i]) == slotRawInt(slot)) {
+ if (IsObj(&func->constants)) {
+ constants = slotRawObject(&func->constants);
+ for (i=0; i<constants->size; ++i)
+ if (SlotEq(&constants->slots[i], slot))
return i;
- }
- }
} else {
constants = (PyrObject*)newPyrArray(compileGC(), 4, flags, false);
SetObject(&func->constants, constants);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
_______________________________________________
sc-dev mailing list
info (subscription, etc.): http://www.beast.bham.ac.uk/research/sc_mailing_lists.shtml
archive: https://listarc.bham.ac.uk/marchives/sc-dev/
search: https://listarc.bham.ac.uk/lists/sc-dev/search/