Exemplo n.º 1
0
static void DumpConstants(const Proto* f, DumpState* D)
{
 int i,n=f->sizek;
 DumpInt(n,D);
 for (i=0; i<n; i++)
 {
  const TValue* o=&f->k[i];
  DumpChar(ttype(o),D);
  switch (ttype(o))
  {
   case LUA_TNIL:
	break;
   case LUA_TBOOLEAN:
	DumpChar(bvalue(o),D);
	break;
   case LUA_TNUMBER:
	DumpNumber(nvalue(o),D);
	break;
   case LUA_TSTRING:
	DumpString(rawtsvalue(o),D);
	break;
  }
 }
 n=f->sizep;
 DumpInt(n,D);
 for (i=0; i<n; i++) DumpFunction(f->p[i],D);
}
Exemplo n.º 2
0
int          clsDump::DumpScope(clsScope * pScope, int onlyCalculateSize)
{
  int          iSize = 0;
  unsigned int iIndex;

  iSize += DumpLine("----- SCOPE BEG -----\n", onlyCalculateSize);
  iSize += DumpLine("\tUID %u\n", pScope->m_UID, onlyCalculateSize);
  iSize += DumpLocation(pScope->m_Location, onlyCalculateSize);
  _Assert(pScope->m_pParentScope && "Frontend Error: All scopes should have a parent.");
  iSize += DumpLine("\tParent Scope UID %u\n", pScope->m_pParentScope->m_UID, onlyCalculateSize);
  _Assert(pScope->m_pRootScope && "Frontend Error: All scopes should have a root.");
  iSize += DumpLine("\tRoot Scope UID %u\n", pScope->m_pRootScope->m_UID, onlyCalculateSize);
  iSize += DumpLine("\tNumber of Children Scopes %u\n", pScope->m_pChildrenScopes.size(), onlyCalculateSize);
  for (iIndex = 0; iIndex < pScope->m_pChildrenScopes.size(); ++iIndex)
  {
    iSize += DumpLine("\tChild Scope UID %u\n", pScope->m_pChildrenScopes[iIndex]->m_UID, onlyCalculateSize);
  }
  iSize += DumpLine("\tNumber of Signals %u\n", pScope->m_pSignals.size(), onlyCalculateSize);
  for (iIndex = 0; iIndex < pScope->m_pSignals.size(); ++iIndex)
  {
    iSize += DumpLine("\tSignal UID %u\n", pScope->m_pSignals[iIndex]->m_UID, onlyCalculateSize);
  }
  iSize += DumpLine("\tNumber of Arguments %u\n", pScope->m_pArguments.size(), onlyCalculateSize);
  for (iIndex = 0; iIndex < pScope->m_pArguments.size(); ++iIndex)
  {
    iSize += DumpLine("\tArgument UID %u\n", pScope->m_pArguments[iIndex]->m_UID, onlyCalculateSize);
  }
  iSize += DumpLine("\tNumber of Parameters %u\n", pScope->m_pParameters.size(), onlyCalculateSize);
  for (iIndex = 0; iIndex < pScope->m_pParameters.size(); ++iIndex)
  {
    iSize += DumpLine("\tParameter UID %u\n", pScope->m_pParameters[iIndex]->m_UID, onlyCalculateSize);
  }
  iSize += DumpLine("\tNumber of Conditions %u\n", pScope->m_pConditions.size(), onlyCalculateSize);
  for (iIndex = 0; iIndex < pScope->m_pConditions.size(); ++iIndex)
  {
    iSize += DumpLine("\tCondition UID %u\n", pScope->m_pConditions[iIndex]->m_UID, onlyCalculateSize);
  }
  iSize += DumpLine("\tNumber of Events %u\n", pScope->m_pEvents.size(), onlyCalculateSize);
  for (iIndex = 0; iIndex < pScope->m_pEvents.size(); ++iIndex)
  {
    iSize += DumpLine("\tEvent UID %u\n", pScope->m_pEvents[iIndex]->m_UID, onlyCalculateSize);
  }
  if (pScope->m_pBasicBlock)
  {
    iSize += DumpLine("\tHas Basicblock %u\n", true, onlyCalculateSize);
    iSize += DumpLine("\tBasicblock UID %u\n", pScope->m_pBasicBlock->m_UID, onlyCalculateSize);
  }
  else
  {
    iSize += DumpLine("\tHas No Basicblock %u\n", false, onlyCalculateSize);
  }
  iSize += DumpString("\tScope Name\n", pScope->m_sScopeName, onlyCalculateSize);
  iSize += DumpLine("\tScope Type UID %u\n", pScope->m_pScopeType->m_UID, onlyCalculateSize);
  iSize += DumpLine("\tScope is Root = %u\n", pScope->m_IsRoot, onlyCalculateSize);
  iSize += DumpLine("\tScope is Automatic = %u\n", pScope->m_IsAutomatic, onlyCalculateSize);
  iSize += DumpLine("----- SCOPE END -----\n", onlyCalculateSize);

  return iSize;
}
Exemplo n.º 3
0
static void DumpDebug (const Proto *f, DumpState *D) {
  int i, n;
  n = (D->strip) ? 0 : f->sizelineinfo;
  DumpInt(n, D);
  DumpVector(f->lineinfo, n, D);
  n = (D->strip) ? 0 : f->sizelocvars;
  DumpInt(n, D);
  for (i = 0; i < n; i++) {
    DumpString(f->locvars[i].varname, D);
    DumpInt(f->locvars[i].startpc, D);
    DumpInt(f->locvars[i].endpc, D);
  }
  n = (D->strip) ? 0 : f->sizeupvalues;
  DumpInt(n, D);
  for (i = 0; i < n; i++)
    DumpString(f->upvalues[i].name, D);
}
Exemplo n.º 4
0
static void DumpFunction (const Proto *f, TString *psource, DumpState *D) {
  const SharedProto *sp = f->sp;
  if (D->strip || sp->source == psource)
    DumpString(NULL, D);  /* no debug info or same source as its parent */
  else
    DumpString(sp->source, D);
  DumpInt(sp->linedefined, D);
  DumpInt(sp->lastlinedefined, D);
  DumpByte(sp->numparams, D);
  DumpByte(sp->is_vararg, D);
  DumpByte(sp->maxstacksize, D);
  DumpCode(sp, D);
  DumpConstants(f, D);
  DumpUpvalues(f, D);
  DumpProtos(f, D);
  DumpDebug(sp, D);
}
Exemplo n.º 5
0
static void DumpDebug(const LuaProto* f, DumpState* D)
{
 int i,n;
 DumpString((D->strip) ? NULL : f->source,D);
 n= (D->strip) ? 0 : (int)f->lineinfo.size();
 DumpVector(f->lineinfo.begin(),n,sizeof(int),D);
 n= (D->strip) ? 0 : (int)f->locvars.size();
 DumpInt(n,D);
 for (i=0; i<n; i++)
 {
  DumpString(f->locvars[i].varname,D);
  DumpInt(f->locvars[i].startpc,D);
  DumpInt(f->locvars[i].endpc,D);
 }
 n= (D->strip) ? 0 : (int)f->upvalues.size();
 DumpInt(n,D);
 for (i=0; i<n; i++) DumpString(f->upvalues[i].name,D);
}
Exemplo n.º 6
0
extern  void    DumpOc( ins_entry *ins ) {
/****************************************/

    DumpPtr( ins );
    DumpLiteral( " " );
    DumpString(  CNames[ _Class( ins ) ] );
    DumpLiteral( " " );
    if( _Class( ins ) != OC_INFO ) {
        CheckAttr( ins->oc.oc_header.class );
    }
Exemplo n.º 7
0
void    DumpOc( ins_entry *ins )
/******************************/
{
    DumpPtr( ins );
    DumpChar( ' ' );
    DumpString(  CNames[_Class( ins )] );
    DumpChar( ' ' );
    if( _Class( ins ) != OC_INFO ) {
        CheckAttr( ins->oc.oc_header.class );
    }
Exemplo n.º 8
0
void    DumpOpcodeName( int opcode )
/**********************************/
{
    if( opcode > OP_BLOCK || opcode < 0 ) {
        DumpLiteral( "??????" );
    } else {
        DumpString( OpcodeList[opcode] );
        DumpChar( ' ' );
    }
}
Exemplo n.º 9
0
Arquivo: luac.c Projeto: jcubic/ToME
static void DumpLocals(const Proto* tf, void* D)
{
	int i,n=tf->nlocvars;
	DumpInt(n,D);
	for (i=0; i<n; i++)
	{
		DumpString(tf->locvars[i].varname,D);
		DumpInt(tf->locvars[i].startpc,D);
		DumpInt(tf->locvars[i].endpc,D);
	}
}
Exemplo n.º 10
0
static void DumpLocals(const Proto* f, DumpState* D)
{
 int i,n=f->sizelocvars;
 DumpInt(n,D);
 for (i=0; i<n; i++)
 {
  DumpString(f->locvars[i].varname,D);
  DumpInt(f->locvars[i].startpc,D);
  DumpInt(f->locvars[i].endpc,D);
 }
}
Exemplo n.º 11
0
int          clsDump::DumpLocation(clsLocation Location, int onlyCalculateSize)
{
  int iSize = 0;

  iSize += DumpLine("- - - LOCATION BEG - - -\n", onlyCalculateSize);
  iSize += DumpString("\tFile\n", Location.m_sFile, onlyCalculateSize);
  iSize += DumpLine("\tLine %u\n", Location.m_iLine, onlyCalculateSize);
  iSize += DumpLine("- - - LOCATION END - - -\n", onlyCalculateSize);

  return iSize;
}
Exemplo n.º 12
0
Arquivo: luac.c Projeto: jcubic/ToME
static void DumpFunction(const Proto* tf, void* D)
{
	DumpString(tf->source,D);
	DumpInt(tf->lineDefined,D);
	DumpInt(tf->numparams,D);
	DumpByte(tf->is_vararg,D);
	DumpInt(tf->maxstacksize,D);
	DumpLocals(tf,D);
	DumpLines(tf,D);
	DumpConstants(tf,D);
	DumpCode(tf,D);
}
Exemplo n.º 13
0
Arquivo: luac.c Projeto: jcubic/ToME
static void DumpConstants(const Proto* tf, void* D)
{
	int i,n;
	DumpInt(n=tf->nkstr,D);
	for (i=0; i<n; i++)
		DumpString(tf->kstr[i],D);
	DumpInt(tf->nknum,D);
	DumpVector(tf->knum,tf->nknum,sizeof(*tf->knum),D);
	DumpInt(n=tf->nkproto,D);
	for (i=0; i<n; i++)
		DumpFunction(tf->kproto[i],D);
}
Exemplo n.º 14
0
static void DumpDebug (const Proto *f, DumpState *D) {
  int i, n;
  n = (D->strip) ? 0 : f->sizelineinfo;
  DumpInt(n, D);
  DumpVector(f->lineinfo, n, D);
  /* n = (D->strip) ? 0 : f->sizelocvars; */
  n = f->sizelocvars;
  DumpInt(n, D);
  for (i = 0; i < n; i++) {
    DumpString((D->strip) ? NULL : f->locvars[i].varname, D);
    DumpInt(f->locvars[i].startpc, D);
    DumpInt(f->locvars[i].endpc, D);
    DumpByte(f->locvars[i].ravi_type, D);
  }
  /* n = (D->strip) ? 0 : f->sizeupvalues; */
  n = f->sizeupvalues;
  DumpInt(n, D);
  for (i = 0; i < n; i++) {
    DumpString((D->strip) ? NULL : f->upvalues[i].name, D);
    DumpByte(f->upvalues[i].type, D);
  }
}
Exemplo n.º 15
0
static void DumpFunction(const Proto* f, const TString* p, DumpState* D)
{
    DumpString((f->source==p || D->strip) ? NULL : f->source,D);
    DumpInt(f->linedefined,D);
    DumpInt(f->lastlinedefined,D);
    DumpChar(f->nups,D);
    DumpChar(f->numparams,D);
    DumpChar(f->is_vararg,D);
    DumpChar(f->maxstacksize,D);
    DumpCode(f,D);
    DumpConstants(f,D);
    DumpDebug(f,D);
}
Exemplo n.º 16
0
/**  Attempt to synchronize with an Analog Device ARM micro.  Sends a
backspace and reads back the microcontrollers response.  Performs
multiple retries. Exits the program on error, returns to caller in the
case of success.
*/
static void AnalogDevicesSync(ISP_ENVIRONMENT *IspEnvironment)
{
    BINARY sync;                        /* Holds sync command.          */
    AD_SYNC_RESPONSE response;          /* Response from micro.         */
    int sync_attempts;                  /* Number of retries.           */

    /*  Make sure we don't read garbage later instead of the        */
    /* response we expect from the micro.                           */
    ClearSerialPortBuffers(IspEnvironment);

    DebugPrintf(2, "Synchronizing\n"); /* Progress report.             */

    sync = ANALOG_DEVICES_SYNC_CHAR;    /* Build up sync command.       */

    /*  Perform the actual sync attempt.  First send the sync       */
    /* character, the attempt to read back the response.  For the   */
    /* AD ARM micro this is a fixed length block.  If response is   */
    /* received attempt to validate it by comparing the first       */
    /* characters to those expected.  If the received block does    */
    /* not validate or is incomplete empty the serial buffer and    */
    /* retry.                                                       */
    for (sync_attempts = 0; sync_attempts < 5; sync_attempts++)
    {
        SendComPortBlock(IspEnvironment, &sync, 1);

        if (ReceiveComPortBlockComplete(IspEnvironment, &response, sizeof(response),
            500) == 0)
        {

            if (memcmp(response.product_id, ANALOG_DEVICES_SYNC_RESPONSE,
                ANALOG_DEVICES_SYNC_SIZE) == 0)
            {
                return;
            }
            else
            {
                DumpString(3, &response, sizeof(response),
                    "Unexpected response to sync attempt ");
            }
        }
        else
        {
            DebugPrintf(3, "No (or incomplete) answer on sync attempt\n");
        }

        ClearSerialPortBuffers(IspEnvironment);
    }

    DebugPrintf(1, "No (or unacceptable) answer on sync attempt\n");
    exit(4);
}
Exemplo n.º 17
0
static void DumpFunction(const Proto* f, const TString* p, DumpState* D)
{
 DumpString((f->source==p) ? NULL : f->source,D);
 DumpInt(f->lineDefined,D);
 DumpByte(f->nups,D);
 DumpByte(f->numparams,D);
 DumpByte(f->is_vararg,D);
 DumpByte(f->maxstacksize,D);
 DumpLines(f,D);
 DumpLocals(f,D);
 DumpUpvalues(f,D);
 DumpConstants(f,D);
 DumpCode(f,D);
}
Exemplo n.º 18
0
bool DumpContents( WResTypeInfo *type, WResResInfo *res,
                    WResLangInfo *lang, WResFileID handle, uint_16 os )
/*********************************************************************/
{
    bool    error;

    res = res;
    fprintf( stdout, "\tOffset: 0x%08lx  Length: 0x%08lx\n",
            lang->Offset, lang->Length );

    if (type->TypeName.IsName) {
        /* it is not one of the predefined types */
        error = false;
    } else {
        switch (type->TypeName.ID.Num) {
        case RESOURCE2INT( RT_MENU ):
            if( os == WRES_OS_WIN16 ) {
                error = DumpMenu( lang->Offset, lang->Length, handle );
            } else {
                error = false;
            }
            break;
        case RESOURCE2INT( RT_DIALOG ):
            if( os == WRES_OS_WIN16 ) {
                error = DumpDialog( lang->Offset, lang->Length, handle );
            } else {
                error = false;
            }
            break;
        case RESOURCE2INT( RT_GROUP_ICON ):
            error = DumpIconGroup( lang->Offset, lang->Length, handle );
            break;
        case RESOURCE2INT( RT_GROUP_CURSOR ):
            error = DumpCursorGroup( lang->Offset, lang->Length, handle );
            break;
        case RESOURCE2INT( RT_STRING ):
            if( os == WRES_OS_WIN16 ) {
                error = DumpString( lang->Offset, lang->Length, handle );
            } else {
                error = false;
            }
            break;
        default:
            error = false;
            break;
        }
    }

    return( error );
}
Exemplo n.º 19
0
void DumpFunction(TFunc* tf, FILE* D)
{
 lastF=tf;
 ThreadCode(tf->code,tf->code+tf->size);
 fputc(ID_FUN,D);
 DumpSize(tf->size,D);
 DumpWord(tf->lineDefined,D);
 if (IsMain(tf))
  DumpString(tf->fileName,D);
 else
  DumpWord(tf->marked,D);
 DumpBlock(tf->code,tf->size,D);
 DumpStrings(D);
}
Exemplo n.º 20
0
int __cdecl wmain(int argc, WCHAR* argv[])
{
	// Tèst string ?? nørmälize 
	LPWSTR strInput = L"T\u00e8st Ÿ\u011E\u011F ? ? Ç string \uFF54\uFF4F n\u00f8rm\u00e4lize";

	wprintf(L"Comparison of Normalization Forms, input string::\n");
	DumpString(strInput);
	LPWSTR str = L"Ÿ\u011E\u011F\u00e8\u00f8";
	LPWSTR str2 = L"asdfjkj.,/*&^%$#@!1283849";
	if (IsNormalizedString(NormalizationD, str2, -1)) {
		wprintf(L"shit happens");

	}

	// Try it in the 4 forms 
	wprintf(L"\n");
	wprintf(L"String in Form C:\n  ");
	TryNormalization(NormalizationC, strInput);

	wprintf(L"\n");
	wprintf(L"String in Form KC:\n  ");
	TryNormalization(NormalizationKC, strInput);

	wprintf(L"\n");
	wprintf(L"String in Form D:\n  ");
	TryNormalization(NormalizationD, strInput);

	wprintf(L"\n");
	wprintf(L"String in Form KD:\n  ");
	TryNormalization(NormalizationKD, strInput);

	// Note that invalid Unicode would show an error (illegal lone surrogate in this case) 
	wprintf(L"\n");
	wprintf(L"Attempt to normalize illegal lone surrogate:\n");
	TryNormalization(NormalizationC, L"Bad surrogate is here: '\xd800'");

	// Contrived strings can cause the initial size guess to be low 
	wprintf(L"\n");
	wprintf(L"Attempt to normalize a string that expands beyond the initial guess\n");
	TryNormalization(NormalizationC,
		// These all expand to 2 characters 
		L"\u0958\u0958\u0958\u0958\u0958\u0958\u0958\u0958\u0958\u0958\u0958\u0958"
		L"\u0958\u0958\u0958\u0958\u0958\u0958\u0958\u0958\u0958\u0958\u0958\u0958"
		L"\u0958\u0958\u0958\u0958\u0958\u0958\u0958\u0958\u0958\u0958\u0958\u0958"
		L"\u0958\u0958\u0958\u0958\u0958\u0958\u0958\u0958\u0958\u0958\u0958\u0958"
		// These all expand to 3 characters 
		L"\ufb2c\ufb2c\ufb2c\ufb2c\ufb2c\ufb2c\ufb2c\ufb2c\ufb2c\ufb2c\ufb2c\ufb2c"
		L"\ufb2c\ufb2c\ufb2c\ufb2c\ufb2c\ufb2c\ufb2c\ufb2c\ufb2c\ufb2c\ufb2c\ufb2c");
}
Exemplo n.º 21
0
static void DumpStrings(FILE* D)
{
 int i;
 for (i=0; i<lua_ntable; i++)
 {
  if (VarLoc(i)!=0)
  {
   fputc(ID_VAR,D);
   DumpWord(VarLoc(i),D);
   DumpString(VarStr(i),D);
  }
  VarLoc(i)=i;
 }
 for (i=0; i<lua_nconstant; i++)
 {
  if (StrLoc(i)!=0)
  {
   fputc(ID_STR,D);
   DumpWord(StrLoc(i),D);
   DumpString(StrStr(i),D);
  }
  StrLoc(i)=i;
 }
}
Exemplo n.º 22
0
static void DumpFunction(const Proto* tf, FILE* D)
{
 DumpString(tf->source,D);
 DumpInt(tf->lineDefined,D);
 DumpInt(tf->numparams,D);
 DumpByte(tf->is_vararg,D);
 DumpInt(tf->maxstacksize,D);
 DumpLocals(tf,D);
 DumpLines(tf,D);
 DumpConstants(tf,D);
 DumpCode(tf,D);
 if (ferror(D))
 {
  perror("luac: write error");
  exit(1);
 }
}
Exemplo n.º 23
0
bool Object::Combine(const Object& img, bool allow_mix, float factor) {
  AddValue(img.Value(), factor);
  
  if (!allow_mix && (stagevalues.Nitems() || img.stagevalues.Nitems()) &&
      (stagevalues.Nitems()!=1 || img.stagevalues.Nitems()!=1)) {
    char txt[100];
    sprintf(txt, "%d %d", stagevalues.Nitems(), img.stagevalues.Nitems());
    return ShowError("Object::Combine() error #1a: ", txt);
  }

  if (allow_mix && stagevalues.Nitems()!=img.stagevalues.Nitems()) {
    char txt[100];
    sprintf(txt, "%d %d", stagevalues.Nitems(), img.stagevalues.Nitems());
    return ShowError("Object::Combine() error #1b: ", txt);
  }

  for (int j=0; j<stagevalues.Nitems(); j++) {
    FloatVector &dst = stagevalues[j];
    const FloatVector &src = img.stagevalues[j];

    if (dst.Length()!=src.Length() || dst.Length()<2) {
      char txt[100];
      sprintf(txt, "j=%d %d %d", j, dst.Length(), src.Length());
      return ShowError("Object::Combine() error #2: ", txt);
    }
  
    for (int i=0; i<dst.Length()-1; i++) {
      if (!allow_mix && dst[i]!=MAXFLOAT && src[i]!=MAXFLOAT) {
	cout << "this=" <<     DumpString(-1) << endl;
	cout << "img =" << img.DumpString(-1) << endl;
	char txt[100];
	sprintf(txt, "j=%d i=%d", j, i);
	return ShowError("Object::Combine() error #3: ", txt);
      }
      if (src[i]!=MAXFLOAT) {
	if (dst[i]==MAXFLOAT)
	  dst[i] = src[i];
	else
	  dst[i] += src[i];
      }
    }
    dst.Last() = value;
  }

  return true;
}
Exemplo n.º 24
0
static TRI_aql_node_t* DumpNode (TRI_aql_statement_walker_t* const walker,
                                 TRI_aql_node_t* const node) {
  TRI_aql_dump_t* state = (TRI_aql_dump_t*) walker->_data;

  if (node == NULL) {
    return node;
  }

  assert(state);

  PrintType(state, node->_type);
  Indent(state);

  switch (node->_type) {
    case TRI_AQL_NODE_VALUE:
      DumpValue(state, node);
      break;

    case TRI_AQL_NODE_VARIABLE:
    case TRI_AQL_NODE_ATTRIBUTE:
    case TRI_AQL_NODE_REFERENCE:
    case TRI_AQL_NODE_PARAMETER:
    case TRI_AQL_NODE_ARRAY_ELEMENT:
    case TRI_AQL_NODE_ATTRIBUTE_ACCESS:
      DumpString(state, node);
      break;
    case TRI_AQL_NODE_FCALL:
      printf("name: %s\n", TRI_GetInternalNameFunctionAql((TRI_aql_function_t*) TRI_AQL_NODE_DATA(node)));
      break;

    case TRI_AQL_NODE_SORT_ELEMENT:
      PrintIndent(state);
      printf("asc/desc: %lu\n", (unsigned long) TRI_AQL_NODE_BOOL(node));
      break;

    default: {
      // nada
    }
  }

  Outdent(state);

  return node;
}
Exemplo n.º 25
0
int          clsDump::DumpScopeType(clsScopeType * pScopeType, int onlyCalculateSize)
{
  int          iSize = 0;
  unsigned int iIndex;

  iSize += DumpLine("----- SCOPE TYPE BEG -----\n", onlyCalculateSize);
  iSize += DumpLine("\tUID %u\n", pScopeType->m_UID, onlyCalculateSize);
  iSize += DumpLine("\tNumber of Friend Scopes %u\n", pScopeType->m_pFriendScopes.size(), onlyCalculateSize);
  for (iIndex = 0; iIndex < pScopeType->m_pFriendScopes.size(); ++iIndex)
  {
    iSize += DumpLine("\tFriend Scope UID %u\n", pScopeType->m_pFriendScopes[iIndex]->m_UID, onlyCalculateSize);
  }
  iSize += DumpString("\tScope Type Name\n", pScopeType->m_sName, onlyCalculateSize);
  iSize += DumpLine("\tScope Type Type = %u\n", pScopeType->m_Type, onlyCalculateSize);
  iSize += DumpLine("\tPrototype Scope UID %u\n", pScopeType->m_pPrototypeScope->m_UID, onlyCalculateSize);
  iSize += DumpLine("----- SCOPE TYPE END -----\n", onlyCalculateSize);

  return iSize;
}
Exemplo n.º 26
0
static void DumpConstants(const Proto* f, DumpState* D)
{
 int i,n=f->sizek;
 DumpInt(n,D);
 for (i=0; i<n; i++)
 {
  const TValue* o=&f->k[i];
  DumpChar(ttype(o),D);
  switch (ttype(o))
  {
   case LUA_TNIL:
	break;
   case LUA_TBOOLEAN:
	DumpChar(bvalue(o),D);
	break;
#ifdef LUA_TINT
   case LUA_TINT:
	DumpInteger(ivalue(o),D);
	break;
   case LUA_TNUMBER:
	DumpNumber(nvalue_fast(o),D);
	break;
#else
   case LUA_TNUMBER:
	DumpNumber(nvalue(o),D);
	break;
#endif
   case LUA_TSTRING:
	DumpString(rawtsvalue(o),D);
	break;
   default:
	lua_assert(0);			/* cannot happen */
	break;
  }
 }
 n=f->sizep;
 DumpInt(n,D);
 for (i=0; i<n; i++) DumpFunction(f->p[i],f->source,D);
}
Exemplo n.º 27
0
static void DumpConstants(const LuaProto* f, DumpState* D)
{
  int n = (int)f->constants.size();
  DumpInt(n,D);
  for(int i=0; i < n; i++)
  {
    LuaValue v = f->constants[i];
    DumpChar(v.type(),D);

    if(v.isBool()) {
      DumpChar(v.getBool() ? 1 : 0,D);
    } else if(v.isNumber()) {
      DumpNumber(v.getNumber(),D);
    } else if(v.isString()) {
      DumpString(v.getString(),D);
    }
  }
  n = (int)f->subprotos_.size();
  DumpInt(n,D);
  for (int i=0; i < n; i++) {
    DumpFunction(f->subprotos_[i],D);
  }
}
Exemplo n.º 28
0
static void DumpUpvalues(const Proto* f, DumpState* D)
{
 int i,n=f->sizeupvalues;
 DumpInt(n,D);
 for (i=0; i<n; i++) DumpString(f->upvalues[i],D);
}
Exemplo n.º 29
0
void ARCProbPlacer::Dump( std::ostream& os ) const
{
	std::for_each(m_vecItems.begin(), m_vecItems.end(), DumpString(os));
}
Exemplo n.º 30
0
// Check if normalized and display normalized output for a particular normalization form 
void TryNormalization(NORM_FORM form, LPWSTR strInput)
{
	// Test if the string is normalized 
	if (IsNormalizedString(form, strInput, -1))
	{
		wprintf(L"Already normalized in this form\n");
	}
	else
	{
		// It was not normalized, so normalize it 
		int    iSizeGuess;
		LPWSTR pBuffer;

		// How big is our buffer (quick guess, usually enough) 
		iSizeGuess = NormalizeString(form, strInput, -1, NULL, 0);

		if (iSizeGuess == 0)
		{
			wprintf(L"Error %d checking for size\n", GetLastError());
		}

		while (iSizeGuess > 0)
		{
			pBuffer = (LPWSTR)malloc(iSizeGuess * sizeof(WCHAR));
			if (pBuffer)
			{
				// Normalize the string 
				int iActualSize = NormalizeString(form, strInput, -1, pBuffer, iSizeGuess);
				iSizeGuess = 0;
				if (iActualSize <= 0 && GetLastError() != ERROR_SUCCESS)
				{
					// Error during normalization 
					wprintf(L"Error %d during normalization\n", GetLastError());
					if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
					{
						// If the buffer is too small, try again with a bigger buffer. 
						wprintf(L"Insufficient buffer, new suggested buffer size %d\n", -iActualSize);
						iSizeGuess = -iActualSize;
					}
					else if (GetLastError() == ERROR_NO_UNICODE_TRANSLATION)
					{
						wprintf(L"Invalid Unicode found at input character index %d\n", -iActualSize);
					}
				}
				else
				{
					// Display the normalized string 
					DumpString(pBuffer);
				}

				// Free the buffer 
				free(pBuffer);
			}
			else
			{
				wprintf(L"Error allocating buffer\n");
				iSizeGuess = 0;
			}
		}
	}
}