Exemplo n.º 1
0
static void exp__exp_lb_exp_rb(Node* node){
    if(node == NULL) return;
    Node* exp1 = node->firstChild;
    Node* exp2 = exp1->nextSibling->nextSibling;
    handle(exp1);handle(exp2);

#ifdef _DEBUG
showType(exp1->type);
showType(exp2->type);
#endif
    if(exp2->type != NULL && exp2->type->myType != NULL && exp2->type->myType != BASIC_INT){
        semanticError(node->line, "Index should be integer\n", NULL);
    }
    if(exp1->type != NULL && exp1->type->myType != NULL){
        if(exp1->type->myType->typeTag != type_array){
            semanticError(node->line, "Illegal use of '[]'\n", NULL);
        }else{
            node->type = newType();
            node->type->myType = exp1->type->myType->array.element;
#ifdef _DEBUG
printf("what the elment\n");
showType(node->type->myType);
#endif
        }
    }
}
Exemplo n.º 2
0
static void dec__vardec(Node* node){
    if(node == NULL) return;
    Node* vardec = node->firstChild;
    vardec->type = node->type;

#ifdef _DEBUG
showType(vardec->type);
#endif

    handle(vardec);

    if(!insertSymbolTableType(vardec->type)){
        semanticError(vardec->line, "Redefined variable '%s'\n", vardec->type->name);
    }
    node->type = vardec->type;

#ifdef _DEBUG
showType(vardec->type);
#endif

    if(inStruct){    // 添加var到struct中
        structElement[elementIndex] = node->type;
        elementIndex++;
    }
}
Exemplo n.º 3
0
 void
 simpleAttributeBinding()
   {
     string localData;
     auto mutator =
     TreeMutator::build()
       .change("data", [&](string val)
         {
           cout << "\"data\" closure received something "<<val<<endl;
           localData = val;
         });
     
     cout << "concrete TreeMutator size=" << sizeof(mutator)
          << " type="<< demangleCxx (showType (mutator))
          << endl;
     
     CHECK (isnil (localData));
     Attribute testAttribute(string ("that would be acceptable"));
     mutator.setAttribute ("lore", testAttribute);
     CHECK ( isnil (localData)); // nothing happens, nothing changed
     mutator.setAttribute ("data", testAttribute);
     CHECK (!isnil (localData));
     cout << "localData changed to: "<<localData<<endl;
     CHECK (localData == "that would be acceptable");
   }
Exemplo n.º 4
0
void CardPlayer::showCards()
{
	vector<	int >::iterator Iter;
	printf("\033[%dA", (40));
	printf("\033[2J");
	if(m_table != NULL)
		printf("remain: %d\n", m_table->getCardNum());
	printf("baida:\n");
	for(int count = 0 ; count < 2; count ++)
	{
		for(int i = 0; i < m_baidaVec.size(); i++)
		{
			MJCard card = m_baidaVec[i];
			if(count == 0) showValue(card);
			else showType(card);
		}
		printf("\n");
	}
	printf("\n");
	showGuid();

	for(int count = 0 ; count < 2; count ++)
	{
		for(int i = MJTYPE_BEGIN; i < MJTYPE_END; i++)
		{
			for(Iter = m_MyPAIVec[i].begin();Iter !=m_MyPAIVec[i].end(); Iter++)
			{
				MJCard card;
				card.type = i;
				if(i == MJTYPE_BAIDA)
					card.type = m_baida.type;
				card.value = *Iter;
				if(count == 0) showValue(card);
				else showType(card);
			}
		}
		if(m_tmpCard.type != -1 && m_tmpCard.value != -1)
		{
			printf(" ");
			MJCard card = m_tmpCard;
			if(count == 0) showValue(card);
			else showType(card);
		}
		printf("\n");
	}
}
Exemplo n.º 5
0
static void dec__vardec_assignop_exp(Node* node){
    if(node == NULL) return;
    dec__vardec(node);
    if(inStruct){
        semanticError(node->line, "Initialization in the structure definition is not allowed\n", NULL);
    }
    else{
        Node* exp = node->firstChild->nextSibling->nextSibling;
        handle(exp);
#ifdef _DEBUG
showType(node->type);
showType(exp->type);
#endif
        if(!checkType(exp->type, node->type)){
            semanticError(node->line, "Type mismatched\n", NULL);
        }
    }
}
Exemplo n.º 6
0
static void def__specifier_declist_semi(Node* node){
    if(node == NULL) return;
    handle(node->firstChild);
    Type* tmp = node->firstChild->type;

#ifdef _DEBUG 
showType(tmp);
#endif

    Node* declist = node->firstChild->nextSibling;
    declist->type = tmp;
    handle(declist);
}
Exemplo n.º 7
0
static void exp__exp_dot_id(Node* node){
    if(node == NULL) return;
    Node* exp = node->firstChild;
    Node* id = exp->nextSibling->nextSibling;
    handle(exp);
#ifdef _DEBUG
showType(exp->type);
#endif
    if(exp->type == NULL || exp->type->myType == NULL || exp->type->myType->typeTag != define_struct){
        semanticError(node->line, "Illegal use of '.'\n", NULL);
    }else{
        Type* t = exp->type->myType;
        int cnt = t->structure.elementCount;
        bool get = false;
        for(int i = 0 ; i < cnt; ++i){
            if(strcmp(id->text, t->structure.element[i]->name) == 0){
                node->type = t->structure.element[i];
                return;
            }
        }
        semanticError(node->line, "Un-existed field '%s'\n", id->text);
    }
}
Exemplo n.º 8
0
void PlotsBuilder::showAllTypes()
{
    #define showType(tname) m_widget->build##tname->show(); 
    
    //2D
    showType(CartesianGraphCurve);
    showType(CartesianGraphCurve);
    showType(CartesianImplicitCurve);
    showType(CartesianParametricCurve2D);
    showType(PolarGraphCurve);
    //3D
    showType(CartesianParametricCurve3D);
    showType(CartesianGraphSurface);
    showType(CartesianImplicitSurface);
    showType(CartesianParametricSurface);
    showType(CylindricalGraphSurface);
    showType(SphericalGraphSurface);
    
    m_widget->cartesianCurvesLinks->show();
    m_widget->polarCurvesLinks->show();
    m_widget->spaceCurvesLinks->show();
    m_widget->cartesianCurvesLinks->show();
    m_widget->cylindricalSurfacesLinks->show();
    m_widget->sphericalSurfacesLinks->show();
}
Exemplo n.º 9
0
BOOL LLFloaterKeyTool::postBuild(void)
{
	setIsChrome(TRUE);
	setTitle(std::string("KeyTool"));

	mListBottom = getRect().getHeight() - 45;
	showType(LLKeyTool::KT_AGENT, LLAssetType::AT_NONE, MAYBE);
	showType(LLKeyTool::KT_TASK, LLAssetType::AT_NONE, MAYBE);
	showType(LLKeyTool::KT_GROUP, LLAssetType::AT_NONE, MAYBE);
	showType(LLKeyTool::KT_REGION, LLAssetType::AT_NONE, MAYBE);
	showType(LLKeyTool::KT_PARCEL, LLAssetType::AT_NONE, MAYBE);
	showType(LLKeyTool::KT_ITEM, LLAssetType::AT_NONE, MAYBE);
	showType(LLKeyTool::KT_ASSET, LLAssetType::AT_TEXTURE, MAYBE);
	showType(LLKeyTool::KT_ASSET, LLAssetType::AT_SOUND, MAYBE);
	showType(LLKeyTool::KT_ASSET, LLAssetType::AT_ANIMATION, MAYBE);
	showType(LLKeyTool::KT_ASSET, LLAssetType::AT_LANDMARK, MAYBE);
	showType(LLKeyTool::KT_ASSET, LLAssetType::AT_GESTURE, MAYBE);
	showType(LLKeyTool::KT_ASSET, LLAssetType::AT_CLOTHING, MAYBE);
	showType(LLKeyTool::KT_ASSET, LLAssetType::AT_BODYPART, MAYBE);
	//showType(LLKeyTool::KT_ASSET, LLAssetType::AT_COUNT, MAYBE);

	mKeyTool = new LLKeyTool(mKey, keyToolCallback, this);
	return TRUE;
}
Exemplo n.º 10
0
void editLevelScreen()
{
    int currentType = TILE_RED;
    showType(currentType);

    Tile *tiles[TOTAL_TILES];

    if(loadTiles(tiles) == false)
    {
        cleanUp();
        exit(0);
    }

    while(true)
    {
        fps.start();

        while(SDL_PollEvent(&event))
        {
            //When the user clicks
            if( event.type == SDL_MOUSEBUTTONDOWN )
            {
                //Put the tile
                putTile( tiles, currentType );
            }

            if (event.type == SDL_KEYDOWN)
            {
                switch(event.key.keysym.sym)
                {
                    case SDLK_1:
                    case SDLK_q:
                    {
                        //Scroll forward through tiles
                        currentType--;

                        if( currentType < TILE_RED )
                            currentType = TILE_TOPLEFT;

                        //Show the current tile type
                        showType( currentType );
                        break;
                    }
                    case SDLK_2:
                    case SDLK_w:
                    {
                        //Scroll backward through tiles
                        currentType++;

                        if( currentType > TILE_TOPLEFT )
                            currentType = TILE_RED;

                        //Show the current tile type
                        showType( currentType );
                        break;
                    }

                    case SDLK_s:
                    {
                        // save the tiles and display a "saved" message
                        saveTiles(tiles);
                        SDL_Color savedMessageColor = {255, 255, 255};
                        SDL_Surface* savedMessage = NULL;
                        savedMessage = load_font("eva.ttf", "SAVED", savedMessageColor, 24);
                        apply_surface(1, 1, savedMessage, screen);
                        SDL_Delay(500);
                        SDL_FreeSurface(savedMessage);
                        break;
                    }
                    case SDLK_BACKSPACE:
                    {
                        deleteTiles(tiles);
                        startScreen();
                        break;
                    }
                    default:;
                }
            }

            myWindow.handle_window();
            handleMusic();

            if( event.type == SDL_QUIT )
            {
                //Quit the program
                deleteTiles(tiles);
                cleanUp();
                exit(0);
            }
        }

        if (myWindow.error())
        {
            cleanUp();
            exit(0);
        }

        setEditorCamera();

        for (int t = 0; t < TOTAL_TILES; t++)
            tiles[t]->show();

        if (SDL_Flip(screen) == -1)
        {
            cleanUp();
            exit(0);
        }

        //Cap the frame rate
        if( fps.get_ticks() < 1000 / FRAMES_PER_SECOND )
        {
            SDL_Delay( ( 1000 / FRAMES_PER_SECOND ) - fps.get_ticks() );
        }
    }
}