/*Will only close the door*/
int closeDoor(int searchFor, int direction)
{
    if (returnAttribute(searchFor) == 0)
    {
        if (direction == UP)
        {
            cMAttribute(searchFor, 1, -1, 0);
            cMAppearance(searchFor, 1, -1, ' ');
            cMAppearance(searchFor, 1, 0, '/');
            Sleep (DRAWSPEED*2);
            cMAttribute(searchFor, 0, 0, 1);
            cMAppearance(searchFor, 1, 0, ' ');
            cMAppearance(searchFor, 0, 0, '-');
        }
        else if (direction == DOWN)
        {
            cMAttribute(searchFor, -1, 1, 0);
            cMAppearance(searchFor, -1, 1, ' ');
            cMAppearance(searchFor, -1, 0, '/');
            Sleep (DRAWSPEED*2);
            cMAttribute(searchFor, 0, 0, 1);
            cMAppearance(searchFor, -1, 0, ' ');
            cMAppearance(searchFor, 0, 0, '-');
        }
        else if (direction == LEFT)
        {
            cMAttribute(searchFor, -1, -1, 0);
            cMAppearance(searchFor, -1, -1, ' ');
            cMAppearance(searchFor, 0, -1, 92);
            Sleep (DRAWSPEED*2);
            cMAttribute(searchFor, 0, 0, 1);
            cMAppearance(searchFor, 0, -1, ' ');
            cMAppearance(searchFor, 0, 0, '|');
        }
        else if (direction == RIGHT)
        {
            cMAttribute(searchFor, 1, 1, 0);
            cMAppearance(searchFor, 1, 1, ' ');
            cMAppearance(searchFor, 0, 1, 92);
            Sleep (DRAWSPEED*2);
            cMAttribute(searchFor, 0, 0, 1);
            cMAppearance(searchFor, 0, 1, ' ');
            cMAppearance(searchFor, 0, 0, '|');
        }
        return TRUE;
    }
    return FALSE;
}
Example #2
0
//-----------------------------------------------------------------------------
// Functions required by the tree traversal mechanism
ClasshierarchyInhAttr
ClasshierarchyTraversal::evaluateInheritedAttribute (
                SgNode* astNode,
                ClasshierarchyInhAttr inheritedAttribute )
{
        GlobalDatabaseConnection *gdb;    // db connection
        //long funcId;                                                                                  // id of a function declaration
        Classhierarchy *classhier = getClasshierarchy();
        gdb = getDB();  

        switch(astNode->variantT())
        {

                case V_SgMemberFunctionDeclaration: {
                        SgMemberFunctionDeclaration *funcDec = isSgMemberFunctionDeclaration( astNode );
                        //funcDec = funcDef->get_declaration();
                        //if(isSgMemberFunctionDeclaration(funcDec)) {
                                // add to class hierarchy if member function definition
                                //if(isSgMemberFunctionDeclaration()) {
                                //cerr << " adding CHvinf for MembFunc " << endl;
                                SgClassDefinition *classDef = isSgClassDefinition( funcDec->get_scope() );
                                //assert(classDef);
                                if(classDef) {
                                        string classname = classDef->get_qualified_name().str();
                                        // get the classhier. vertex
                                        Classhierarchy::dbgVertex chVert = 0; //?? init necessary
                                        bool foundClass = false;
                                        Classhierarchy::dbgVertexIterator chvi,chvend;
                                        boost::tie(chvi,chvend) = boost::vertices( *getClasshierarchy() );
                                        for(; chvi!=chvend; chvi++) {
                                                if( boost::get( vertex_dbg_data,  *getClasshierarchy() , *chvi).get_typeName() == classname ) {
                                                        chVert = *chvi;
                                                        foundClass = true;
                                                }
                                        }
                                        if(foundClass) {
                                                property_map< Classhierarchy::dbgType, boost::vertex_classhierarchy_t>::type chMap = boost::get( boost::vertex_classhierarchy, *getClasshierarchy() );
                                                chMap[ chVert ].defined.insert( funcDec );
                                                //get type?
                                                //cerr << " added! "; // debug
                                        }
                                }

                        //}
                        cerr << " found V_SgMemberFunctionDeclaration done for " <<funcDec->get_mangled_name().str()<< " " << endl; // debug
                        } break;

                case V_SgClassDefinition: {
                        cerr << " found V_SgClassDef of "; // debug
                        SgClassDefinition *classDef = isSgClassDefinition( astNode );
                        assert( classDef );
                        SgName classname = classDef->get_qualified_name();

                        // make db entry
                        long typeId = UNKNOWNID;
                        typesTableAccess types( gdb );
                        typesRowdata newtype( typeId, getProjectId(), classname.str() );
                        typeId = types.retrieveCreateByColumn( &newtype, "typeName", newtype.get_typeName(), newtype.get_projectId() );
                        cerr << classname.str()<< ", id:" << newtype.get_id() << endl; // debug
                        //classhier->addNode( newtype, newtype.get_typeName() );
                        //classhier->insertWithName( newtype, newtype.get_typeName() );
                        classhier->insertVertex( newtype, newtype.get_typeName() );

                        SgBaseClassList inherits = classDef->get_inheritances();
                        for( SgBaseClassList::iterator i=inherits.begin(); i!=inherits.end(); i++) {
                                SgClassDeclaration *parentDecl = (*i).get_base_class();
                                cerr << " found inheritance from " ; // debug
                                assert( parentDecl );

                                // add new edge
                                typesRowdata partype( UNKNOWNID, getProjectId(), parentDecl->get_name().str() ); // MANGLE
                                long parentId = types.retrieveCreateByColumn( &partype, "typeName", partype.get_typeName(), partype.get_projectId() );
                                cerr << parentDecl->get_name().str() << ", id: " << parentId << endl;

                                // add to class hierarchy graph, allow only one edge per inheritance
                                //A classhier->addNode( partype, partype.get_typeName() );
                                //A classhier->addEdge( newtype, partype, false );
                                classhier->insertEdge( newtype, partype );
                        }
                        
                        } break;

        } // switch node type


        // Note that we have to use a particular constructor (to pass on context information about source code position).
        // This allows the Rewrite mechanism to position new source code relative to the current position using a simple interface.
        ClasshierarchyInhAttr returnAttribute(inheritedAttribute,astNode);
        // FIXME why not return inheritedAttribute???

        return returnAttribute;
}