void AsmJsByteCodeWriter::AsmBrReg2(OpCodeAsmJs op, ByteCodeLabel labelID, RegSlot R1, RegSlot R2)
    {
        CheckOpen();
        CheckLabel(labelID);

        MULTISIZE_LAYOUT_WRITE(AsmBrReg2, op, labelID, R1, R2);
    }
Exemple #2
0
bool FScanner::GetNumber ()
{
	char *stopper;

	CheckOpen();
	if (GetString())
	{
		if (strcmp (String, "MAXINT") == 0)
		{
			Number = INT_MAX;
		}
		else
		{
			Number = (int)strtoll (String, &stopper, 0);
			if (*stopper != 0)
			{
				ScriptError ("SC_GetNumber: Bad numeric constant \"%s\".", String);
			}
		}
		Float = Number;
		return true;
	}
	else
	{
		return false;
	}
}
int FitsFile::GetCurrentHDU()
{
	CheckOpen();
	int hdunum = 0;
	fits_get_hdu_num(_fptr, &hdunum);
	return hdunum;
}
Exemple #4
0
//
// SC_GetNumber
//
BOOL SC_GetNumber (void)
{
	char *stopper;

	CheckOpen ();
	if (SC_GetString())
	{
		if (strcmp (sc_String, "MAXINT") == 0)
		{
			sc_Number = MAXINT;
		}
		else
		{
			sc_Number = strtol (sc_String, &stopper, 0);
			if (*stopper != 0)
			{
				//I_Error ("SC_GetNumber: Bad numeric constant \"%s\".\n"
				//	"Script %s, Line %d\n", sc_String, ScriptName.c_str(), sc_Line);
				Printf (PRINT_HIGH,"SC_GetNumber: Bad numeric constant \"%s\".\n"
					"Script %s, Line %d\n", sc_String, ScriptName.c_str(), sc_Line);
			}
		}
		sc_Float = (float)sc_Number;
		return true;
	}
	else
	{
		return false;
	}
}
void FitsFile::MoveToHDU(int hduNumber)
{
	CheckOpen();
	int status = 0;
	fits_movabs_hdu(_fptr, hduNumber, NULL, &status);
	CheckStatus(status);
}
Exemple #6
0
BOOL SC_GetNumber (void)
{
	char *stopper;

	CheckOpen ();
	if (SC_GetString())
	{
		if (strcmp (sc_String, "MAXINT") == 0)
		{
			sc_Number = INT_MAX;
		}
		else
		{
			sc_Number = strtol (sc_String, &stopper, 0);
			if (*stopper != 0)
			{
				SC_ScriptError ("SC_GetNumber: Bad numeric constant \"%s\".", sc_String);
			}
		}
		sc_Float = (float)sc_Number;
		return true;
	}
	else
	{
		return false;
	}
}
Exemple #7
0
dboolean SC_Check(void)
{
  char *text;

  CheckOpen();
  text = ScriptPtr;
  if (text >= ScriptEndPtr)
  {
    return false;
  }
  while (*text <= 32)
  {
    if (*text == '\n')
    {
      return false;
    }
    text++;
    if(text == ScriptEndPtr)
    {
      return false;
    }
  }
  if (*text == ASCII_COMMENT)
  {
    return false;
  }
  return true;
}
Exemple #8
0
bool FScanner::ScanString (bool tokens)
{
	const char *marker, *tok;
	bool return_val;

	CheckOpen();
	if (AlreadyGot)
	{
		AlreadyGot = false;
		if (!tokens || LastGotToken)
		{
			return true;
		}
		ScriptPtr = LastGotPtr;
		Line = LastGotLine;
	}

	Crossed = false;
	if (ScriptPtr >= ScriptEndPtr)
	{
		End = true;
		return false;
	}

	LastGotPtr = ScriptPtr;
	LastGotLine = Line;

	// In case the generated scanner does not use marker, avoid compiler warnings.
	marker;
#include "sc_man_scanner.h"
	LastGotToken = tokens;
	return return_val;
}
int FitsFile::GetColumnCount()
{
	CheckOpen();
	int rowCount, status = 0;
	fits_get_num_cols(_fptr, &rowCount, &status);
	CheckStatus(status);
	return rowCount;
}
    void AsmJsByteCodeWriter::AsmStartCall(OpCodeAsmJs op, ArgSlot ArgCount, bool isPatching)
    {
        CheckOpen();

        OpLayoutStartCall data;
        data.ArgCount = ArgCount;
        m_byteCodeData.Encode(op, &data, sizeof(data), this, isPatching);
    }
int FitsFile::GetCurrentImageDimensionCount()
{
	CheckOpen();
	int status = 0, naxis = 0;
	fits_get_img_dim(_fptr, &naxis, &status);
	CheckStatus(status);
	return naxis;
}
int FitsFile::GetHDUCount()
{
	CheckOpen();
	int hdunum = 0, status = 0;
	fits_get_num_hdus(_fptr, &hdunum, &status);
	CheckStatus(status);
	return hdunum;
}
int FitsFile::GetRowCount()
{
	CheckOpen();
	long rowCount;
	int status = 0;
	fits_get_num_rows(_fptr, &rowCount, &status);
	CheckStatus(status);
	return rowCount;
}
int FitsFile::GetTableColumnArraySize(int columnIndex)
{
	CheckOpen();
	int typecode = 0, status = 0;
	long repeat = 0, width = 0;
	fits_get_coltype(_fptr, columnIndex, &typecode, &repeat, &width, &status);
	CheckStatus(status);
	return repeat;
}
int FitsFile::GetColumnType(int colNumber)
{
	CheckOpen();
	int typecode, status = 0;
	long repeat, width;
	fits_get_coltype(_fptr, colNumber, &typecode, &repeat, &width, &status);
	CheckStatus(status);
	return typecode;
}
Exemple #16
0
long FitsFile::GetTableDimensionSize(int columnIndex, int dimension)
{
	CheckOpen();
	int naxis = 0, status = 0, maxdim = 10;
	long naxes[10];
	for(size_t i=0;i!=10;++i) naxes[i] = 0;
	fits_read_tdim(_fptr, columnIndex, maxdim, &naxis, naxes, &status);
	CheckStatus(status);
	return naxes[dimension];
}
std::vector<long> FitsFile::GetColumnDimensions(int columnIndex)
{
	CheckOpen();
	int naxis = 0, status = 0;
	constexpr int maxdim = 10;
	std::vector<long> axes(maxdim, 0);
	fits_read_tdim(_fptr, columnIndex, maxdim, &naxis, axes.data(), &status);
	CheckStatus(status);
	axes.resize(naxis);
	return axes;
}
Exemple #18
0
dboolean SC_GetNumber(void)
{
    CheckOpen();

    if (SC_GetString())
    {
        sc_Number = strtol(sc_String, NULL, 0);
        return true;
    }
    else
        return false;
}
    void AsmJsByteCodeWriter::AsmBr(ByteCodeLabel labelID, OpCodeAsmJs op)
    {
        CheckOpen();
        CheckLabel(labelID);

        size_t const offsetOfRelativeJumpOffsetFromEnd = sizeof(OpLayoutAsmBr) - offsetof(OpLayoutAsmBr, RelativeJumpOffset);
        OpLayoutAsmBr data;
        data.RelativeJumpOffset = offsetOfRelativeJumpOffsetFromEnd;

        m_byteCodeData.Encode(op, &data, sizeof(data), this);
        AddJumpOffset(op, labelID, offsetOfRelativeJumpOffsetFromEnd);
    }
long FitsFile::GetColumnDimensionSize(int columnIndex, int dimension)
{
	CheckOpen();
	int naxis = 0, status = 0, maxdim = 10;
	long naxes[10];
	for(size_t i=0;i!=10;++i) naxes[i] = 0;
	fits_read_tdim(_fptr, columnIndex, maxdim, &naxis, naxes, &status);
	CheckStatus(status);
	if(dimension >= naxis)
		throw FitsIOException("Requested dimension index not available in fits file");
	return naxes[dimension];
}
void FitsFile::WriteImage(long startPos, float *buffer, long bufferSize, float nullValue)
{
	CheckOpen();
	int status = 0, dimensions = GetCurrentImageDimensionCount();
	long *firstpixel = new long[dimensions];
	for(int i=0;i < dimensions;i++) {
		firstpixel[i] = 1 + startPos%GetCurrentImageSize(i+1);
		startPos = startPos/GetCurrentImageSize(i+1);
	}
	fits_write_pixnull(_fptr, TFLOAT, firstpixel, bufferSize, buffer, &nullValue, &status);
	delete[] firstpixel;
	CheckStatus(status);
}
long FitsFile::GetCurrentImageSize(int dimension)
{
	CheckOpen();
	if(dimension > GetCurrentImageDimensionCount())
		throw FitsIOException("Parameter outside range");
	int status = 0;
	long *sizes = new long[dimension];
	fits_get_img_size(_fptr, dimension, sizes, &status);
	long size = sizes[dimension-1];
	delete[] sizes;
	CheckStatus(status);
	return size;
}
Exemple #23
0
//
// SC_SavePos
//
// Saves the current script location for restoration later
//
void SC_SavePos (void)
{
	CheckOpen ();
	if (sc_End)
	{
		SavedScriptPtr = NULL;
	}
	else
	{
		SavedScriptPtr = ScriptPtr;
		SavedScriptLine = sc_Line;
	}
}
Exemple #24
0
void LogFile::Raw(const std::wstring& r)
{
	if (!CheckOpen())
		return;

	DWORD written;

	// write the string
	WriteFile(_hLogFile, r.c_str(), r.length() * 2, &written, NULL);
	assert(written == r.length() * 2);

	//::FlushFileBuffers(hLogFile);
	//::CloseHandle(hLogFile);
}
std::string FitsFile::GetTableDimensionName(int index)
{
	CheckOpen();
	std::ostringstream name;
	name << "CTYPE" << (index+1);
	int status = 0;
	char valueStr[256], commentStr[256];
	fits_read_key(_fptr, TSTRING, name.str().c_str(), valueStr, commentStr, &status);
	std::string val;
	if(!status) {
		val = valueStr;
	}
	return val;
}
enum FitsFile::HDUType FitsFile::GetCurrentHDUType()
{
	CheckOpen();
	int hdutypeInt = 0, status = 0;
	fits_get_hdu_type(_fptr, &hdutypeInt, &status);
	CheckStatus(status);
	enum HDUType hduType;
	switch(hdutypeInt) {
		case IMAGE_HDU: hduType = ImageHDUType; break;
		case ASCII_TBL: hduType = ASCIITableHDUType; break;
		case BINARY_TBL: hduType = BinaryTableHDUType; break;
		default: throw FitsIOException("Unknown HDUType returned");
	}
	return hduType;
}
Exemple #27
0
const FScanner::SavedPos FScanner::SavePos ()
{
	SavedPos pos;

	CheckOpen ();
	if (End)
	{
		pos.SavedScriptPtr = NULL;
	}
	else
	{
		pos.SavedScriptPtr = ScriptPtr;
	}
	pos.SavedScriptLine = Line;
	return pos;
}
enum FitsFile::ImageType FitsFile::GetCurrentImageType()
{
	CheckOpen();
	int bitPixInt = 0, status = 0;
	fits_get_img_type(_fptr, &bitPixInt, &status);
	CheckStatus(status);
	enum ImageType imageType;
	switch(bitPixInt) {
		case BYTE_IMG: imageType = Int8ImageType; break;
		case SHORT_IMG: imageType = Int16ImageType; break;
		case LONG_IMG: imageType = Int32ImageType; break;
		case FLOAT_IMG: imageType = Float32ImageType; break;
		case DOUBLE_IMG: imageType = Double64ImageType; break;
		default: throw FitsIOException("Unknown image type returned");
	}
	return imageType;
}
    void AsmJsByteCodeWriter::AddJumpOffset(Js::OpCodeAsmJs op, ByteCodeLabel labelId, uint fieldByteOffset)
    {
        AssertMsg(fieldByteOffset < 100, "Ensure valid field offset");
        CheckOpen();
        CheckLabel(labelId);

        uint jumpByteOffset = m_byteCodeData.GetCurrentOffset() - fieldByteOffset;

        //
        // Branch targets are created in two passes:
        // - In the instruction stream, write "labelID" into "OpLayoutBrC.Offset". Record this
        //   location in "m_jumpOffsets" to be patched later.
        // - When the bytecode is closed, update all "OpLayoutBrC.Offset"'s with their actual
        //   destinations.
        //

        JumpInfo jumpInfo = { labelId, jumpByteOffset };
        m_jumpOffsets->Add(jumpInfo);
    }
void FitsFile::ReadCurrentImageData(long startPos, num_t *buffer, long bufferSize, long double nullValue)
{
	CheckOpen();
	int status = 0, dimensions = GetCurrentImageDimensionCount();
	long *firstpixel = new long[dimensions];
	for(int i=0;i < dimensions;i++) {
		firstpixel[i] = 1 + startPos%GetCurrentImageSize(i+1);
		startPos = startPos/GetCurrentImageSize(i+1);
	}
	double *dblbuffer = new double[bufferSize];
	double dblNullValue = nullValue;
	int anynul = 0;
	fits_read_pix(_fptr, TDOUBLE, firstpixel, bufferSize, &dblNullValue, dblbuffer, &anynul, &status);
	for(int i=0;i<bufferSize;i++)
		buffer[i] = dblbuffer[i];
	delete[] dblbuffer;
	delete[] firstpixel;
	CheckStatus(status);
}