primitiveErrorAndLog(void) { char *log; sqInt logLen; sqInt logObj; char *logObjData; sqInt resultObj; logLen = 0; log = getlog((&logLen)); resultObj = instantiateClassindexableSize(classArray(), 2); if (resultObj == 0) { primitiveFailFor(PrimErrNoMemory); return null; } storePointerofObjectwithValue(0, resultObj, integerObjectOf(errorAcorn())); if (logLen > 0) { pushRemappableOop(resultObj); logObj = instantiateClassindexableSize(classString(), logLen); if (failed()) { popRemappableOop(); primitiveFailFor(PrimErrNoMemory); return null; } resultObj = popRemappableOop(); logObjData = arrayValueOf(logObj); memcpy(logObjData, log, logLen); storePointerofObjectwithValue(1, resultObj, logObj); } popthenPush(1, resultObj); if (failed()) { return null; } return null; }
primitiveDisassembleAtInMemory(void) { usqIntptr_t address; void *cpu; sqInt cpuAlien; sqInt instrLenOrErr; sqInt log; sqInt logLen; sqInt logObj; sqInt logObjData; char *memory; sqInt resultObj; logLen = 0; address = (BytesPerOop == 4 ? positive32BitValueOf(stackValue(1)) : positive64BitValueOf(stackValue(1))); success(isWordsOrBytes(stackValue(0))); memory = ((char *) (firstIndexableField(stackValue(0)))); cpuAlien = stackValue(2); if (failed()) { return null; } if (((cpu = ((longAt(cpuAlien + BaseHeaderSize)) > 0 ? (cpuAlien + BaseHeaderSize) + BytesPerOop : longAt((cpuAlien + BaseHeaderSize) + BytesPerOop)))) == 0) { primitiveFailFor(PrimErrBadReceiver); return null; } instrLenOrErr = disassembleForAtInSize(cpu, address, memory, byteSizeOf(((sqInt)(sqIntptr_t)(memory) - BaseHeaderSize))); if (instrLenOrErr < 0) { primitiveFailFor(PrimErrInappropriate); return null; } log = getlog((&logLen)); resultObj = instantiateClassindexableSize(classArray(), 2); if (resultObj == 0) { primitiveFailFor(PrimErrNoMemory); return null; } pushRemappableOop(resultObj); logObj = instantiateClassindexableSize(classString(), logLen); if (failed()) { popRemappableOop(); primitiveFailFor(PrimErrNoMemory); return null; } logObjData = arrayValueOf(logObj); memcpy(logObjData, log, logLen); resultObj = popRemappableOop(); storePointerofObjectwithValue(0, resultObj, integerObjectOf(instrLenOrErr)); storePointerofObjectwithValue(1, resultObj, logObj); if (failed()) { return null; } popthenPush(3, resultObj); return null; }
primitiveFileStdioHandles(void) { // FilePlugin>>#primitiveFileStdioHandles SQFile fileRecords[3]; sqInt index; sqInt result; sqInt validMask; if (sHFAfn != 0) { if (!( ((sqInt (*)(void))sHFAfn)())) { return primitiveFailFor(PrimErrUnsupported); } } validMask = sqFileStdioHandlesInto(fileRecords); if (validMask == 0) { return primitiveFailFor(PrimErrUnsupported); } result = instantiateClassindexableSize(classArray(), 3); if (result == null) { return primitiveFailFor(PrimErrNoMemory); } pushRemappableOop(result); for (index = 0; index <= 2; index += 1) { if ((validMask & (1 << index)) != 0) { result = instantiateClassindexableSize(classByteArray(), sizeof(SQFile)); if (result == null) { popRemappableOop(); return primitiveFailFor(PrimErrNoMemory); } storePointerofObjectwithValue(index, topRemappableOop(), result); memcpy(firstIndexableField(result), (&(fileRecords[index])), sizeof(SQFile)); } } # if COGMTVM fullGC(); # endif /* COGMTVM */ result = popRemappableOop(); popthenPush(1, result); }
/* Matrix2x3Plugin>>#roundAndStoreResultRect:x0:y0:x1:y1: */ static sqInt roundAndStoreResultRectx0y0x1y1(sqInt dstOop, double x0, double y0, double x1, double y1) { sqInt cornerOop; double maxX; double maxY; double minX; double minY; sqInt originOop; sqInt rectOop; minX = x0 + 0.5; if (!((minX >= (((double) (MinSmallInteger) ))) && (minX <= (((double) (MaxSmallInteger) ))))) { return primitiveFail(); } maxX = x1 + 0.5; if (!((maxX >= (((double) (MinSmallInteger) ))) && (maxX <= (((double) (MaxSmallInteger) ))))) { return primitiveFail(); } minY = y0 + 0.5; if (!((minY >= (((double) (MinSmallInteger) ))) && (minY <= (((double) (MaxSmallInteger) ))))) { return primitiveFail(); } maxY = y1 + 0.5; if (!((maxY >= (((double) (MinSmallInteger) ))) && (maxY <= (((double) (MaxSmallInteger) ))))) { return primitiveFail(); } pushRemappableOop(dstOop); originOop = makePointwithxValueyValue(((sqInt)minX), ((sqInt)minY)); pushRemappableOop(originOop); cornerOop = makePointwithxValueyValue(((sqInt)maxX), ((sqInt)maxY)); originOop = popRemappableOop(); rectOop = popRemappableOop(); storePointerofObjectwithValue(0, rectOop, originOop); storePointerofObjectwithValue(1, rectOop, cornerOop); return rectOop; }
primitiveSoundGetVolume(void) { // SoundPlugin>>#primitiveSoundGetVolume double left; sqInt results; double right; left = 0; right = 0; snd_Volume((double *) &left,(double *) &right); pushRemappableOop(floatObjectOf(right)); pushRemappableOop(floatObjectOf(left)); pushRemappableOop(instantiateClassindexableSize(classArray(), 2)); results = popRemappableOop(); storePointerofObjectwithValue(0, results, popRemappableOop()); storePointerofObjectwithValue(1, results, popRemappableOop()); if (failed()) { return null; } popthenPush(1, results); return null; }
static sqInt makeDirEntryNamesizecreateDatemodDateisDirfileSizeposixPermissionsisSymlink(char *entryName, sqInt entryNameSize, sqInt createDate, sqInt modifiedDate, sqInt dirFlag, squeakFileOffsetType fileSize, sqInt posixPermissions, sqInt symlinkFlag) { // FilePlugin>>#makeDirEntryName:size:createDate:modDate:isDir:fileSize:posixPermissions:isSymlink: sqInt createDateOop; sqInt fileSizeOop; sqInt i; sqInt modDateOop; sqInt nameString; sqInt posixPermissionsOop; sqInt results; char *stringPtr; /* allocate storage for results, remapping newly allocated oops in case GC happens during allocation */ pushRemappableOop(instantiateClassindexableSize(classArray(), 7)); pushRemappableOop(instantiateClassindexableSize(classString(), entryNameSize)); pushRemappableOop(positive32BitIntegerFor(createDate)); pushRemappableOop(positive32BitIntegerFor(modifiedDate)); pushRemappableOop(positive64BitIntegerFor(fileSize)); pushRemappableOop(positive32BitIntegerFor(posixPermissions)); posixPermissionsOop = popRemappableOop(); fileSizeOop = popRemappableOop(); modDateOop = popRemappableOop(); createDateOop = popRemappableOop(); nameString = popRemappableOop(); /* copy name into Smalltalk string */ results = popRemappableOop(); stringPtr = firstIndexableField(nameString); for (i = 0; i < entryNameSize; i += 1) { stringPtr[i] = (entryName[i]); } storePointerofObjectwithValue(0, results, nameString); storePointerofObjectwithValue(1, results, createDateOop); storePointerofObjectwithValue(2, results, modDateOop); if (dirFlag) { storePointerofObjectwithValue(3, results, trueObject()); } else { storePointerofObjectwithValue(3, results, falseObject()); } storePointerofObjectwithValue(4, results, fileSizeOop); storePointerofObjectwithValue(5, results, posixPermissionsOop); if (symlinkFlag) { storePointerofObjectwithValue(6, results, trueObject()); } else { storePointerofObjectwithValue(6, results, falseObject()); } return results; }
primitiveTextureGetColorMasks(void) { // B3DAcceleratorPlugin>>#primitiveTextureGetColorMasks sqInt array; sqInt arrayOop; sqInt handle; sqInt i; int masks[4]; sqInt renderer; sqInt result; if (!((methodArgumentCount()) == 3)) { return primitiveFail(); } array = stackObjectValue(0); handle = stackIntegerValue(1); renderer = stackIntegerValue(2); if (failed()) { return null; } if (!((fetchClassOf(array)) == (classArray()))) { return primitiveFail(); } if (!((slotSizeOf(array)) == 4)) { return primitiveFail(); } result = b3dxTextureColorMasks(renderer, handle, masks); if (!result) { return primitiveFail(); } arrayOop = array; for (i = 0; i <= 3; i += 1) { pushRemappableOop(arrayOop); result = positive32BitIntegerFor(masks[i]); arrayOop = popRemappableOop(); storePointerofObjectwithValue(i, arrayOop, result); } return pop(3); }
primitiveExecutableModulesAndOffsets(void) { const struct mach_header *h; const struct mach_header_64 *h64; sqInt i; const char *name; char *nameObjData; sqInt nimages; sqInt resultObj; const struct section *s; const struct section_64 *s64; usqIntptr_t size; usqIntptr_t slide; usqIntptr_t start; sqInt valueObj; # if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 /* _dyld_present was deprecated in 10.5 */ if (!(_dyld_present())) { return primitiveFail(); } # endif /* MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 */ nimages = _dyld_image_count(); resultObj = instantiateClassindexableSize(classArray(), nimages * 4); if (resultObj == 0) { return primitiveFail(); } pushRemappableOop(resultObj); for (i = 0; i < nimages; i += 1) { /* impossible start & size */ start = (size = -1); name = _dyld_get_image_name(i); slide = _dyld_get_image_vmaddr_slide(i); # if __x86_64__ h64 = (const struct mach_header_64 *)_dyld_get_image_header(i); if (!(h64 == null)) { s64 = getsectbynamefromheader_64(h64,SEG_TEXT,SECT_TEXT); if (!(s64 == null)) { start = s64->addr; size = s64->size; } } # else /* __x86_64__ */ h = _dyld_get_image_header(i); if (!(h == null)) { s = getsectbynamefromheader(h,SEG_TEXT,SECT_TEXT); if (!(s == null)) { start = s->addr; size = s->size; } } # endif /* __x86_64__ */ valueObj = instantiateClassindexableSize(classString(), strlen(name)); if (failed()) { popRemappableOop(); return primitiveFail(); } storePointerofObjectwithValue(i * 4, topRemappableOop(), valueObj); nameObjData = arrayValueOf(valueObj); memcpy(nameObjData, name, strlen(name)); valueObj = (BytesPerWord == 8 ? signed64BitIntegerFor(slide) : signed32BitIntegerFor(slide)); if (failed()) { popRemappableOop(); return primitiveFail(); } storePointerofObjectwithValue((i * 4) + 1, topRemappableOop(), valueObj); /* begin positiveMachineIntegerFor: */ valueObj = (BytesPerWord == 8 ? positive64BitIntegerFor(start) : positive32BitIntegerFor(start)); if (failed()) { popRemappableOop(); return primitiveFail(); } storePointerofObjectwithValue((i * 4) + 2, topRemappableOop(), valueObj); /* begin positiveMachineIntegerFor: */ valueObj = (BytesPerWord == 8 ? positive64BitIntegerFor(size) : positive32BitIntegerFor(size)); if (failed()) { popRemappableOop(); return primitiveFail(); } storePointerofObjectwithValue((i * 4) + 3, topRemappableOop(), valueObj); } resultObj = popRemappableOop(); return popthenPush(1, resultObj); }