Ejemplo n.º 1
0
int CppDecodeLabel(OpcodeInfo *theOp, char *str)
{

	SYMBOL *ref, *labref;
	int addr;

	ref = (SYMBOL *) ArrayGet(&CallArray, theOp->rip);

	// !! Check if what it points to in lablearry and use that !!

	if (!ref)
		return 0;

	addr = ref->Value;

	labref = (SYMBOL *) ArrayGet(&CodeLabelArray, addr);

	if (!labref)
		return 0;

	ref = labref;

	RebuildEmit(str, ref->LabelEnum);
	return 1;
}
Ejemplo n.º 2
0
AsmCode* AsmCodeNew(char *line) {
  AsmCode* code = ObjNew(AsmCode,1);
	char head[MAX_LEN];
	strCut(line, "/", head, NULL);
	Array* tokens = split(head, " \t+[],", REMOVE_SPLITER);
	if (tokens->count == 0) { 
       ArrayFree(tokens, strFree);
       ObjFree(code);
       return NULL; 
    }
	code->line = strNew(head);
  strTrim(code->line, code->line, SPACE);
  code->tokens = tokens;
  int tokenIdx = 0;
  if (strTail(tokens->item[0], ":")) {
      code->label = ArrayGet(tokens, tokenIdx++);
      strTrim(code->label, code->label, ":");
  } else
      code->label = NULL;
  code->op = ArrayGet(tokens, tokenIdx++);
  code->opCode = OP_NULL;
  code->argStart = tokenIdx;
  code->arg[0] = ArrayGet(tokens, tokenIdx++);
  code->arg[1] = ArrayGet(tokens, tokenIdx++);
  code->arg[2] = ArrayGet(tokens, tokenIdx++);
//	AsmCodePrintln(code);
  return code;
}
void TestFunction()
{
	char puzzle_board_data[] =
	{
		't', 'h', 'i', 's',
		'w', 'a', 't', 's',
		'o', 'a', 'h', 'g',
		'f', 'g', 'd', 't'
	};
	char* dictionary[] =
	{
		"this", "two", "fat", "that"
	};

	Array words, ret;
	int i;
	size_t index, count;
	PuzzleBoard puzzle_board = { puzzle_board_data, 4, 4 };

	ArrayInit(&words, 4, sizeof(char*));
	for (i = 0; i < 4; ++i)
	{
		ArrayPush(&words, &dictionary[i]);
	}

	// solution1
	ret = solution1_Function(&puzzle_board, &words);
	count = ArrayUsed(&ret);
	MLOG("solution 1:\n");
	for (index = 0; index < count; ++index)
	{
		RetWord* word = (RetWord*)ArrayGet(&ret, index);
		MLOG("%s (%d, %d) - (%d, %d)\n", word->word, word->start_x, word->start_y, word->end_x, word->end_y);
	}
	ArrayDestroy(&ret);

	// solution2
	ret = solution2_Function(&puzzle_board, &words);
	count = ArrayUsed(&ret);
	MLOG("solution 2:\n");
	for (index = 0; index < count; ++index)
	{
		RetWord* word = (RetWord*)ArrayGet(&ret, index);
		MLOG("%s (%d, %d) - (%d, %d)\n", word->word, word->start_x, word->start_y, word->end_x, word->end_y);
	}
	ArrayDestroy(&ret);

	ArrayDestroy(&words);
}
Ejemplo n.º 4
0
void Dump_MasterIP_Trans(FILE *out)
{
    char	*tptr;
    char	*ptr;
    uint	ip,line;

    tptr = FileTop;
    line = 0;

    fprintf(out, "\nLINEIP\n");

    if (!AsmCharArray.array)
        return;

    for (ip=AsmCharArray.lo; ip<AsmCharArray.hi+1; ip++)
    {
        // n = ip

        ptr = (char *) ArrayGet(&AsmCharArray, ip);

        if (ptr)
        {
            if (tptr != ptr)
                line = GetLineNumber(FileTop, ptr);

            fprintf(out, "%d:%x\n", line, ip);
            tptr = ptr;
        }
    }

    return;
}
Ejemplo n.º 5
0
void FunctionReg_Calli(OpcodeInfo *thisOp, FuncProp *fp)
{
	SYMBOL *CallSym;
	
	CallSym = (SYMBOL *) ArrayGet(&CallArray, thisOp->rip);

	if (CallSym)
	{
		int params = CallSym->Params;
		int p;

		for (p=0;p<params;p++)
		{
			// check if this reg was assigned previously, if it was'nt it is uninitialized before use
	
			int is_assigned = fp->assign_reg & REGBIT(REG_i0 + p);
	
			if (!is_assigned)
				fp->uninit_reg |= REGBIT(REG_i0 + p);
	
			fp->src_reg |= REGBIT(REG_i0 + p);
		}

		// Check what the function returns
		// Do nothing for void
		
		if (CallSym->RetType == RET_int   ||
			CallSym->RetType == RET_float)
			fp->dst_reg |= REGBIT(REG_r14);

		if (CallSym->RetType == RET_double)
			fp->dst_reg |= REGBIT(REG_r14) | REGBIT(REG_r15);
	}
}
Ejemplo n.º 6
0
void Rebuild_Code()
{
	SYMBOL *sym;
	int n;
	int c = 0;

	for (n=0;n<CodeIP+1;n++)
	{
		sym = (SYMBOL *) ArrayGet(&CodeLabelArray, n);

		if (sym)
		{
			if ((sym->Flags & SymFlag_Ref) || ArgSkipElim)
			{
				if (sym->LabelType >= label_Function)
				{
					//TestAnalyse(sym);
					RebuildFunc(sym);
					c++;
				}
			}
		}
	}

	CRPRINT("Processed %d functions\n", c);
}
Ejemplo n.º 7
0
int Rebuild_CanMoveToBss(int ip, int len)
{
	SYMBOL *thisSym;
	int n;

	if (ArgSkipElim)
		return 0;

	for (n=ip;n<ip+len;n++)
	{
		// if a symbol exists in this data, don't optimize
		
		thisSym = (SYMBOL *) ArrayGet(&DataArray, n);

		if (thisSym)
			return 0;

		// If the data contains non-zero's, don't optimize

		if (GetDataMem(n))
			return 0;
	}

	return 1;
}
Ejemplo n.º 8
0
void Dump_MasterIP_Trans(FILE *out)
{
    char	c;
    uint	offset, line, ip;

    fprintf(out, "\nLINEIP\n");

    offset = 0;
    line = 1;

    if (!AsmCharArray.array)
        return;

    while(1)
    {
        c = FileTop[offset];

        if (c == 0x00)
            break;

        if (c == 0x0d)
            line++;

        ip = ArrayGet(&AsmCharIPArray, offset);

        if (ip)
            fprintf(out, "%d:%x\n", line, ip-1);

        offset++;
    }

    return;
}
Ejemplo n.º 9
0
void ArrayRemoveAtIndex(Array *arr,int index) {
    assert(index >= 0 && index < arr->length_);//断言
    OBJECT_RELEASE(ArrayGet(arr, index));
    
    arr->length_ --;
    for (int i = index; i < arr->length_; i++) {
        arr->values_[i] = arr->values_[i+1];
    }
}
Ejemplo n.º 10
0
void AsmPass2(Assembler *a) {                         // 組譯器的第二階段
  printf("=============PASS2==============\n");                       
  int i;                                                              
  for (i=0; i<a->codes->count; i++) {                 // 對每一個指令    
    AsmCode *code = ArrayGet(a->codes, i);                                
    AsmTranslateCode(a, code);                        //   進行編碼動作  
    AsmCodePrintln(code);
  }
}
Ejemplo n.º 11
0
int CppDecodeCase(int ip)
{
	SYMBOL *ref;

	ref = (SYMBOL *) ArrayGet(&CodeLabelArray, ip);

	if (!ref)
		return 0;

	RebuildEmit("goto label_%d;", ref->LabelEnum);
	return 1;
}
Ejemplo n.º 12
0
void RebuildEmitStabs(int ip)
{
	int line  = ArrayGet(&SLD_Line_Array, ip);
	int file = ArrayGet(&SLD_File_Array, ip);
	char *FileStr;
	
	if (line == 0)
		return;

	if (file != lastfileno)
	{
		lastfileno = file;

		FileStr = GetFileNumString(file);

		if (FileStr)
			RebuildEmit(".sourcefile '%s'\n", FileStr);
	}

	RebuildEmit(".line %d\n", line);
}
Ejemplo n.º 13
0
void InitFiles() {
	size_t n;

	for(n = 0; n < 1024; n++) {
		fileInfo[n].numLines = -1;
		fileInfo[n].fileData = NULL;
	}

	for (n=SLD_File_Array.lo;n<SLD_File_Array.hi+1;n++) {
		int file = ArrayGet(&SLD_File_Array, n);
		FILE *f;
		const char *fileName;
		if(fileInfo[file].numLines!=-1) continue;
		fileName = GetFileNumString(file);
		f = fopen(fileName, "rb");
		if(f)
		{
			size_t i, dataSize, line, res;
			fseek(f, 0, SEEK_END);
			dataSize = ftell(f);

			fileInfo[file].fileData = (char*) malloc(dataSize+1);

			fileInfo[file].fileData[dataSize] = 0;
			fseek(f, 0, SEEK_SET);
			res = fread(fileInfo[file].fileData, 1, dataSize, f);
			if(res != dataSize) {
				printf("Error reading file '%s'\n", fileName);
				exit(1);
			}
			line = 0;
			for(i = 0; i < dataSize; i++) {
				if(fileInfo[file].fileData[i] == '\n') line++;
			}
			fileInfo[file].numLines = line;

			fileInfo[file].lines = (char**) malloc(sizeof(char*)*(line+1));

			line = 0;
			fileInfo[file].lines[0] = fileInfo[file].fileData;
			for(i = 0; i < dataSize; i++) {
				if(fileInfo[file].fileData[i] == '\n') {
					line++;
					fileInfo[file].fileData[i] = 0;
					fileInfo[file].lines[line] = &fileInfo[file].fileData[i+1];
				}
			}

			fclose(f);
		}
	}
}
Ejemplo n.º 14
0
int CppDecodeCall(OpcodeInfo *theOp)
{
	SYMBOL *ref, *labref;
	int addr;

	ref = (SYMBOL *) ArrayGet(&CallArray, theOp->rip);

	// !! Check if what it points to in lablearry and use that !!

	if (!ref)
		return 0;

	addr = ref->Value;

	labref = (SYMBOL *) ArrayGet(&CodeLabelArray, addr);

	if (!labref)
		return 0;

	ref = labref;

	return CppCallFunction(ref, 1);
}
Ejemplo n.º 15
0
int ArraySearch(ArrayStore *theArray, uint value)
{
	uint n;
	
	if (!theArray->array)
		return 0;

// !! Fix ARH 21/09/10 - theArray->lo is incorrect should be 0 !!

	for (n=0;n<theArray->hi+1;n++)
	{
		if (value == ArrayGet(theArray, n))
			return n;
	}

	return -1;	
}
Ejemplo n.º 16
0
void Rebuild_Memory()
{
	SYMBOL *sym;
	int n;

	for (n=0;n<MaxDataIP + BssIP;n++)
	{
		sym = (SYMBOL *) ArrayGet(&LabelArray, n);

		if (sym)
		{
			if ((sym->Flags & SymFlag_Ref) || ArgSkipElim)
			{
				//printf("%d: Found '%s' size %d\n", n, sym->Name, sym->EndIP);

				Rebuild_Data(sym);
			}
		}
	}
}
Ejemplo n.º 17
0
void RebuildCpp_Code()
{
	SYMBOL *sym;
	int n;
	int c = 0;

	for (n=0;n<CodeIP+1;n++)
	{
		sym = (SYMBOL *) ArrayGet(&CodeLabelArray, n);

		if (sym)
		{
			if (sym->Flags & SymFlag_Ref)
			if (sym->LabelType >= label_Function)
			{
				RebuildCppFunc(sym, 0);
				c++;
			}
		}
	}
}
Ejemplo n.º 18
0
void RebuildCpp_EmitProtos()
{
	SYMBOL *sym;
	int n;

	RebuildEmit("\n// Prototypes\n\n");

	RebuildEmit("static int CallReg(int s, int i0, int i1, int i2, int i3);\n");

	for (n=0;n<CodeIP+1;n++)
	{
		sym = (SYMBOL *) ArrayGet(&CodeLabelArray, n);

		if (sym)
		{
			if (sym->Flags & SymFlag_Ref)
			if (sym->LabelType >= label_Function)
			{
				RebuildCppFunc(sym, 1);
			}
		}
	}
}
Ejemplo n.º 19
0
static const Tiny_Value* ReadVar(const char* filename, int* line, FILE* f, Dict* env, Array* arr, int arrIndex, int c, char* var)
{
    const Tiny_Value* val = NULL;

    if(c == '_') {
        if(!arr) {
            ERROR("Attempted to use '$_' outside of array expansion.\n");
        }

        assert(arrIndex >= 0 && arrIndex < arr->length);
    
        var[0] = '_';
        var[1] = 0;

        val = ArrayGet(arr, arrIndex);
    } else {
        int i = 0;

        while(isalpha(c)) {
            if(i >= VAR_SIZE - 1) {
                ERROR("Var name is too long.\n");
            }

            var[i++] = c;
            c = getc(f);
        }
		ungetc(c, f);

        var[i] = 0;
        
        val = DictGet(env, var);
    }

    return val;
error:
    return NULL;
}
Ejemplo n.º 20
0
void ArrayCopy(ArrayStore *dstArray, ArrayStore *srcArray)
{
	uint n;

	if (dstArray->array == srcArray->array)
		return;

	if (!dstArray->array)
		return;

	if (!srcArray->array)
		return;

// !! Fix ARH 21/09/10 - srcArray->lo is incorrect should be 0 !!

	for (n=0;n<srcArray->hi+1;n++)

	{
		ArraySet(dstArray, n, ArrayGet(srcArray, n));
	}

	dstArray->ps = srcArray->ps;
	return;
}
Ejemplo n.º 21
0
void TestPerformance()
{
	// puzzle board
	char puzzle_board_data[] =
	{
		't', 'h', 'i', 's',
		'w', 'a', 't', 's',
		'o', 'a', 'h', 'g',
		'f', 'g', 'd', 't'
	};
	PuzzleBoard puzzle_board = { puzzle_board_data, 4, 4 };

	// dictionary
	char* buf;
	long num;
	if (!File_Read("res/wordsEn/wordsEn.txt", &buf, &num))
	{
		MASSERT_MSG(0, "File (res/wordsEn/wordsEn.txt) not exist!\n");
		MLOG("File (res/wordsEn/wordsEn.txt) not exist!\n");
		return;
	}

	if (num == 0)
	{
		MLOG("dictionary is empty\n");
		return;
	}

	Array dictionary;
	ArrayInit(&dictionary, 8, sizeof(char*));

	char* p = buf;
	char* q = p;
	while (p)
	{
		if (*p == '\r' || *p == '\n')
		{
			*p = '\0';
			if (q != p)
			{
				ArrayPush(&dictionary, &q);
			}
			++p;
			q = p;
			continue;
		}

		if (*p == '\0')
		{
			if (q != p)
			{
				ArrayPush(&dictionary, &q);
			}
			break;
		}

		++p;
	}

	// performance test
	PerformanceTest test;
	size_t piece_size = dictionary.used / 128;
	for (int i = 1; i <= 32; ++i)
	{
		size_t num = i * piece_size;
		size_t count;
		Array ret;

		Array cur_dictionary;
		ArrayInit(&cur_dictionary, 8, sizeof(char*));
		for (size_t j = 0; j < num; ++j)
		{
			ArrayPush(&cur_dictionary, ArrayGet(&dictionary, j));
		}

		// solution 1
		PERFORMANCE_TEST_ADD(test, "puzzle - solution 1", (int)num, ret = solution1_Function(&puzzle_board, &cur_dictionary));
		count = ArrayUsed(&ret);
		MLOG("solution 1:\n");
		for (size_t index = 0; index < count; ++index)
		{
			RetWord* word = (RetWord*)ArrayGet(&ret, index);
			MLOG("%s (%d, %d) - (%d, %d)\n", word->word, word->start_x, word->start_y, word->end_x, word->end_y);
		}
		ArrayDestroy(&ret);

		// solution 2
		PERFORMANCE_TEST_ADD(test, "puzzle - solution 2", (int)num, ret = solution2_Function(&puzzle_board, &cur_dictionary));
		count = ArrayUsed(&ret);
		MLOG("solution 1:\n");
		for (size_t index = 0; index < count; ++index)
		{
			RetWord* word = (RetWord*)ArrayGet(&ret, index);
			MLOG("%s (%d, %d) - (%d, %d)\n", word->word, word->start_x, word->start_y, word->end_x, word->end_y);
		}
		ArrayDestroy(&ret);

		ArrayDestroy(&cur_dictionary);
	}
	test.WriteCompareToFile("puzzle.txt");

	// destroy
	ArrayDestroy(&dictionary);
	free(buf);
}
Ejemplo n.º 22
0
void Rebuild_Data(SYMBOL *sym)
{
	SYMBOL *thisSym;

	//uint ta = 0;
	
	int ip;
	int len;
	int n;
	int c;
	int left;
	int align;
	int opt_bss;

	// decode the field
	
	ip = sym->Value;

	if (sym->Type == SECT_bss)
		ip += MaxDataIP;

	len = sym->EndIP;
	left = len;

	// Has this been done already

	if (ArrayGet(&LabelDone, ip))
		return;

	// Mark as done

	ArraySet(&LabelDone, ip, 1);
	
	if (!len)
	{
		len = FindLabelExtent(ip);


		if (!len)
		{
			RebuildEmit("// empty %s_%d,%d\n", sym->Name, sym->LocalScope, len);
			return;
		}

		// Save the result for later

		sym->EndIP = len;

		RebuildEmit("// found extent %s_%d,%d\n", sym->Name, sym->LocalScope, len);
	}

	align = ArrayGet(&DataAlignArray, ip);
	
	if (sym->Type == SECT_bss)
	{
		RebuildEmit("\t.comm %s_%d,%d\n", sym->Name, sym->LocalScope, len);
		return;
	}
	
	if (sym->Type != SECT_data)
		Error(Error_System, "(Rebuild_Data) Illegal section in data output");

	// Check if this data field can be moved to bss

#if 1
	opt_bss  = Rebuild_CanMoveToBss(ip, len);

	if (opt_bss)
	{
		// Make sure bss output is aligned
		int bss_len = len;
		
		while(bss_len & 3)
			bss_len++;
		
		RebuildEmit("\t.comm %s_%d,%d	//moved to bss\n", sym->Name, sym->LocalScope, bss_len);
		return;
	}
#endif

	if (align)
		RebuildEmit("\t.align %d\n", align);

	// write a data section field

	RebuildEmit("%s_%d:\n", sym->Name, sym->LocalScope );

	// write array

	c = 0;

	for (n=ip;n<ip+len;n++)
	{
		thisSym = (SYMBOL *) ArrayGet(&DataArray, n);

		if (!thisSym)
		{
			RebuildEmit("\t.byte 0x%s\n", Hex8(GetDataMem(n)) );
			left--;
			continue;
		}

		// check if we hit a .word reference

		if (left >= 4)
		{
			if (thisSym)
			{
				SYMBOL *labref = NULL;
				int addr;

				addr = thisSym->Value;
	
				if (thisSym->Type == SECT_code)
				{
					labref = (SYMBOL *) ArrayGet(&CodeLabelArray, addr);

					if (labref == 0)
						Error(Error_System, "Could not repoint label !!");
//						labref = thisSym;
				}

				if (thisSym->Type == SECT_data)
				{
					labref = (SYMBOL *) ArrayGet(&LabelArray, addr);

					if (labref == 0)
						Error(Error_System, "Could not repoint label !!");
				}

				if (thisSym->Type == SECT_bss)
				{
					labref = (SYMBOL *) ArrayGet(&LabelArray, addr + MaxDataIP);

					if (labref == 0)
						Error(Error_System, "Could not repoint label !!");
				}
	
				if(labref == NULL)
					Error(Error_System, "Broken label");

				RebuildEmit("\t.word %s_%d\n", labref->Name, labref->LocalScope);
	
				left-=4;
				n+=3;

			}
		}
	}

	RebuildEmit("\n\n");
	return;
}
Ejemplo n.º 23
0
PetscErrorCode FiberField_AddToSendbufs( FiberField field )
{
  int i;
  int e;
  const int vlen = ArrayLength(field->verts);
  const int elen = ArrayLength(field->edges);
  const BoundingBox lbbox = field->localBounds;
  int neiIdx;
  VertexEdgeMPI *evmpi;
  iCoor n; // index in 3x3x3 array nei
  Vertex v;
  PetscMPIInt sendRank;
  const PetscMPIInt *neiRanks;
  PetscErrorCode ierr;

  PetscFunctionBegin;

  ierr = DMDAGetNeighbors(field->da, &neiRanks); CHKERRQ(ierr);
  
  // clear send arrays
  // for each vert
  //   if outside nei, err
  //   else add vert to send list

  for (i = 0; i < NUMNEI; i++) {
    ArraySetSize( field->sendbufs[i], 0);
  }
   
  for (i = 0; i < vlen; i++) {
    ierr = ArrayGet( field->verts, i, &v ); CHKERRQ(ierr);

    PositionToNeiIdx( &lbbox, &v->X, &n, &neiIdx);

    // if vertex outside 3x3x3 nei, something went terribly wrong
    if (n.x < 0 || n.x > 2 ||
        n.y < 0 || n.y > 2 ||
        n.z < 0 || n.z > 2 ) {
      ierr = PetscInfo(0, "ERROR: Vertex outside 3x3x3 neighbor region\n"); CHKERRQ(ierr);
      ierr = PetscInfo1(0, "i = %d\n",i); CHKERRQ(ierr);
      ierr = PetscInfo3(0, "X = {%f, %f, %f}\n",v->X.x,v->X.y,v->X.z); CHKERRQ(ierr);
      ierr = PetscInfo3(0, "n = {%d, %d, %d}\n",n.x,n.y,n.z); CHKERRQ(ierr);
      ierr = PetscInfo(0, "ERROR: END MESSAGE\n"); CHKERRQ(ierr);
      SETERRQ(field->comm, 0, "Vertex outside 3x3x3 neighbor region");
    } else { 
      // convert nei index to mpi rank
      sendRank = neiRanks[neiIdx];
      // in the edge case where a vertex leaves the global bounding box, abort
      // handle this case in the physics, not in the communication routine
      if ( sendRank == MPI_PROC_NULL) {
        ierr = PetscInfo(0, "ERROR: Vertex outside global bbox\n"); CHKERRQ(ierr);
        ierr = PetscInfo1(0, "i = %d\n",i); CHKERRQ(ierr);
        ierr = PetscInfo3(0, "X = {%f, %f, %f}\n",v->X.x,v->X.y,v->X.z); CHKERRQ(ierr);
        ierr = PetscInfo3(0, "n = {%d, %d, %d}\n",n.x,n.y,n.z); CHKERRQ(ierr);
        ierr = PetscInfo1(0, "neiIdx = %d\n",neiIdx); CHKERRQ(ierr);
        ierr = PetscInfo(0, "ERROR: END MESSAGE\n"); CHKERRQ(ierr);
        SETERRQ(field->comm, 0, "Vertex outside global bbox\n");
      }

      // add vertex to send list[rank]
      ierr = ArrayAppend( field->sendbufs[neiIdx], &evmpi); CHKERRQ(ierr); 
      evmpi->xID = v->vID;
      evmpi->type= v->type;
      evmpi->X = v->X;
      evmpi->V = v->V;
      for (e = 0; e < MAXEDGES; e++) {
        evmpi->yIDs[e] = v->eID[e];
      }
    }
  }

  int min;
  int vPO;
  struct _Edge *edges = ArrayGetData(field->edges);
  struct _Vertex *vertsPO;
  ierr = FiberFieldGetVertexArrayPO( field, &vertsPO ); CHKERRQ(ierr);
  for (e = 0; e < elen; e++) {
    // the edge is 'owned' by the vertex with the smallest ID
    min = edges[e].vID[0] < edges[e].vID[1] ? 0 : 1;
    vPO = edges[e].vPO[min]; 

    v = &vertsPO[vPO];

    PositionToNeiIdx( &lbbox, &v->X, &n, &neiIdx);

    if (v->vID != edges[e].vID[min] ) {
      ierr = PetscInfo1(0, "v->vID = %d\n", v->vID); CHKERRQ(ierr);
      ierr = PetscInfo1(0, "edges[e].vID[min] = %d\n", edges[e].vID[min]); CHKERRQ(ierr);
      SETERRQ(PETSC_COMM_SELF, 0, "Bad vertex");
    }

    ierr = ArrayAppend( field->sendbufs[neiIdx], &evmpi); CHKERRQ(ierr); 
    evmpi->xID = edges[e].eID; 
    evmpi->type = edges[e].type; 
    evmpi->yIDs[0] = edges[e].vID[0]; 
    evmpi->yIDs[1] = edges[e].vID[1]; 
    evmpi->X.x = edges[e].l0;
  }

  PetscFunctionReturn(0);
}
Ejemplo n.º 24
0
void RebuildCppFunc(SYMBOL *sym, int isproto)
{
	OpcodeInfo thisOp;
	SYMBOL *ref;

	uchar *ip, *ip_end, *ip_last;

	int real_ip;
//	char str[256];

	if (!sym)
		return;

	// Say no returns yet

	ReturnCount = 0;

	// Enumerate this functions labels, unless we're generating a proto

	if (isproto	== 0)
		EnumerateFunctionLabels(sym);

	ThisFunctionRegs = FunctionRegUsage(sym);
	ThisFunctionRetType = sym->RetType;

	if (ThisFunctionRegs == -1)
		return;

	RebuildCppProlog(sym, isproto);

	// if we're generating a proto return

	if (isproto)
		return;

	ip_end = (uchar *) ArrayPtr(&CodeMemArray, sym->EndIP);
	ip = (uchar *) ArrayPtr(&CodeMemArray, sym->Value);
	real_ip	= sym->Value;

	while(1)
	{
		ip_last = ip;

		if (ip > ip_end)
			break;

		// Print labels

		ref = (SYMBOL *) ArrayGet(&CodeLabelArray, real_ip);

		if (ref)
		{
			if (ref->LabelType == label_Local)
			{
#ifdef Cpp_DEBUG
				RebuildEmit("// %s_%d:\n", ref->Name, ref->LocalScope);
#endif
				RebuildEmit("label_%d:;\n", ref->LabelEnum);
			}
		}

		if (ArrayGet(&CodeTouchArray, real_ip) == 0)
			RebuildEmit("// ");

		CaseRef = 0;

		ip = DecodeOpcode(&thisOp, ip);

		ThisFunctionExit = 0;

		if (ip > ip_end)
			ThisFunctionExit = 1;

		RebuildCppInst(&thisOp);

//		DecodeAsmString(&thisOp, str);
//		RebuildEmit("\t%s", str);

#ifdef CPP_DEBUG
		{
			int len = 4 + strlen(str);
			str[0] = 0;

			while(len < 40)
			{
				RebuildEmit(" ", str);
				len++;
			}

			DisassembleFromSource(real_ip, str);
			RebuildEmit(";%s", str);
		}
#endif

//		RebuildEmit("\n");

		// Check for case statement, which need case data after them

/*		if (CaseRef)
		{
			RebuildEmit(".data\n");
			Rebuild_Data(CaseRef);
			RebuildEmit(".code\n");
		}
*/
		real_ip += (ip - ip_last);
	}

	RebuildCppEpilog(sym);
}
Ejemplo n.º 25
0
void RebuildFunc(SYMBOL *sym)
{
	OpcodeInfo thisOp;
	SYMBOL *ref;

	uchar *ip, *ip_end, *ip_last;
	
	int real_ip;
	char str[256];

	if (!sym)
		return;

	RebuildEmit("\n//****************************************\n");
	RebuildEmit("// Function: %s\n", sym->Name);
	RebuildEmit("//****************************************\n\n");

#if 0 //OLD
	if (strcmp(sym->Name, Code_EntryPoint) == 0)
	{
		RebuildEmit(".global %s\n", sym->Name);
		RebuildEmit(".func %s\n", sym->Name);
	}
	else
	{
		RebuildEmit(".func %s_%d\n", sym->Name, sym->LocalScope);
	}
#else //New

	if (strcmp(sym->Name, Code_EntryPoint) == 0)
	{
		RebuildEmit(".global %s\n", sym->Name);
		RebuildEmit(".func %s, %d, %s\n", sym->Name, sym->Params, RebuildRetType(sym->RetType) );
	}
	else
	{
		RebuildEmit(".func %s_%d, %d, %s\n", sym->Name, sym->LocalScope, sym->Params, RebuildRetType(sym->RetType));
	}

#endif

	ip_end = (uchar *) ArrayPtr(&CodeMemArray, sym->EndIP);
	ip = (uchar *) ArrayPtr(&CodeMemArray, sym->Value);
	real_ip	= sym->Value;

	while(1)
	{
		ip_last = ip;
		
		if (ip > ip_end)
			break;

		// Print labels
		
		ref = (SYMBOL *) ArrayGet(&CodeLabelArray, real_ip);

		if (ref)
		{
			if (ref->LabelType == label_Local)
				RebuildEmit("%s_%d:\n", ref->Name, ref->LocalScope);
		}

		RebuildEmitStabs(real_ip);
	
//		Peeper(ip, ip_end);

		if (ArgSkipElim == 0)
			if (ArrayGet(&CodeTouchArray, real_ip) == 0)
				RebuildEmit("// ");

		CaseRef = 0;

		ip = DecodeOpcode(&thisOp, ip);
		DecodeAsmString(&thisOp, str, 1);
		RebuildEmit("\t%s", str);

//		DecodeAsmString(&thisOp, str, 0);			// Sanity testing
//		CodeSanityChecker(thisOp.rip, str);

		if (ArgDebugRebuild)
		{
			int len = 4 + strlen(str);		
			str[0] = 0;
			
			while(len < 40)
			{
				RebuildEmit(" ", str);
				len++;
			}
			
			RebuildEmit("; 0x%x - ", real_ip);
			
			DisassembleFromSource(real_ip, str);
			RebuildEmit("%s", str);
		}

		RebuildEmit("\n");

		// Check for case statement, which need case data after them
		
		if (CaseRef)
		{
			RebuildEmit(".data\n");
			Rebuild_Data(CaseRef);
			RebuildEmit(".code\n");
		}

		real_ip += (ip - ip_last);	
	}
}
Ejemplo n.º 26
0
PetscErrorCode LevelSetUpdateIrregularNodeList_2D( LevelSet ls )
{
  int i, j, k, I, J, ni, nj;
  const int numNei = 4;
  const int nei[][2] = {{1,0},{-1,0},{0,-1},{0,1}};
  IrregularNode *n;
  PetscReal **phi, phiHI, phiLO;
  PetscReal sten[3][3];
  PetscReal local[5][5];
  iCoor *band;
  int b;
  PetscErrorCode ierr;
  
  PetscFunctionBegin;
  ierr = GridGet(ls->phi,&phi); CHKERRQ(ierr);
  for( b = 0; b < ArrayLength(ls->band); ++b)
  {
    ierr = ArrayGet(ls->band,b,&band); CHKERRQ(ierr);
    i = band->x;
    j = band->y;
    
    // Cell-centered Irregular Node
    for( J = -2; J <= 2; ++J) {
      for( I = -2; I <= 2; ++I) {
        local[J+2][I+2] = phi[J+j][I+i];
      }
    } // for local 5x5 stencil

    // Cell-centered Irregular Node
    for( J = -1; J < 2; ++J)
    {
      for( I = -1; I < 2; ++I)
      {
        sten[J+1][I+1] = phi[J+j][I+i];
      }
    } // for local 3x3 stencil

    // Add ortho-proj for FMM boundary condition
    for( k = 0; k < numNei; ++k)
    {
      ni = 1 + nei[k][0];
      nj = 1 + nei[k][1];
      if( sten[1][1] * sten[nj][ni] <= 0. )
      {
        ierr = ArrayAppend( ls->irregularNodes, &n ); CHKERRQ(ierr);
        OrthogonalProjection2D( sten, local, &n->op);
        n->pos = *band;
        n->axis  = -1; // no-axis
        n->shift = -1;
        n->signCenter = sten[1][1] > 0. ? 1 : -1;
        n->X.x = n->pos.x + n->op.x;
        n->X.y = n->pos.y + n->op.y;
        break;
      }
    }

    // Add IIM irregular grid point
    // Cell-centered gradients
    for( k = U_FACE; k <= V_FACE; ++k)
    {
      ni = 1 + STAGGERED_GRID[k].x;
      nj = 1 + STAGGERED_GRID[k].y;
      if( sten[1][1] * sten[nj][ni] <= 0. )
      {
        ierr = ArrayAppend( ls->irregularNodes, &n ); CHKERRQ(ierr);
        n->d = sten[1][1] / (sten[1][1] - sten[nj][ni]);
        n->signCenter = sten[1][1] > 0. ? 1 : -1;
        n->signFace = n->d < 0.5 ? -n->signCenter : n->signCenter;
        n->pos = *band;
        n->shift = CELL_CENTER;
        n->axis  = k-U_FACE; // assuming U_FACE == 1, x-axis is 0, y-axis is 1
        n->X.x = n->pos.x + n->d * STAGGERED_GRID[k].x;
        n->X.y = n->pos.y + n->d * STAGGERED_GRID[k].y;
      } // if irreg
    } // for k in {U_FACE,V_FACE}

    // U-Velocity Laplacian
    phiHI = ( sten[1][0] + sten[1][1] ) / 2.;
    phiLO = ( sten[0][0] + sten[0][1] ) / 2.;
    if( phiHI * phiLO <= 0. )
    {
      ierr = ArrayAppend( ls->irregularNodes, &n ); CHKERRQ(ierr);
      n->d = phiHI / (phiHI - phiLO);
      n->signCenter = phiHI > 0. ? 1 : -1;
      n->signFace = n->d < 0.5 ? -n->signCenter : n->signCenter;
      n->pos = *band;
      n->shift = U_FACE;
      n->axis  = V_FACE-U_FACE; // y-axis == 1
      n->X.x = n->pos.x + STAGGERED_GRID[U_FACE].x / 2.;
      n->X.y = n->pos.y + STAGGERED_GRID[U_FACE].y / 2. - n->d;
    } // if irreg

    // V-Velicty Laplacian
    phiHI = ( sten[0][1] + sten[1][1] ) / 2.;
    phiLO = ( sten[0][0] + sten[1][0] ) / 2.;
    if( phiHI * phiLO <= 0. )
    {
      ierr = ArrayAppend( ls->irregularNodes, &n ); CHKERRQ(ierr);
      n->d = phiHI / (phiHI - phiLO);
      n->signCenter = phiHI > 0. ? 1 : -1;
      n->signFace = n->d < 0.5 ? -n->signCenter : n->signCenter;
      n->pos = *band;
      n->shift = V_FACE;
      n->axis  = U_FACE-U_FACE; // x-axis == 0
      n->X.x = n->pos.x + STAGGERED_GRID[V_FACE].x / 2. - n->d;
      n->X.y = n->pos.y + STAGGERED_GRID[V_FACE].y / 2.;
    } // if irreg
  } // for b in band
  PetscFunctionReturn(0);
}
Ejemplo n.º 27
0
uint arrayGet(int index)
{
	return ArrayGet(CurrentArray, index);
}
Ejemplo n.º 28
0
int RebuildCppInst(OpcodeInfo *theOp)
{
	int ip = theOp->rip;
	char str[256];

#ifdef CPP_DEBUG
	str[0] = 0;
	DisassembleFromSource(ip, str);
	RebuildEmit("\t\t\t\t\t\t//%s\n", str);
#endif


#ifdef CPP_SHOW_LINES
	{
		int line = ArrayGet(&SLD_Line_Array, ip);
		int file = ArrayGet(&SLD_File_Array, ip);

		if(line!=0) {
			RebuildEmit("\n	// %s:%d\n", GetFileNumString(file), line);
			RebuildEmit("	// %s\n", GetFileLine(file, line));
		}
	}
#endif

	switch (theOp->op)
	{
		case _PUSH:
			RebuildEmit("	//push %s,%d\n",Cpp_reg[theOp->rd], theOp->rs);

			if (REGUSED(funcprop.reg_used, REG_sp))
			{
				RebuildEmit("	sp -= %d;\n",theOp->rs*4);
			}
		return 1;

		case _POP:
			RebuildEmit("	//pop  %s,%d\n",Cpp_reg[theOp->rd], theOp->rs);

			if (REGUSED(funcprop.reg_used, REG_sp))
			{
				RebuildEmit("	sp += %d;\n",theOp->rs*4);
			}

		return 1;

		case _CASE:
			CppDecodeSwitch(theOp);
		break;


		case _CALLI:
			CppDecodeCall(theOp);
		break;

		case _SYSCALL:
			CppDecodeSysCall(theOp);
		break;

		case _CALL:
			CppDecodeCallReg(theOp);
		break;

		case _LDI:
			RebuildEmit("	%s = 0x%x;", Cpp_reg[theOp->rd], theOp->imm);
		break;

		case _LDR:
		{
			if (IsRegConst(theOp->rs))
				RebuildEmit("	%s = 0x%x;", Cpp_reg[theOp->rd], ConstRegValue(theOp->rs));
			else
				RebuildEmit("	%s = %s;", Cpp_reg[theOp->rd], Cpp_reg[theOp->rs]);
		}
		break;

		// Arithmatic

		case _ADD:
			CppEmitArith(theOp,"+", 0);
		break;

		case _ADDI:
			CppEmitArith(theOp,"+", 1);
		break;

		case _MUL:
			CppEmitArith(theOp,"*", 0);
		break;

		case _MULI:
			CppEmitArith(theOp,"*", 1);
		break;

		case _SUB:
			CppEmitArith(theOp,"-", 0);
		break;

		case _SUBI:
			CppEmitArith(theOp,"-", 1);
		break;

		case _AND:
			CppEmitArith(theOp,"&", 0);
		break;

		case _ANDI:
			CppEmitArith(theOp,"&", 1);
		break;

		case _OR:
			CppEmitArith(theOp,"|", 0);
		break;

		case _ORI:
			CppEmitArith(theOp,"|", 1);
		break;

		case _XOR:
			CppEmitArith(theOp,"^", 0);
		break;

		case _XORI:
			CppEmitArith(theOp,"^", 1);
		break;

		case _DIVU:
			CppEmitDivu(theOp, 0);
		break;

		case _DIVUI:
			CppEmitDivu(theOp, 1);
		break;

		case _DIV:
			CppEmitArith(theOp,"/", 0);
		break;

		case _DIVI:
			CppEmitArith(theOp,"/", 1);
		break;

		// Shifts

		case _SLL:
			CppEmitShift(theOp,"<<", 0, 0);
		break;

		case _SLLI:
			CppEmitShift(theOp,"<<", 1, 0);
		break;

		case _SRA:
			CppEmitShift(theOp,">>", 0, 0);
		break;

		case _SRAI:
			CppEmitShift(theOp,">>", 1, 0);
		break;

		case _SRL:
			CppEmitShift(theOp,">>", 0, 1);		// Unsigned
		break;

		case _SRLI:
			CppEmitShift(theOp,">>", 1, 1);		// Unsigned
		break;

		case _NOT:
			RebuildEmit("	%s = ~%s;", Cpp_reg[theOp->rd], Cpp_reg[theOp->rs]);
		break;

		case _NEG:
			RebuildEmit("	%s = -%s;", Cpp_reg[theOp->rd], Cpp_reg[theOp->rs]);
		break;

		case _RET:
		{
			if (ThisFunctionExit == 0)	// Don't output a return jump on last instruction
			{
				RebuildEmit("	goto label_0;	// return");
				ReturnCount++;
			}
		}
		break;

		// Conditional jumps

		case _JC_EQ:
			CppEmitJumpCond(theOp, "==", 0);
		break;

		case _JC_NE:
			CppEmitJumpCond(theOp, "!=", 0);
		break;

		case _JC_GE:
			CppEmitJumpCond(theOp, ">=", 0);
		break;

		case _JC_GEU:
			CppEmitJumpCond(theOp, ">=", 1);
		break;

		case _JC_GT:
			CppEmitJumpCond(theOp, ">", 0);
		break;

		case _JC_GTU:
			CppEmitJumpCond(theOp, ">", 1);
		break;

		case _JC_LE:
			CppEmitJumpCond(theOp, "<=", 0);
		break;

		case _JC_LEU:
			CppEmitJumpCond(theOp, "<=", 1);
		break;

		case _JC_LT:
			CppEmitJumpCond(theOp, "<", 0);
		break;

		case _JC_LTU:
			CppEmitJumpCond(theOp, "<", 1);
		break;

		case _JPI:
			CppDecodeLabel(theOp, "	goto label_%d;");
		break;

		// Memory instructions

		case _LDW:
			Cpp_LoadMem(theOp, "RINT");
		break;

		case _LDH:
			Cpp_LoadMem(theOp, "RSHORT");
		break;

		case _LDB:
			Cpp_LoadMem(theOp, "RBYTE");
		break;

		case _STW:
			Cpp_StoreMem(theOp, "WINT");
		break;

		case _STH:
			Cpp_StoreMem(theOp, "WSHORT");
		break;

		case _STB:
			Cpp_StoreMem(theOp, "WBYTE");
		break;

		case _XB:
			RebuildEmit("	%s = (int)((char) %s);", Cpp_reg[theOp->rd], Cpp_reg[theOp->rs]);
		break;

		case _XH:
			RebuildEmit("	%s = (int)((short) %s);", Cpp_reg[theOp->rd], Cpp_reg[theOp->rs]);
		break;

		default:
			str[0] = 0;
			DisassembleFromSource(ip, str);
			ErrorOnIP(Error_Fatal, ip, "Missing instruction in Cpp rebuilder '%s'\n", str);
	}

	//	ArraySet(&SLD_Line_Array, CodeIP, line);
	//	ArraySet(&SLD_File_Array, CodeIP, This_SLD_File);

//	RebuildEmit("\n");

	RebuildEmit("\n");

#ifdef LOG_REGISTER_STATE_CHANGES
	if (funcprop.reg_used)
	{
		/*
		int n;
		for (n=0;n<32;n++)
		{
			if (reg_used & (1 << n))
			{
				RebuildEmit("if(last_%s != %s) { LOG_REGISTER(%s); last_%s = %s;}\n", Cpp_reg[n], Cpp_reg[n], Cpp_reg[n], Cpp_reg[n], Cpp_reg[n]);
			}
		}
		RebuildEmit(";\n\n");
		*/
		RebuildEmit("\tLOG_REGISTER_STATE_CHANGES(0x%x)\n", funcprop.reg_used);
	}
#endif


	return 1;
}
bool process_file(const char* file_name, bool is_std_file,
	Array* file_stack, Array* file_records,
	DoubleList* lines, DoubleList* file_binarys)
{
#if MG_PLATFORM_WINDOWS
	const char* header_search_dirs[] = {
		"D:/Microsoft Visual Studio 12.0/VC/crt/src",
		"D:/Microsoft Visual Studio 12.0/VC/include",
		"D:/Microsoft Visual Studio 12.0/VC/atlmfc/include",
		"C:/Program Files (x86)/Windows Kits/8.1/Include/um",
		"C:/Program Files (x86)/Windows Kits/8.1/Include/shared",
		"C:/Program Files (x86)/Windows Kits/8.1/Include/winrt",
	};
#else
	const char* header_search_dirs[] = {
		"/usr/include",
		"/usr/include/x86_64-linux-gnu",
		"/usr/include/linux",
		"/usr/local/include",
		"/usr/lib/gcc/x86_64-linux-gnu/4.8/include",
	};
#endif
	char* bytes = NULL;
	long byte_num = 0;
	size_t std_search_path_num = sizeof(header_search_dirs) / sizeof(char*);
	size_t index = 0;
	size_t file_path_len;
	char* p_file_path;
	char** pp_file_path;
	char file_path[MG_MAX_PATH];
	bool is_file_exist = false;

	// check file name length
	if (strlen(file_name) == 0)
	{
		MLOG("file name is null\n");
		MASSERT_MSG(0, "file name is null!\n");
		return false;
	}

	// ensure file is exist
	memset(file_path, 0, MG_MAX_PATH);
	sprintf_s(file_path, MG_MAX_PATH - 1, "%s", file_name);
	is_file_exist = File_IsExist(file_path);
	if (!is_file_exist)
	{
		if (is_std_file)
		{
			// try absolute path in std folder
			is_file_exist = SearchInStdFolder(file_name, std_search_path_num, header_search_dirs, file_path);

			// try absolute path in current process path
			if (!is_file_exist)
			{
				File_GetAbsolutePath(file_name, file_path);
				is_file_exist = File_IsExist(file_path);
			}
		}
		else
		{
			// try absolute path in current process path
			File_GetAbsolutePath(file_name, file_path);
			is_file_exist = File_IsExist(file_path);

			// try absolute path in std folder
			if (!is_file_exist)
			{
				is_file_exist = SearchInStdFolder(file_name, std_search_path_num, header_search_dirs, file_path);
			}
		}

		if (!is_file_exist)
		{
			MLOG("file %s is not exsit\n", file_name);
			MASSERT_MSG(0, "file is not exsit\n");
			return false;
		}
	}

	// detect file repeat in one step
	for (index = 0; index < ArrayUsed(file_stack); ++index)
	{
		char** p_address = (char**)ArrayGet(file_stack, index);
		if (strncmp(*p_address, file_path, MG_MAX_PATH) == 0)
		{
			return false;
		}
	}

	// detect file repeat in all step
	for (index = 0; index < ArrayUsed(file_records); ++index)
	{
		char** p_address = (char**)ArrayGet(file_records, index);
		if (strncmp(*p_address, file_path, MG_MAX_PATH) == 0)
		{
			return true;
		}
	}

	// read file
	if (!File_Read(file_path, &bytes, &byte_num))
	{
		MLOG("file %s is not exsit\n", file_path);
		MASSERT_MSG(0, "failed in read file\n");
		return false;
	}

	// push file path into file stack
	file_path_len = strlen(file_path) + 1;
	p_file_path = (char*)malloc(sizeof(char) * file_path_len);
	memcpy(p_file_path, file_path, file_path_len);
	ArrayPush(file_stack, &p_file_path);

	// push file path into file records
	p_file_path = (char*)malloc(sizeof(char) * file_path_len);
	memcpy(p_file_path, file_path, file_path_len);
	ArrayPush(file_records, &p_file_path);

	// save bytes
	DoubleListAdd(file_binarys, &bytes);
	if (byte_num == 0)
	{
		return true;
	}

	// split into lines
	SplitLines(bytes, lines);

	// parse each line
	if (!parse_lines(file_stack, file_records, lines, file_binarys))
	{
		MASSERT_MSG(0, "failed in parse lines");
		MLOG("failed in parse lines");
		return false;
	}

	// pop this file
	pp_file_path = ArrayGet(file_stack, ArrayUsed(file_stack) - 1);
	MASSERT(strncmp(*pp_file_path, p_file_path, MG_MAX_PATH) == 0);
	if (strncmp(*pp_file_path, p_file_path, MG_MAX_PATH) != 0)
	{
		return false;
	}
	free(*pp_file_path);
	ArrayPop(file_stack);

	return true;
}
Ejemplo n.º 30
0
void DumpIPTrans()
{
    SYMBOL	*Sym;
    SYMBOL  *LastSLDSym = NULL;
    FILE	*SldFile = 0;
    int		line, file;
    uint		n;
    int MustConvertPaths = 0;

    Sym = SymTab;
    n = SYMMAX;

    SldFile = fopen(SldName, "w");

    if (!SldFile)
    {
        printf("Failed to create source line file'\n");
        return;
    }

    fprintf(SldFile, "Files\n");


    do
    {
        if (Sym->Section == section_SLD_File)
        {
            char *SymName = Sym->Name;
            size_t i, j = 0, len;
            char temp[256];

            if(!MustConvertPaths) {
                if(LastSLDSym && LastSLDSym->Type > Sym->Type)
                    MustConvertPaths = 1;
                LastSLDSym = Sym;
            }

            if(MustConvertPaths) {
                char *ParentPath = GetFileIdString(Sym->Type);
                GetRelPath(ParentPath);
                len = strlen(Sym->Name);
#define IS_SLASH(c) ((c)=='/' || (c)=='\\')
                if((len>2 && Sym->Name[1]==':' && IS_SLASH(Sym->Name[2])) || (len>0 && IS_SLASH(Sym->Name[0]))) {

                } else {
                    SymName = AddRelPrefix(Sym->Name);
                }
            }

            len = strlen(SymName);
            // filter out bad slashes...
            for(i = 0; i < len; i++) {

                if(IS_SLASH(SymName[i])) {
                    if(i+1<len-1 && IS_SLASH(SymName[i+1])) {
                        i++;
                    }
                    temp[j++] = '/';
                } else
                    temp[j++] = SymName[i];
            }

            temp[j] = 0;

            fprintf(SldFile, "%d:%d:%s\n", Sym->Value, Sym->Type, temp);
        }

        Sym++;
    }
    while(--n);

    fprintf(SldFile, "SLD\n");

    if (!SLD_Line_Array.array)
        return;

    for (n=SLD_Line_Array.lo; n<SLD_Line_Array.hi+1; n++)
    {

        line = ArrayGet(&SLD_Line_Array, n);
        file= ArrayGet(&SLD_File_Array, n);

        if (line)
        {
            fprintf(SldFile, "%x:%d:%d\n", n, line, file);
        }
    }

    DumpFunctions(SldFile);
    DumpVariables(SldFile);
    //DumpAllSyms(SldFile);
    Dump_MasterIP_Trans(SldFile);

    fprintf(SldFile, "END\n");

    fclose(SldFile);
    return;
}