Esempio n. 1
0
// utility function to print initial state of 
// a chat session
void PrintToDate(IChatSession *pcs)
{
    IEnumString *pes = 0;
    HRESULT hr = pcs->GetStatements(&pes);
    if (SUCCEEDED(hr))
    {
        PrintAllStrings(pes);
        pes->Release();
    }
}
Esempio n. 2
0
short ResolveReferences(void)
{
   Stack Ref;
   Instruction I,j;
   int Labelref;

   Ref = AllocateStack (200);

   for (I = 1; I <= SizeOf (Labels); I++) 
   {
      if (LabelOf(I) != UndefinedString)
         if (Element(Ref,LabelOf(I)) == UndefinedString)
            Assign(Ref,LabelOf(I),I);
         else 
         {
            fprintf(output,"<<< MACHINE ERROR >>>: ");
            fprintf(output,"DUPLICATE INSTRUCTION WITH LABEL ");
    	    fprintf(output," %d **",LabelOf(I));
    	    WriteString(output,LabelOf(I));
            fprintf(output,"**: LINE %1d \n",I);
            return(false);
         }
   }

   for (I = 1; I <= SizeOf(Labels); I++) 
   {
      if (OpCodeOf(I) == GOTOOP || OpCodeOf(I) == CONDOP ||
                                   OpCodeOf(I) == CODEOP) 
      {
         Labelref = Element(Ref,Operand1Of(I));
         if (Labelref == 0) 
         {
            fprintf(output,"<<< MACHINE ERROR >>>: ");
            fprintf(output,"NO INSTRUCTION WITH LABEL ");
    	    fprintf(TraceFile," %d ",Operand1Of(I));
            fprintf(output,"': LINE %1d \n",I);
            return(false);
         }
         
         Assign ( Ref, Operand1Of(I), 1000000+Labelref );
         Assign ( Operand1, I, Labelref % 1000000);
      }

      if (OpCodeOf(I) == CONDOP) 
      {
         Labelref = Element(Ref,Operand2Of(I));
         if (Labelref == 0) 
         {
            fprintf(output,"<<< MACHINE ERROR >>>: ");
            fprintf(output,"NO INSTRUCTION WITH LABEL ");
    	    fprintf(output," %d ",Operand2Of(I));
            fprintf(output,"': LINE %1d \n",I);
            return(false);
         }
         Assign (Ref, Operand2Of(I), 1000000+Labelref );
         Assign (Operand2, I, Labelref % 1000000);
      }

      if (OpCodeOf(I) == LITOP || OpCodeOf(I) ==  LLVOP
            || OpCodeOf(I) ==  LGVOP  || OpCodeOf(I) == SLVOP
            || OpCodeOf(I) ==  SGVOP  || OpCodeOf(I) == LLIVOP
            || OpCodeOf(I) ==  LGIVOP || OpCodeOf(I) == SLIVOP
            || OpCodeOf(I) ==  SGIVOP || OpCodeOf(I) == LLAOP
            || OpCodeOf(I) ==  LGAOP  || OpCodeOf(I) == LUVOP
            || OpCodeOf(I) ==  SUVOP  || OpCodeOf(I) == POPOP
            || OpCodeOf(I) ==  CALLOP || OpCodeOf(I) == RTNOP)
          Assign (Operand1,I,StringToInteger(Operand1Of(I)));

       if (OpCodeOf(I) == LUVOP || OpCodeOf(I) == SUVOP )
          Assign(Operand2,I,StringToInteger(Operand2Of(I)));
   }

   for (I =1; I <= TextSize(); I++ ) 
   {
      if (Element(Ref,I) != 0)
         if (Element(Ref,I) < 1000000) 
         {
            fprintf(output,"<<< MACHINE ERROR >>>: ");
            fprintf(output,"NO REFERENCE TO INSTRUCTION WITH LABEL ");
	    fprintf(output,"%d ", I);
            fprintf(output,": LINE %1d \n",I);
            fprintf(output,"Element(Ref)= %d\n",Element(Ref,I));
            PrintAllStrings(stdout);
            return(false);
	 }
   }

   return(true);
}