Changeset 144
- Timestamp:
- 05/11/06 14:23:03 (3 years ago)
- Location:
- trunk/orca
- Files:
-
- 23 modified
-
console.c (modified) (1 diff)
-
context.c (modified) (14 diffs)
-
files.c (modified) (6 diffs)
-
gl/audio.c (modified) (1 diff)
-
gl/gx.c (modified) (1 diff)
-
gl/gx.h (modified) (1 diff)
-
gl/joystick.c (modified) (1 diff)
-
gl/main.c (modified) (2 diffs)
-
gl/png_load.c (modified) (1 diff)
-
internal.h (modified) (1 diff)
-
math.c (modified) (6 diffs)
-
op.c (modified) (64 diffs)
-
ovalue.c (modified) (50 diffs)
-
ovalue.h (modified) (4 diffs)
-
parse.c (modified) (8 diffs)
-
project.r (modified) (1 diff)
-
qt/main.cpp (modified) (2 diffs)
-
qt/qorca.cpp (modified) (3 diffs)
-
series.c (modified) (4 diffs)
-
tests/working/blocks.r (modified) (1 diff)
-
tests/working/strings.r (modified) (1 diff)
-
unix/os.c (modified) (6 diffs)
-
win32/os.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/orca/console.c
r61 r144 126 126 { 127 127 OValue* val; 128 val = or RESULT;128 val = orTOS; 129 129 if( (val->type != OT_UNSET) && 130 130 (val->type != OT_OBJECT) && -
trunk/orca/context.c
r140 r144 876 876 body = orBlockN( blk ); 877 877 bi = 0; 878 a1[2].series.n = body; // Replace original on stack to keep from GC. 878 879 orBind( blk, &ctx ); 879 880 … … 1209 1210 1210 1211 /* 1211 'variables [word! block!] 1212 series [series!] 1213 body [block!] 1212 foreach: native [ 1213 'variables [word! block!] 1214 series [series!] 1215 body [block!] 1216 ] 1214 1217 */ 1215 1218 //see orForeachNative … … 1226 1229 OIndex si = a2->series.it; 1227 1230 1228 OIndex sdest = 0; //in second buffer1231 OIndex sdest = 0; //in second buffer 1229 1232 OIndex sorig = si; 1230 1233 OIndex ssrc; … … 1234 1237 OIndex bi = (a1 + 2)->series.it; 1235 1238 1236 // Binding a copy of the body to a private context is horribly 1237 // expensive but what choice do we have? 1238 // Still, 'foreach is faster than 'forall (probably because using paths 1239 // is so slow). 1240 1241 orRefAvailErr( 5 ) // 4 + block-temp 1239 1240 orRefAvailErr( 5 ) // 4 + block-temp 1242 1241 1243 1242 // Must hold body & a2 in case orMakeContext() or orCopyBlock() trigger … … 1275 1274 ++it; 1276 1275 } 1277 1278 1276 } 1279 1277 else … … 1293 1291 body = orBlockN( blk ); 1294 1292 bi = 0; 1293 a1[2].series.n = body; // Replace original on stack to keep from GC. 1295 1294 orBind( blk, &ctx ); 1296 1295 … … 1305 1304 case OT_PATH: 1306 1305 { 1307 OIndex keeptBlkIndex;1308 OBlock* keeptBlock;1309 OValue *keept;1306 OIndex keeptBlkIndex; 1307 OBlock* keeptBlock; 1308 OValue* keept; 1310 1309 1311 1310 blk = orBlockPtr( serN ); 1312 keeptBlock = orMakeBlock( blk->used );1313 keeptBlkIndex = orBlockN( keeptBlock );1314 orRefPush( OT_BLOCK, keeptBlkIndex );1315 keept = keeptBlock->values;1311 keeptBlock = orMakeBlock( blk->used ); 1312 keeptBlkIndex = orBlockN( keeptBlock ); 1313 orRefPush( OT_BLOCK, keeptBlkIndex ); 1314 keept = keeptBlock->values; 1316 1315 send = blk->used; 1317 1316 … … 1328 1327 blk = orBlockPtr( serN ); // Reacquire. 1329 1328 send = blk->used; 1330 keeptBlock = orBlockPtr( keeptBlkIndex ); 1331 keept = keeptBlock->values; 1332 1333 if( !orIfTrue(orRESULT)){ 1334 memCpy( keept + sdest, blk->values + si, vlen * sizeof(OValue) ); 1335 sdest += vlen; 1336 keeptBlock->used = sdest; 1337 } 1329 keeptBlock = orBlockPtr( keeptBlkIndex ); 1330 keept = keeptBlock->values; 1331 1332 if( ! orIfTrue(orTOS) ) 1333 { 1334 memCpy( keept + sdest, blk->values + si, 1335 vlen * sizeof(OValue) ); 1336 sdest += vlen; 1337 keeptBlock->used = sdest; 1338 } 1338 1339 si += vlen; 1339 1340 } 1340 1341 1341 //handle rest, if less values then loopvars1342 // handle rest, if less values then loopvars 1342 1343 1343 1344 if( si < blk->used ) … … 1358 1359 if( orErrorThrown ) 1359 1360 goto error; 1360 1361 blk = orBlockPtr( serN ); // Reacquire. 1362 send = blk->used; 1363 keeptBlock = orBlockPtr( keeptBlkIndex ); 1364 keept = keeptBlock->values; 1365 1366 if( !orIfTrue(orRESULT)){ 1367 memCpy( keept + sdest, blk->values + si, (blk->used - si) * sizeof(OValue) ); 1368 sdest += blk->used - si; 1369 keeptBlock->used = sdest; 1370 } 1371 } 1372 1373 orResultBLOCK( serN ); 1374 blk->used = sorig + sdest; 1375 orRESULT->series.it = sorig; 1376 memCpy( blk->values + sorig, keept, sdest * sizeof(OValue)); 1377 orRefPop( 1 ); //free(keept); 1378 } 1379 break; 1361 blk = orBlockPtr( serN ); // Reacquire. 1362 send = blk->used; 1363 keeptBlock = orBlockPtr( keeptBlkIndex ); 1364 keept = keeptBlock->values; 1365 1366 if( ! orIfTrue(orTOS) ) 1367 { 1368 memCpy( keept + sdest, blk->values + si, 1369 (blk->used - si) * sizeof(OValue) ); 1370 sdest += blk->used - si; 1371 keeptBlock->used = sdest; 1372 } 1373 } 1374 1375 orResultBLOCK( serN ); 1376 blk->used = sorig + sdest; 1377 a1->series.it = sorig; 1378 memCpy( blk->values + sorig, keept, sdest * sizeof(OValue)); 1379 orRefPop( 1 ); //free(keept); 1380 } 1381 break; 1380 1382 1381 1383 case OT_STRING: … … 1385 1387 { 1386 1388 OString* str = orStringPtr( serN ); 1387 char *keept = malloc(str->used);1389 char* keept = malloc(str->used); 1388 1390 send = str->used; 1389 1391 … … 1400 1402 while( si < send ) 1401 1403 { 1402 ssrc = si;1404 ssrc = si; 1403 1405 for( rlen = 0; rlen < vlen; ++rlen ) 1404 1406 (wval + rlen)->integer = str->charArray[ si++ ]; … … 1408 1410 goto error; 1409 1411 str = orStringPtr( serN ); // Reacquire. 1410 send = str->used; 1411 1412 if( !orIfTrue(orRESULT)){ 1413 strNCpy( keept + sdest, str->charArray + ssrc, vlen ); 1414 sdest += vlen; 1415 } 1412 send = str->used; 1413 1414 if( ! orIfTrue(orTOS) ) 1415 { 1416 strNCpy( keept + sdest, str->charArray + ssrc, vlen ); 1417 sdest += vlen; 1418 } 1416 1419 } 1417 1420 … … 1419 1422 { 1420 1423 rlen = str->used - si; 1421 ssrc = si;1424 ssrc = si; 1422 1425 1423 1426 while( si < str->used ) … … 1435 1438 1436 1439 orEvalBlock( orBlockPtr( body ), bi ); 1437 1438 1440 if( orErrorThrown ) 1439 1441 goto error; 1440 1441 str = orStringPtr( serN ); // Reacquire. 1442 str = orStringPtr( serN ); // Reacquire. 1442 1443 send = str->used; 1443 if( !orIfTrue(orRESULT)){ 1444 strNCpy( keept + sdest, str->charArray + ssrc, (str->used - ssrc) ); 1445 sdest += str->used - ssrc; 1446 } 1447 } 1448 1449 orResultSTRING( serN ); 1450 str->used = sorig + sdest; 1451 orRESULT->series.it = sorig; 1452 strNCpy( str->charArray + sorig, keept, str->used ); 1453 free(keept); 1444 if( ! orIfTrue(orTOS) ) 1445 { 1446 strNCpy( keept + sdest, str->charArray + ssrc, 1447 (str->used - ssrc) ); 1448 sdest += str->used - ssrc; 1449 } 1450 } 1451 1452 orResultSTRING( serN ); 1453 str->used = sorig + sdest; 1454 a1->series.it = sorig; 1455 strNCpy( str->charArray + sorig, keept, str->used ); 1456 free(keept); 1454 1457 } 1455 1458 break; 1456 1459 1457 default: 1458 orError("remove-each for this type not implemented"); 1459 1460 1461 /* case OT_LIST: */ 1462 /* if( a1->type == OT_BLOCK ) */ 1463 /* { */ 1464 /* orError( "foreach block! list! not implemented" ); */ 1465 /* break; */ 1466 /* } */ 1467 1468 /* orResultNONE; */ 1469 1470 /* if( a2->series.index ) */ 1471 /* { */ 1472 /* OValue* begin; */ 1473 /* OValue* it; */ 1474 1475 /* blk = orBLOCK(a2); */ 1476 /* begin = blk->values; */ 1477 /* it = begin + a2->series.index; */ 1478 1479 /* while( it->LIST_NEXT > 0 ) */ 1480 /* { */ 1481 /* orCopyV( wval, it[1] ); */ 1482 1483 /* orEvalBlock( orBlockPtr( body ), bi ); */ 1484 /* if( orErrorThrown ) */ 1485 /* goto error; */ 1486 1487 /* //blk = orBlockPtr( serN ); // Reacquire. */ 1488 /* //orListNextNode( blk, it ); */ 1489 /* it = begin + it->LIST_NEXT; */ 1490 /* } */ 1491 /* } */ 1492 /* break; */ 1460 default: 1461 orError("remove-each for this type not implemented"); 1493 1462 } 1494 1463 -
trunk/orca/files.c
r136 r144 26 26 extern int orIsDir( const char* path ); 27 27 extern int orFileModified( const char* path, OValue* res ); 28 extern void orReadDir( const char* filename );28 extern void orReadDir( OValue*, const char* filename ); 29 29 extern void orNowNative( OValue* a1 ); 30 30 extern void orChangeDirNative( OValue* a1 ); … … 126 126 OString* str = orSTRING(a1); 127 127 orTermCStr( str ); 128 status = orFileModified( str->charArray + a1->series.it, orRESULT);128 status = orFileModified( str->charArray + a1->series.it, a1 ); 129 129 if( status < 0 ) 130 130 { … … 248 248 #define REF_READ_SIZE a1+6 249 249 250 /* 251 read: native [ 252 source [file! port!] 253 /binary 254 /lines 255 /skip length [number!] 256 /part size [number!] 257 ] 258 */ 250 259 OR_NATIVE( orReadNative ) 251 260 { … … 257 266 258 267 orTermCStr( str ); 259 260 268 fn = str->charArray + a1->series.it; 269 261 270 n = orIsDir( fn ); 262 271 if( n < 0 ) … … 266 275 else if( n == 1 ) 267 276 { 268 orReadDir( fn ); 277 // TODO: Hold a1 from GC (or copy fn). 278 orReadDir( a1, fn ); 269 279 } 270 280 else … … 361 371 362 372 assert( (devID > -1) && (devID < arr->used) ); 363 ((OPortDevice**) arr->buf)[ devID ]->read( &a1->ctx );373 ((OPortDevice**) arr->buf)[ devID ]->read( &a1->ctx, a1 ); 364 374 } 365 375 } -
trunk/orca/gl/audio.c
r43 r144 157 157 alGenBuffers( 1, &buffer ); 158 158 alBufferData( buffer, format, data, size, freq ); 159 { 160 OValue* a1 = orTOS; 159 161 orResult( OT_SOUND, buffer ); 162 } 160 163 } 161 164 else -
trunk/orca/gl/gx.c
r86 r144 480 480 resd_add( &gEnv.resd, &tex->res, key ); 481 481 482 result = or RESULT;482 result = orTOS; 483 483 orCopyV( result, *val ); 484 484 orLoadNative( result ); -
trunk/orca/gl/gx.h
r42 r144 147 147 148 148 #define gxResultRES(rp) \ 149 {OValue* _or_result = orRESULT; \ 150 orSetTF(_or_result, OT_RESOURCE); \ 151 _or_result->argc = rp->res.resType; \ 152 _or_result->index = rp->res.resKey;} 149 {orSetTF(a1, OT_RESOURCE); \ 150 a1->argc = rp->res.resType; \ 151 a1->index = rp->res.resKey;} 153 152 154 153 #define gxResType(val) val->argc -
trunk/orca/gl/joystick.c
r54 r144 132 132 Set 'input block values. 133 133 */ 134 static void jsRead( OContext* ctx )134 static void jsRead( OContext* ctx, OValue* a1 ) 135 135 { 136 136 int events = 0; -
trunk/orca/gl/main.c
r61 r144 56 56 { 57 57 OIndex strN; 58 OValue* tos; 58 59 60 tos = orTOS; 59 61 strN = orMakeCString( argv[1], -1 ); 60 orResultFILE( strN ); 62 orSetTF(tos, OT_FILE ); 63 orSetSeries(tos, strN, 0 ); 61 64 62 orDoNative( orRESULT);65 orDoNative( tos ); 63 66 if( orErrorThrown ) 64 67 { … … 123 126 { 124 127 OValue* val; 125 val = or RESULT;128 val = orTOS; 126 129 if( (val->type != OT_UNSET) && 127 130 (val->type != OT_OBJECT) && -
trunk/orca/gl/png_load.c
r1 r144 57 57 58 58 bin = orMakeImage( format, width, height ); 59 { 60 OValue* a1 = orTOS; 59 61 orResult( OT_IMAGE, orBinaryN(bin) ); 62 } 60 63 61 64 if( bin->byteArray ) -
trunk/orca/internal.h
r26 r144 15 15 16 16 17 #define or PushStack ++orEnv->dataStack.used18 #define or PopStack --orEnv->dataStack.used17 #define orStackGrow(n) orEnv->dataStack.used += n 18 #define orStackDrop(n) orEnv->dataStack.used -= n 19 19 20 20 #define OA_EXPAND1(type,arr,newptr) \ -
trunk/orca/math.c
r94 r144 170 170 171 171 172 static void orOpPower( OValue* a )172 static void orOpPower( OValue* a1 ) 173 173 { 174 174 double x, y; 175 OValue* b = a + 1;176 if( a ->type == OT_INTEGER )175 OValue* b = a1 + 1; 176 if( a1->type == OT_INTEGER ) 177 177 { 178 178 if( b->type == OT_INTEGER ) … … 182 182 if( n ) 183 183 { 184 sum = orInt(a );184 sum = orInt(a1); 185 185 while( --n ) 186 sum *= orInt(a );186 sum *= orInt(a1); 187 187 } 188 188 else … … 195 195 else if( b->type == OT_DECIMAL ) 196 196 { 197 x = (double) orInt(a );197 x = (double) orInt(a1); 198 198 y = orDecimal(b); 199 199 goto fp; 200 200 } 201 a = b;202 } 203 else if( a ->type == OT_DECIMAL )204 { 205 x = orDecimal(a );201 a1 = b; 202 } 203 else if( a1->type == OT_DECIMAL ) 204 { 205 x = orDecimal(a1); 206 206 if( b->type == OT_INTEGER ) 207 207 { … … 214 214 goto fp; 215 215 } 216 a = b;217 } 218 orErrorOp( "**", a );216 a1 = b; 217 } 218 orErrorOp( "**", a1 ); 219 219 return; 220 220 … … 224 224 225 225 226 static void orOpRemainder( OValue* a )226 static void orOpRemainder( OValue* a1 ) 227 227 { 228 228 double x, y; 229 OValue* b = a + 1;230 if( a ->type == OT_INTEGER )229 OValue* b = a1 + 1; 230 if( a1->type == OT_INTEGER ) 231 231 { 232 232 if( b->type == OT_INTEGER ) 233 233 { 234 orResult( OT_INTEGER, orInt(a ) % orInt(b) );234 orResult( OT_INTEGER, orInt(a1) % orInt(b) ); 235 235 return; 236 236 } 237 237 else if( b->type == OT_DECIMAL ) 238 238 { 239 x = (double) orInt(a );239 x = (double) orInt(a1); 240 240 y = orDecimal(b); 241 241 goto fp; 242 242 } 243 a = b;244 } 245 else if( a ->type == OT_DECIMAL )246 { 247 x = orDecimal(a );243 a1 = b; 244 } 245 else if( a1->type == OT_DECIMAL ) 246 { 247 x = orDecimal(a1); 248 248 if( b->type == OT_INTEGER ) 249 249 { … … 256 256 goto fp; 257 257 } 258 a = b;259 } 260 orErrorOp( "//", a );258 a1 = b; 259 } 260 orErrorOp( "//", a1 ); 261 261 return; 262 262 -
trunk/orca/op.c
r98 r144 28 28 29 29 30 void orOpAdd( OValue* a )31 { 32 OValue* b = a + 1;33 if( orIs(a , OT_INTEGER) )34 { 35 if( orIs(b, OT_INTEGER) ) 36 { 37 orResult( OT_INTEGER, orInt(a ) + orInt(b) );38 return; 39 } 40 else if( orIs(b, OT_DECIMAL) ) 41 { 42 orResultDECIMAL( (double) orInt(a ) + orDecimal(b) );30 void orOpAdd( OValue* a1 ) 31 { 32 OValue* b = a1 + 1; 33 if( orIs(a1, OT_INTEGER) ) 34 { 35 if( orIs(b, OT_INTEGER) ) 36 { 37 orResult( OT_INTEGER, orInt(a1) + orInt(b) ); 38 return; 39 } 40 else if( orIs(b, OT_DECIMAL) ) 41 { 42 orResultDECIMAL( (double) orInt(a1) + orDecimal(b) ); 43 43 return; 44 44 } … … 52 52 for( i = 0; i < res->argc; i++ ) 53 53 { 54 tmp = orInt(a ) + b->tuple[i];54 tmp = orInt(a1) + b->tuple[i]; 55 55 res->tuple[i] = orToByteRange(tmp); 56 56 } … … 59 59 return; 60 60 } 61 a = b;62 } 63 else if( orIs(a , OT_DECIMAL) )64 { 65
