//-----------------------------------------------------------------------------
void SGScriptTranslator::translate(ScriptCompiler* compiler, const AbstractNodePtr &node)
{
	ObjectAbstractNode* obj = reinterpret_cast<ObjectAbstractNode*>(node.get());
	ObjectAbstractNode* parent = reinterpret_cast<ObjectAbstractNode*>(obj->parent);

	// Translate section within a pass context.
	if (parent->cls == "pass")
	{
		translatePass(compiler, node);
	}
}
//-----------------------------------------------------------------------------
void SGScriptTranslator::translate(ScriptCompiler* compiler, const AbstractNodePtr &node)
{
    ObjectAbstractNode* obj = static_cast<ObjectAbstractNode*>(node.get());
    ObjectAbstractNode* parent = static_cast<ObjectAbstractNode*>(obj->parent);

    // Translate section within a pass context.
    if (parent->cls == "pass")
    {
        translatePass(compiler, node);
    }
    if (parent->cls == "texture_unit")
    {
        translateTextureUnit(compiler, node);
    }
}
Ejemplo n.º 3
0
int
backTranslateWithTracing (const char *tableList, const widechar * inbuf,
			  int *inlen, widechar * outbuf,
			  int *outlen, formtype *typeform,
			  char *spacing, int *outputPos,
			  int *inputPos, int *cursorPos, int modex,
			  const TranslationTableRule **rules, int *rulesLen)
{
  int k;
  int goodTrans = 1;
  if (tableList == NULL || inbuf == NULL || inlen == NULL || outbuf ==
      NULL || outlen == NULL)
    return 0;
  if ((modex & otherTrans))
    return other_backTranslate (tableList, inbuf,
				inlen, outbuf, outlen,
				typeform, spacing, outputPos, inputPos,
				cursorPos, modex);
  table = getTable (tableList);
  if (table == NULL)
    return 0;
  srcmax = 0;
  while (srcmax < *inlen && inbuf[srcmax])
    srcmax++;
  destmax = *outlen;
  typebuf = (unsigned char *) typeform;
  spacebuf = spacing;
  outputPositions = outputPos;
  if (outputPos != NULL)
    for (k = 0; k < srcmax; k++)
      outputPos[k] = -1;
  inputPositions = inputPos;
  if (cursorPos != NULL)
    cursorPosition = *cursorPos;
  else
    cursorPosition = -1;
  cursorStatus = 0;
  mode = modex;
  if (!(passbuf1 = liblouis_allocMem (alloc_passbuf1, srcmax, destmax)))
    return 0;
  if (typebuf != NULL)
    memset (typebuf, '0', destmax);
  if (spacebuf != NULL)
    memset (spacebuf, '*', destmax);
  for (k = 0; k < srcmax; k++)
    if ((mode & dotsIO))
      passbuf1[k] = inbuf[k] | 0x8000;
    else
      passbuf1[k] = getDotsForChar (inbuf[k]);
  passbuf1[srcmax] = getDotsForChar (' ');
  if (!(srcMapping = liblouis_allocMem (alloc_srcMapping, srcmax, destmax)))
    return 0;
  for (k = 0; k <= srcmax; k++)
    srcMapping[k] = k;
  srcMapping[srcmax] = srcmax;
  currentInput = passbuf1;
  if ((!(mode & pass1Only)) && (table->numPasses > 1 || table->corrections))
    {
      if (!(passbuf2 = liblouis_allocMem (alloc_passbuf2, srcmax, destmax)))
	return 0;
    }
  appliedRulesCount = 0;
  if (rules != NULL && rulesLen != NULL)
    {
      appliedRules = rules;
      maxAppliedRules = *rulesLen;
    }
  else
    {
      appliedRules = NULL;
      maxAppliedRules = 0;
    }
  currentPass = table->numPasses;
  if ((mode & pass1Only))
    {
      currentOutput = outbuf;
      goodTrans = backTranslateString ();
    }
  else
    switch (table->numPasses + (table->corrections << 3))
      {
      case 1:
	currentOutput = outbuf;
	goodTrans = backTranslateString ();
	break;
      case 2:
	currentOutput = passbuf2;
	goodTrans = translatePass ();
	if (!goodTrans)
	  break;
	currentPass--;
	srcmax = dest;
	currentInput = passbuf2;
	currentOutput = outbuf;
	goodTrans = backTranslateString ();
	break;
      case 3:
	currentOutput = passbuf2;
	goodTrans = translatePass ();
	if (!goodTrans)
	  break;
	currentPass--;
	srcmax = dest;
	currentInput = passbuf2;
	currentOutput = passbuf1;
	goodTrans = translatePass ();
	if (!goodTrans)
	  break;
	currentInput = passbuf1;
	currentOutput = outbuf;
	currentPass--;
	srcmax = src;
	goodTrans = backTranslateString ();
	break;
      case 4:
	currentOutput = passbuf2;
	goodTrans = translatePass ();
	if (!goodTrans)
	  break;
	currentPass--;
	srcmax = dest;
	currentInput = passbuf2;
	currentOutput = passbuf1;
	goodTrans = translatePass ();
	if (!goodTrans)
	  break;
	currentInput = passbuf1;
	currentOutput = passbuf2;
	srcmax = dest;
	currentPass--;
	goodTrans = translatePass ();
	if (!goodTrans)
	  break;
	currentInput = passbuf2;
	currentOutput = outbuf;
	currentPass--;
	srcmax = dest;
	goodTrans = backTranslateString ();
	break;
      case 9:
	currentOutput = passbuf2;
	goodTrans = backTranslateString ();
	if (!goodTrans)
	  break;
	currentInput = passbuf2;
	currentOutput = outbuf;
	currentPass--;
	srcmax = dest;
	goodTrans = makeCorrections ();
	break;
      case 10:
	currentOutput = passbuf2;
	goodTrans = translatePass ();
	if (!goodTrans)
	  break;
	currentPass--;
	srcmax = dest;
	currentInput = passbuf2;
	currentOutput = passbuf1;
	goodTrans = backTranslateString ();
	if (!goodTrans)
	  break;
	currentInput = passbuf1;
	currentOutput = outbuf;
	currentPass--;
	srcmax = dest;
	goodTrans = makeCorrections ();
	break;
      case 11:
	currentOutput = passbuf2;
	goodTrans = translatePass ();
	if (!goodTrans)
	  break;
	currentPass--;
	srcmax = dest;
	currentInput = passbuf2;
	currentOutput = passbuf1;
	goodTrans = translatePass ();
	if (!goodTrans)
	  break;
	currentInput = passbuf1;
	currentOutput = passbuf2;
	currentPass--;
	srcmax = dest;
	goodTrans = backTranslateString ();
	if (!goodTrans)
	  break;
	currentInput = passbuf2;
	currentOutput = outbuf;
	currentPass--;
	srcmax = dest;
	goodTrans = makeCorrections ();
	break;
      case 12:
	currentOutput = passbuf2;
	goodTrans = translatePass ();
	if (!goodTrans)
	  break;
	currentPass--;
	srcmax = dest;
	currentInput = passbuf2;
	currentOutput = passbuf1;
	goodTrans = translatePass ();
	if (!goodTrans)
	  break;
	currentInput = passbuf1;
	currentOutput = passbuf2;
	srcmax = dest;
	currentPass--;
	goodTrans = translatePass ();
	if (!goodTrans)
	  break;
	currentInput = passbuf2;
	currentOutput = passbuf1;
	currentPass--;
	srcmax = dest;
	goodTrans = backTranslateString ();
	if (!goodTrans)
	  break;
	currentInput = passbuf1;
	currentOutput = outbuf;
	currentPass--;
	srcmax = dest;
	goodTrans = makeCorrections ();
	break;
      default:
	break;
      }
  if (src < *inlen)
    *inlen = srcMapping[src];
  *outlen = dest;
  if (outputPos != NULL)
    {
      int lastpos = 0;
      for (k = 0; k < *inlen; k++)
	if (outputPos[k] == -1)
	  outputPos[k] = lastpos;
	else
	  lastpos = outputPos[k];
    }
  if (cursorPos != NULL)
    *cursorPos = cursorPosition;
  if (rulesLen != NULL)
    *rulesLen = appliedRulesCount;
  return goodTrans;
}