Пример #1
0
void traverseTable()
{
    int i = 0;
    for(i = 0;i < ST_SIZE;i++)
    {
        struct entryInSymbolTable* entry = symbolTable[i];
        while(entry != 0)
        {
            if(entry->symbol.typeId == ARRAY)
            {
                printf("ARRAY : ");
                printType(entry);
            }
            if(entry->symbol.typeId == BASIC)
            {
                printf("BASIC : ");
                printType(entry);
            }
            if(entry->symbol.typeId == FUNCTION)
            {
                printf("Function : ");
                printType(entry);
            }
            printf("name :  %s\n",entry->symbol.name);
            entry = entry->nextEntry;
        }
    }
}
Пример #2
0
int main(int, char **)
{
    printType(DB::NumberTraits::ResultOfAdditionMultiplication<DB::UInt8, DB::UInt8>::Type()); std::cout << std::endl;
    printType(DB::NumberTraits::ResultOfAdditionMultiplication<DB::UInt8, DB::Int32>::Type()); std::cout << std::endl;
    printType(DB::NumberTraits::ResultOfAdditionMultiplication<DB::UInt8, DB::Float32>::Type()); std::cout << std::endl;
    printType(DB::NumberTraits::ResultOfSubtraction<DB::UInt8, DB::UInt8>::Type()); std::cout << std::endl;
    printType(DB::NumberTraits::ResultOfSubtraction<DB::UInt16, DB::UInt8>::Type()); std::cout << std::endl;
    printType(DB::NumberTraits::ResultOfSubtraction<DB::UInt16, DB::Int8>::Type()); std::cout << std::endl;
    printType(DB::NumberTraits::ResultOfFloatingPointDivision<DB::UInt16, DB::Int16>::Type()); std::cout << std::endl;
    printType(DB::NumberTraits::ResultOfFloatingPointDivision<DB::UInt32, DB::Int16>::Type()); std::cout << std::endl;
    printType(DB::NumberTraits::ResultOfIntegerDivision<DB::UInt8, DB::Int16>::Type()); std::cout << std::endl;
    printType(DB::NumberTraits::ResultOfModulo<DB::UInt32, DB::Int8>::Type()); std::cout << std::endl;

    ifLeftType<DB::UInt8>();
    ifLeftType<DB::UInt16>();
    ifLeftType<DB::UInt32>();
    ifLeftType<DB::UInt64>();
    ifLeftType<DB::Int8>();
    ifLeftType<DB::Int16>();
    ifLeftType<DB::Int32>();
    ifLeftType<DB::Int64>();
    ifLeftType<DB::Float32>();
    ifLeftType<DB::Float64>();

    return 0;
}
Пример #3
0
void verifyAssignmentTypeMatch( struct expr_sem *LHS, struct expr_sem *RHS )
{
	__BOOLEAN misMatch = __FALSE;

	if( (LHS->pType->type)==ERROR_t || (RHS->pType->type)==ERROR_t ) {	// previous error(s)
		// ......
	}
	// verify type
	else if( LHS->pType->type != RHS->pType->type ) {
		if( !((LHS->pType->type==FLOAT_t || LHS->pType->type==DOUBLE_t )&&RHS->pType->type==INTEGER_t) ) {
			if(!(LHS->pType->type==DOUBLE_t&&RHS->pType->type==FLOAT_t)){	
				misMatch = __TRUE;
			}
		}
	}

	if( misMatch == __TRUE ) {
		fprintf( stdout, "########## Error at Line#%d: type mismatch, LHS= ", linenum ); semError = __TRUE;
		printType( LHS->pType, 0 );
		fprintf( stdout, ", RHS= " );
		printType( RHS->pType, 0 );
		fprintf( stdout, " ##########\n" );
	}

	// verify dimension #
	if( (LHS->pType->dimNum > 0) || (RHS->pType->dimNum > 0)){
		fprintf( stdout, "########## Error at Line#%d: array type assignment ##########\n", linenum ); semError = __TRUE;
	}
	
}
Пример #4
0
void verifyAssignmentTypeMatch( struct expr_sem *LHS, struct expr_sem *RHS )
{
	__BOOLEAN misMatch = __FALSE;

	if( (LHS->pType->type)==ERROR_t || (RHS->pType->type)==ERROR_t ) {	// previous error(s)
		// ......
	}
	// verify type
	else if( LHS->pType->type != RHS->pType->type ) {
		if( !(LHS->pType->type==REAL_t && RHS->pType->type==INTEGER_t) ) {
			misMatch = __TRUE;
		}
	}
	// verify if it is array
	if( (LHS->pType->isArray == __TRUE ) || (RHS->pType->isArray == __TRUE))
	{
		fprintf( stdout, "<Error> found in Line %d: Can't do array arithemetic \n", linenum );
		return ;
	}
	if( misMatch == __TRUE ) {
		fprintf( stdout, "<Error> found in Line %d: type mismatch, LHS= ", linenum );
		printType( LHS->pType, 0 );
		fprintf( stdout, ", RHS= " );
		printType( RHS->pType, 0 );
		fprintf( stdout, " \n" );
	}
}
Пример #5
0
void ifRightType()
{
    printType(T0());
    std::cout << ", ";
    printType(T1());
    std::cout << " -> ";
    printType(typename DB::NumberTraits::ResultOfIf<T0, T1>::Type());
    std::cout << std::endl;
}
Пример #6
0
int main()
{
	QVariant v(int());
	printType(ctypeToVariantType<int>());
	printType(ctypeToVariantType<double>());
	printType(ctypeToVariantType<QVariantList>());
	printType(ctypeToVariantType<QString>());

//	std::cout << QVariant::nameToType("int") << std::endl;
}
Пример #7
0
static
void
printTypeSig(PE_TYPE_SIG *type_sig)
{
     assert(type_sig);

     printType(type_sig->domain);
     printf(" -> ");
     printType(type_sig->codomain);
}
Пример #8
0
static c_bool
walkProperty(
    c_metaObject object,
    c_metaWalkActionArg actionArg)
{
    toolActionData actionData = (toolActionData)actionArg;
    c_object o;
    c_voidp addr;

    o = c_iterObject(actionData->stack, 0);

    if (c_baseObjectKind(object) == M_ATTRIBUTE) {
        addr = C_DISPLACE(o, (c_address)c_property(object)->offset);
        if (c_typeIsRef(c_property(object)->type)) {
            addr = *(c_voidp *)addr;
            if (c_baseObjectKind(c_property(object)->type) == M_COLLECTION) {
                if (addr) {
                    if (c_iterContains(actionData->stack, addr)) {
                        printf("Ignore cyclic reference 0x"PA_ADDRFMT"\n",
                               (os_address)addr);
                    } else {
                        OBJECT_PUSH(actionData, addr);
                        iprintf("%s ",_METANAME(object));
                        printType(c_property(object)->type, actionData);
                        OBJECT_POP(actionData);
                    }
                } else {
                    iprintf("    %s <0x"PA_ADDRFMT">", _METANAME(object), (os_address)addr);
                }
            } else {
                iprintf("    %s <0x"PA_ADDRFMT">", _METANAME(object), (os_address)addr);
                if (addr) {
                    /* Section for code to print additional type specific info. */
                    if (c_property(object)->type == v_topic_t) {
                        printf(" /* topic name is: %s */", v_topicName(addr));
                    }
                    if (c_property(object)->type == v_partition_t) {
                        printf(" /* Partition: %s */", v_partitionName(addr));
                    }
                    if (c_property(object)->type == c_type_t(c_getBase(object))) {
                        printf(" /* Type: %s */", _METANAME(c_type(addr)));
                    }
                }
            }
            printf("\n");
        } else {
            OBJECT_PUSH(actionData, addr);
            iprintf("%s ",_METANAME(object));
            printType(c_property(object)->type, actionData);
            printf("\n");
            OBJECT_POP(actionData);
        }
    }
    return TRUE;
}
Пример #9
0
void	OSinfo::drawContent( int posX, int posY, int width, int height, Window const & win )
{
	printType(posX + (width - 17) / 2, posY, width, height, win, "Model: ", _info.model);
	posY++;	
	printType(posX + (width - 17) / 2, posY, width, height, win, "Machine: ", _info.machine);
	posY++;
	printType(posX + (width - 17) / 2, posY, width, height, win, "OStype: ", _info.ostype);
	posY++;	
	printType(posX + (width - 17) / 2, posY, width, height, win, "OSrelease: ", _info.osrelease);
	posY++;
}
Пример #10
0
int
main(int argc, char **argv) {

	DIR *dp;
	struct dirent *dirp;

	if (argc != 2) {
		fprintf(stderr, "usage: %s dir_name\n", argv[0]);
		exit(1);
	}

	if ((dp = opendir(argv[1])) == NULL) {
		fprintf(stderr, "can't open '%s'\n", argv[1]);
		exit(1);
	}

	if (chdir(argv[1]) == -1) {
		fprintf(stderr, "can't chdir to '%s': %s\n", argv[1], strerror(errno));
		exit(EXIT_FAILURE);
	}

	while ((dirp = readdir(dp)) != NULL) {
		struct stat sb;
		if (stat(dirp->d_name, &sb) == -1) {
			fprintf(stderr, "Can't stat %s: %s\n", dirp->d_name,
						strerror(errno));

			if (lstat(dirp->d_name, &sb) == -1) {
				fprintf(stderr,"Can't stat %s: %s\n", dirp->d_name,
						strerror(errno));
				continue;
			}
		}

		printf("%s (", dirp->d_name);
		printType(sb);
		printf(" - ");

		if (lstat(dirp->d_name, &sb) == -1) {
			fprintf(stderr,"Can't stat %s: %s\n", dirp->d_name,
						strerror(errno));
			continue;
		}
		printType(sb);
		printf(")\n");
	}

	closedir(dp);
	return(0);
}
Пример #11
0
void searchTree(TreeNode* root, ConstTable* MainConstTable, TypeTable* MainTypeTable, VarTable* MainVarTable, ProcedureTable* MainProcedureTable)
{
	enumlist = NULL;
	errorOccur = 0;
	current_procedure = (char*)malloc(100);
	memset(current_procedure, 0, 100);
	strcpy(current_procedure, "main");

	TreeNode *head = root->child->sibling->child;//routine_heads


	TreeNode *const_type = getChild(2, head);
	makeNewConstTable(const_type, MainConstTable, MainTypeTable, MainVarTable, MainProcedureTable);
	
	makeNewTypeTable(getChild(3, head), MainConstTable, MainTypeTable, MainVarTable, MainProcedureTable);
	
	makeNewVarTable((TreeNode*)getChild(4,head), MainConstTable, MainTypeTable, MainVarTable, MainProcedureTable);

	ProcedureTableNode* mainnode = makeNewProcedureTableNode();
	mainnode->name = "main";
	mainnode->returntype = NULL;
	mainnode->next = NULL;
	mainnode->paranum = mainnode->line_no = mainnode->size = 0;
	mainnode->paralist = NULL;
	int t = insertIntoProcedureTable(mainnode, MainConstTable, MainTypeTable, MainVarTable, MainProcedureTable);
	if(t == -1)
		return;

	makeNewProcedureTable((TreeNode*)getChild(5,head), MainConstTable, MainTypeTable, MainVarTable, MainProcedureTable);

	//if(getType("days", "main", MainConstTable, MainTypeTable, MainVarTable, MainProcedureTable) != NULL)
	//	printType(getType("days", "main", MainConstTable, MainTypeTable, MainVarTable, MainProcedureTable));
	/*
	printf("\nnum: %d\n", get_args_list_num("testfunc", MainProcedureTable));
	*/
	printType(get_args_type(1, "testfunc", "main", MainConstTable, MainTypeTable, MainVarTable, MainProcedureTable));
	printType(get_return_type("testfunc", "main_testfunc", MainProcedureTable));
	
	int size, address, totallevel, leveltofather;
	char* label = (char*)malloc(100);
	memset(label, 0, 100);
	
	getAddress("k", "main_testfunc", &size, &label, &address, &totallevel, &leveltofather, MainConstTable, MainVarTable, MainProcedureTable);
	printf("size:%d address:%d totallevel:%d leveltofather:%d label:%s\n", size, address, totallevel, leveltofather, label);
	free(label);
	printf("ifexists: %d", ifExists("dt.year", "main_testfunc", MainConstTable, MainTypeTable, MainVarTable, MainProcedureTable));


}
Пример #12
0
void CodeGenerator::printParamList(const Node *firstParamNode, FuncEntry *funcEntry)
{
	Node *paramNode = const_cast<Node*>(firstParamNode);
	Node *paramTypeNode, *paramNameNode;
	unsigned long long key;
	SYM_TYPE type;
	while(paramNode->kind == PARAM)
	{
		paramTypeNode = paramNode->son;
		paramNameNode = paramTypeNode->bro;
		key = SymbolTable::hash(paramNameNode->val.sVal);
		if(symbolTable.isInThisScope(key))
		{
			std::cerr << "parameter is duplicated : " << paramNameNode->val.sVal << std::endl;
			exit(-1);
		}
		else
		{
			type = getType(paramTypeNode);
			funcEntry->addParam(type, key);
			printType(paramTypeNode);
			ofs << ' ' << paramNameNode->val.sVal;
		}
		paramNode = paramNode->bro;
		if(paramNode->kind == PARAM)
			ofs << ", ";
	}
}
Пример #13
0
QString Interpreter::printArgType(uint8_t *type, int &index)
{
    if (*type==CRP_INT8)
        return "INT8";
    else if (*type==CRP_INT16)
        return "INT16";
    else if (*type==CRP_INT32)
        return "INT32";
    else if (*type==CRP_TYPE_HINT)
    {
        int n = strlen((char *)type);
        QString print = "HINT(";
        if (n>4)
        {
            print += printType(FOURCC(type[1], type[2], type[3], type[4]), false) + ") ";
            index += 4;
        }
        else
        {
            index += n-1;
            print += "error)";
        }
        return print;
    }
    else
        return "?";
}
Пример #14
0
/* When the name  selected changes to currName gets its type and definition */
static local VOID SetName(HWND hDlg, UINT currName, List names)
{
  Name	nm = nth(currName,names);

  if (nonNull(name(nm).type))
      printType(stdstr,name(nm).type);
  else
    fprintf(stdstr,"<Unknown type>");
  fprintf(stdstr, "\n");

  SendDlgItemMessage(hDlg, LB_NAMESTYPE ,LB_RESETCONTENT, 0, 0L);
  SendDlgItemMessage(hDlg, LB_NAMESTYPE ,LB_ADDSTRING, 0, (LONG)(LPSTR) stdstrbuff);


  if (isCfun(nm))
    fprintf(stdstr,"Data constructor");
  else if (isMfun(nm))
    fprintf(stdstr, "Class member");
  else if (isSfun(nm))
    fprintf(stdstr, "Selector function");
  else if (name(nm).primDef)
    fprintf(stdstr, "Primitive");
  fprintf(stdstr, "\n");

  SendDlgItemMessage(hDlg, LB_NAMESNOTES ,LB_RESETCONTENT, 0, 0L);
  SendDlgItemMessage(hDlg, LB_NAMESNOTES ,LB_ADDSTRING, 0, (LONG)(LPSTR) stdstrbuff);
}
Пример #15
0
bool ASTPrinter::visit(TupleExpression const& _node)
{
	writeLine(string("TupleExpression"));
	printType(_node);
	printSourcePart(_node);
	return goDeeper();
}
Пример #16
0
bool ASTPrinter::visit(Identifier const& _node)
{
	writeLine(string("Identifier ") + _node.getName());
	printType(_node);
	printSourcePart(_node);
	return goDeeper();
}
Пример #17
0
int main(int argc, char* argv[])
{
    if(argc < 2) return -1;

    std::fstream file(argv[1], std::fstream::in);
    BinaryStream bs(file);

    Deserializer decoder(bs);

    try
    {
        Amf3Type ttt = decoder.readType();

        std::cout<<"type="<<(int)ttt.type()<<std::endl;
        printType(&ttt, 0);
    }
    catch (const char * msg) {
        std::cout<<"Exception: '"<<msg<<"'"<<std::endl;
    }
    catch (...)
    {
        std::cout<<"Unknown exception"<<std::endl;
    }

}
Пример #18
0
bool ASTPrinter::visit(ElementaryTypeNameExpression const& _node)
{
	writeLine(string("ElementaryTypeNameExpression ") + Token::toString(_node.getTypeToken()));
	printType(_node);
	printSourcePart(_node);
	return goDeeper();
}
Пример #19
0
bool ASTPrinter::visit(MemberAccess const& _node)
{
	writeLine("MemberAccess to member " + _node.getMemberName());
	printType(_node);
	printSourcePart(_node);
	return goDeeper();
}
Пример #20
0
bool ASTPrinter::visit(IndexAccess const& _node)
{
	writeLine("IndexAccess");
	printType(_node);
	printSourcePart(_node);
	return goDeeper();
}
Пример #21
0
bool ASTPrinter::visit(FunctionCall const& _node)
{
	writeLine("FunctionCall");
	printType(_node);
	printSourcePart(_node);
	return goDeeper();
}
Пример #22
0
bool ASTPrinter::visit(NewExpression const& _node)
{
	writeLine("NewExpression");
	printType(_node);
	printSourcePart(_node);
	return goDeeper();
}
Пример #23
0
bool ASTPrinter::visit(Assignment const& _node)
{
	writeLine(string("Assignment using operator ") + Token::toString(_node.getAssignmentOperator()));
	printType(_node);
	printSourcePart(_node);
	return goDeeper();
}
Пример #24
0
bool ASTPrinter::visit(BinaryOperation const& _node)
{
	writeLine(string("BinaryOperation using operator ") + Token::toString(_node.getOperator()));
	printType(_node);
	printSourcePart(_node);
	return goDeeper();
}
Пример #25
0
/*
  Synopsis: builds the standard real form interface for G and lo.

  Explanation: d_in[rf] is the inner numbering (the one used by G) of the
  weak real form rf; d_out[rf] is the outer numbering (the one used by the
  interface) of rf --- so d_in and d_out are inverses of each other. The
  names are names for the corresponding Lie algebras.
*/
Interface::Interface(const ComplexReductiveGroup& G,
		     const lietype::Layout& lo)
: d_in(G.numRealForms()), d_out(G.numRealForms()), d_name(G.numRealForms())
{
  const size_t nrf = G.numRealForms();
  const RootSystem& rs = G.rootSystem();
  const Fiber& fundf = G.fundamental();

  std::vector<RealFormData> rf_data; rf_data.reserve(nrf);

  for (RealFormNbr rf = 0; rf<nrf; ++rf)
  {
    RootNbrSet so = cartanclass::toMostSplit(fundf,rf,rs);
    Grading gr = cartanclass::specialGrading(fundf,rf,rs);
    rf_data.push_back(RealFormData(rf,gr,so));
  }

  std::sort(rf_data.begin(),rf_data.end());

  for (size_t i = 0; i<nrf; ++i)
  {
    d_in[i] = rf_data[i].realForm();
    d_out[d_in[i]] = i;
  }

  // write names
  std::ostringstream os;

  for (size_t i = 0; i<nrf; ++i)
  {
    os.str("");
    printType(os,rf_data[i].grading(),lo);
    d_name[i] = os.str();
  }
}
Пример #26
0
void printSymbol(symbol_t symbol)
{
	fprintf(stderr,"(");
	fprintf(stderr,"%s",symbol.text);
	fprintf(stderr," : ");
	printType(symbol.type);
	fprintf(stderr,")");
}
Пример #27
0
bool ASTPrinter::visit(UnaryOperation const& _node)
{
	writeLine(string("UnaryOperation (") + (_node.isPrefixOperation() ? "prefix" : "postfix") +
			  ") " + Token::toString(_node.getOperator()));
	printType(_node);
	printSourcePart(_node);
	return goDeeper();
}
Пример #28
0
void print_Ast_Recursion(AstNodePtr root) { 
//printf(" print_Ast_Recursion: root = %d\n", root);
   /*
    * End the recursion
    */
   if(root == NULL)
      return;
     
   switch(root->nKind) {
   case METHOD :
//printf(" root->nKind = METHOD\n");   
      printType(root->nType, 0);
      printf("  %s(", root->nSymbolPtr->id);
      if(root->children[0] == NULL)
         printf(" void");
      else
         print_Ast_Recursion(root->children[0]); // print the parameters of the method
      printf(" )\n");
      print_Ast_Recursion(root->children[1]); // print the body of the method
      printf(" \n");
      print_Ast_Recursion(root->sibling); // print the next method
   break;
   case FORMALVAR :
//printf(" root->nKind = FORMALVAR\n");   
      printType(root->nSymbolPtr->stype, 0); // print the type
      printf("  %s", root->nSymbolPtr->id); // print the name of the variable
      if(root->nSymbolPtr->stype->kind == ARRAY)
         printf(" []");
      /*
       * Print the next parameter if there's one
       */
      if(root->sibling != NULL) {
         printf(" , ");
         print_Ast_Recursion(root->sibling);
      }
   break;
   case STMT :
//printf(" root->nKind = STMT\n");   
      print_Statement(root);
   break;
   case EXPRESSION :
//printf(" root->nKind = EXPRESSION\n");   
      print_Expression(root, 1); // I don't think it ever gets here
   break;
   }
}
Пример #29
0
static
void
printStructorTypeSig (PE_STRUCTOR_TYPE_SIG *sig)
{
  assert (sig);

  printType (sig->domain);
  printf (" -> ");

  if (sig->param)
    {
      printType (sig->param);
      printf (" => ");
    }

  printType (sig->codomain);
}
Пример #30
0
void lua::utils::dumpTable(TraversalInfo input)
{
    bool tableIsNotEmpty = false;
    input.output << '{';

    const int top = lua_gettop(input.L);

    const int tableIndex = input.index;

    TraversalInfo keyInput(input);
    keyInput.index = top + 1;
    keyInput.level += 1;
    keyInput.indent = true;

    TraversalInfo valueInput(input);
    valueInput.index = top + 2;
    valueInput.level += 1;
    valueInput.indent = false;

    // first 'dummy' key
    lua_pushnil(input.L);

    // table is in the stack at 'tableIndex'
    while (lua_next(input.L, tableIndex) != 0)
    {
        tableIsNotEmpty = true;
        input.output << '\n';

        printType(keyInput);
        input.output << " => ";
        printType(valueInput);

        // removes 'value' but keeps 'key' for next iteration
        lua_pop(input.L, 1);
    }
    if (tableIsNotEmpty)
    {
        input.output << '\n';
        if (input.indent)
        {
            helper::indent(input.level, input.output);
        }
    }
    input.output << '}';
}