ostream& operator << ( ostream& out, const Token& token ) { if ( token.type == IDENT_T || token.type == SINGLE0_T || token.type == INTEGER_T || token.type == STRINGCONST_T || token.type == OTHERERROR ) out << nameOf( token.type ) << " " << token.lexeme << " " << token.line << ":" << token.column; else out << nameOf( token.type ) << " " << token.line << ":" << token.column; return out; }
//===----------------------------------------------------------------------===// // Check whether the current token's type equal tokenType //===----------------------------------------------------------------------===// bool Parser::check( int tokenType ) { // NUM case to match both SINGLE0_T and INTEGER_T if ( nameOf( tokenType ) == "NUM" && nameOf( token.type ) == "NUM" ) return true; else if ( token.type == tokenType ) return true; else return false; }
void enumerateSystemBusses() { auto sb = getChild(ACPI_ROOT_OBJECT, "_SB_"); for(auto child : getChildren(sb)) { auto id = getHardwareId(child); if(id != "PNP0A03" && id != "PNP0A08") continue; frigg::infoLogger() << "thor: Found PCI host bridge" << frigg::endLog; pci::RoutingInfo routing{*kernelAlloc}; acpi::ScopedBuffer buffer; ACPICA_CHECK(AcpiGetIrqRoutingTable(child, buffer.get())); size_t offset = 0; while(true) { auto route = (ACPI_PCI_ROUTING_TABLE *)((char *)buffer.data() + offset); if(!route->Length) break; auto slot = route->Address >> 16; auto function = route->Address & 0xFFFF; assert(function == 0xFFFF); auto index = static_cast<pci::IrqIndex>(route->Pin + 1); if(!*route->Source) { frigg::infoLogger() << " Route for slot " << slot << ", " << nameOf(index) << ": " << "GSI " << route->SourceIndex << frigg::endLog; configureIrq(route->SourceIndex, {TriggerMode::level, Polarity::low}); auto pin = getGlobalSystemIrq(route->SourceIndex); routing.push({slot, index, pin}); }else{ frigg::infoLogger() << " Route for slot " << slot << ", " << nameOf(index) << ": " << (const char *)route->Source << "[" << route->SourceIndex << "]" << frigg::endLog; assert(!route->SourceIndex); auto pin = configureRoute(const_cast<const char *>(route->Source)); routing.push({slot, index, pin}); } offset += route->Length; } pci::pciDiscover(routing); } }
string BinOp::toString( string indent ) { string result = indent + "BinOp " + nameOf( op ) + "\n"; result += left->toString( indent + " " ); result += right->toString( indent + " " ); return result; }
void DataTreeView::dataModifiersChanged( const phantom::data& a_Data, modifiers_t a_Modifiers ) { modifiers_t modifiers = a_Modifiers | a_Data.type()->getModifiers(); DataTreeViewItem* pItem = getItem(a_Data); if(pItem != nullptr) { // if( a_Modifiers.matchesMask(o_component) ) // { // pItem->setHidden(m_bHideComponentData); // } if( ((modifiers&o_private_visibility) == o_private_visibility)) { pItem->setHidden(m_bHidePrivate); } if( ((modifiers&o_protected_visibility) == o_protected_visibility) ) { pItem->setHidden(m_bHideProtected); } Qt::ItemFlags flags = Qt::ItemIsSelectable|Qt::ItemIsDragEnabled|Qt::ItemIsDropEnabled; if( (modifiers & o_readonly) != o_readonly ) { flags |= (Qt::ItemIsEnabled|Qt::ItemIsEditable); } if( (modifiers & o_singleton) == o_singleton ) { QBrush b (Qt::darkGray); pItem->setForeground( 0 , b ); pItem->setText(0, nameOf(a_Data.type()).c_str()); QFont font = pItem->font(0); font.setBold(true); pItem->setFont( 0, font ); } pItem->setFlags(flags); } }
void ClassTypeVisualizerNode::expand( VariableNode* a_pParentNode, const vector<reflection::Expression*>& a_LeftExpressions, reflection::ClassType* a_pClassType) const { // Public Value Members (Properties and InstanceAttributes { auto it = a_pClassType->beginValueMembers(); auto end = a_pClassType->endValueMembers(); for(;it != end;++it) { reflection::ValueMember* pValueMember = *it; if(!m_Filter(a_pParentNode, pValueMember)) continue; vector<reflection::Expression*> expressions; for(auto it = a_LeftExpressions.begin(); it != a_LeftExpressions.end(); ++it) { reflection::Expression* pLeftExpression = *it; expressions.push_back(cplusplus()->qualifiedLookup(pLeftExpression->clone(), pValueMember->getName(), nullptr, nullptr, 0)->asExpression()); } VariableNode* pVariableNode = o_new(VariableNode)(nameOf(pValueMember), expressions); pVariableNode->setIcon(QIcon(iconOf(pValueMember).c_str())); pVariableNode->setRange(pValueMember->getRange()); pVariableNode->setModifiers(pValueMember->getModifiers()); a_pParentNode->addChildNode(pVariableNode); } } }
static OMX_ERRORTYPE os_register_type (tiz_os_t * ap_os, const tiz_os_type_init_f a_type_init_f, const char * a_type_name, const OMX_S32 a_type_id) { OMX_ERRORTYPE rc = OMX_ErrorInsufficientResources; void * p_obj = NULL; assert (ap_os); assert (ap_os->p_map); assert (a_type_init_f); assert (a_type_name); assert (strnlen (a_type_name, OMX_MAX_STRINGNAME_SIZE) < OMX_MAX_STRINGNAME_SIZE); assert (a_type_id >= 0); /* Call the type init function */ p_obj = a_type_init_f (ap_os, ap_os->p_hdl); if (p_obj) { /* Register the class or object type */ TIZ_TRACE (ap_os->p_hdl, "Registering type #[%d] : [%s] -> [%p] " "nameOf [%s]", a_type_id, a_type_name, p_obj, nameOf (p_obj)); rc = tiz_map_insert (ap_os->p_map, os_strndup (ap_os->p_soa, a_type_name, OMX_MAX_STRINGNAME_SIZE), p_obj, (OMX_U32 *) (&a_type_id)); } /* print_types (ap_os); */ return rc; }
void DataTreeView::addNodeItem( serialization::Node* a_pNode ) { DataTreeViewItem* pNewItem = new DataTreeViewItem(m_pDataBase, a_pNode->getGuid()); if(a_pNode->getParentNode()) { serialization::Node* pNodeNode = a_pNode->getParentNode(); DataTreeViewItem* pParentItem = getItem(pNodeNode); o_assert(pParentItem); pParentItem->addChild(pNewItem); } else { addTopLevelItem(pNewItem); } const string* values = getDataBase()->getNodeAttributeValues(a_pNode); bool editable = false; string name = values[m_uiNameAttributeIndex]; pNewItem->setText(0, name.c_str()); pNewItem->setIcon(0, a_pNode->isLoaded() ? a_pNode->getParentNode() ? m_NodeLoadedIcon : m_NodeRootIcon : QIcon(m_NodeUnloadedIcon.pixmap(16, QIcon::Disabled))); char buffer[64] = ""; sprintf(buffer, "%08X", m_pDataBase->getGuid(a_pNode)); pNewItem->setText(2, buffer); pNewItem->setText(3, nameOf(phantom::typeOf<serialization::Node>()).c_str()); if(editable) { pNewItem->setFlags(Qt::ItemIsEditable | pNewItem->flags()); } sortItems(0, Qt::AscendingOrder); }
void DataTreeView::addDataItem( const phantom::data& a_Data ) { DataTreeViewItem* pNewItem = new DataTreeViewItem(m_pDataBase, m_pDataBase->getGuid(a_Data)); pNewItem->setIcon(0, QIcon(iconOf(a_Data.type()).c_str())); const phantom::data& ownerData = getDataBase()->getComponentDataOwner(a_Data); if(ownerData.isNull()) { serialization::Node* pDataNode = getDataBase()->getNode(a_Data); DataTreeViewItem* pNodeItem = getItem(pDataNode); o_assert(pNodeItem); pNodeItem->addChild(pNewItem); pNodeItem->setExpanded(true); } else { DataTreeViewItem* pDataItem = getItem(ownerData); o_assert(pDataItem) pDataItem->addChild(pNewItem); } const string* values = m_pDataBase->getDataAttributeValues(a_Data); bool editable = false; dataAttributeValueChanged(a_Data, m_uiNameAttributeIndex, values[m_uiNameAttributeIndex]); dataModifiersChanged(a_Data, m_pDataBase->getDataModifiers(a_Data)); char buffer[64] = ""; sprintf(buffer, "%08X", m_pDataBase->getGuid(a_Data)); pNewItem->setText(2, buffer); pNewItem->setText(3, nameOf(a_Data.type()).c_str()); }
string CompositionRemoveComponentDataCommand::generateComponentName( serialization::DataBase* a_pDataBase, phantom::data a_Component ) { void* pAddress = a_Component.address(); reflection::Expression* pCompositionExpression = phantom::expressionByName(m_strCompositionExpression); reflection::CompositionClass* pCompositionClass = as<reflection::CompositionClass*>(pCompositionExpression->getValueType()->removeReference()->removeConst()); return nameOf(pCompositionExpression->getHatchedElement()->asNamedElement())+" - "+lexical_cast<string>(pCompositionClass->indexOf(pCompositionExpression->loadEffectiveAddress(), &pAddress)); }
bool ProcValue::getBoolValue( int lin, int col ) { cout << "(!) At " << lin << ":" << col << " : cannot get " << nameOf( Value_BoolValue ) << " from the procedure value defined at " << line << ":" << column << endl; exit( 1 ); }
void DataTreeView::nodeAdded( serialization::Node* a_pNode,serialization::Node* a_pParentNode) { o_connect(a_pNode, loaded(), this, nodeLoaded()); o_connect(a_pNode, aboutToBeUnloaded(), this, nodeAboutToBeUnloaded()); string name = nameOf(typeOf<serialization::Node>()).c_str(); // m_pDataBase->setNodeAttributeValue(a_pNode, m_uiNameAttributeIndex, name); addNodeItem(a_pNode); }
void DataTreeView::dataReloaded(const phantom::data& a_New, phantom::serialization::Node*) { DataTreeViewItem* pItem = getItem(a_New); o_assert(pItem); pItem->setText(3, nameOf(a_New.type()).c_str()); dataModifiersChanged(a_New, m_pDataBase->getDataModifiers(a_New)); update(); }
void Association::printOn( ostream& outputStream ) const { outputStream << " " << nameOf() << " { "; aKey.printOn( outputStream ); outputStream << ", "; aValue.printOn( outputStream ); outputStream << " }\n"; }
void ProcValue::setValue( bool b, int lin, int col ) { cout << "(!) At " << lin << ":" << col << " : cannot set " << nameOf( Value_BoolValue ) << " to the procedure value defined at " << line << ":" << column << endl; exit( 1 ); }
void BoolCell::setValue( int i, int lin, int col ) { cout << "(!) At " << lin << ":" << col << " : cannot set " << nameOf( Value_IntValue ) << " to the boolean cell defined at " << line << ":" << column << endl; exit( 1 ); }
int BoolCell::getIntValue( int lin, int col ) { cout << "(!) At " << lin << ":" << col << " : cannot get " << nameOf( Value_IntValue ) << " from the boolean cell defined at " << line << ":" << column << endl; exit( 1 ); }
void IntCell::setValue( bool b, int lin, int col ) { cout << "(!) At " << lin << ":" << col << " : cannot set " << nameOf( Value_BoolValue ) << " to the integer cell defined at " << line << ":" << column << endl; exit( 1 ); }
bool IntCell::getBoolValue( int lin, int col ) { cout << "(!) At " << lin << ":" << col << " : cannot get " << nameOf( Value_BoolValue ) << " from the integer cell defined at " << line << ":" << column << endl; exit( 1 ); }
void IntValue::setValue( int i, int lin, int col ) { cout << "(!) At " << lin << ":" << col << " : cannot set " << nameOf( Value_IntValue ) << " to the integer value defined at " << line << ":" << column << endl; exit( 1 ); }
void DataTreeView::dataAdded( const phantom::data& a_Data, serialization::Node* a_pNode) { DataTreeViewItem* pParentItem = getItem(a_pNode); o_assert(pParentItem); string name = nameOf(a_Data.type()).c_str(); addDataItem(a_Data); sortItems(0, Qt::AscendingOrder); }
Value* Call::interpret( SymbolTable t ) { Value* look_up = t.lookUp( ID, line, column ); if ( look_up == NULL ) { cout << "(!) Expected " << nameOf( Value_ProcValue ) << " at " << line << ":" << column << " but found " << nameOf( Value_Undefined ) << endl; exit( 1 ); } if ( look_up->value_type != Value_ProcValue ) { cout << "(!) Expected " << nameOf( Value_ProcValue ) << " at " << line << ":" << column << " but found " << nameOf( look_up->value_type ) << endl; exit( 1 ); } ProcValue* value = dynamic_cast<ProcValue*>( look_up ); list<Value*> arguments; for ( Expr* arg : args ) { Value* v = arg->interpret( t ); arguments.push_back( v ); } if ( value->params.size() != arguments.size() ) { cout << "(!) The number of parameters does not match the number of arguments of " << ID << " at " << line << ":" << column << endl; exit( 1 ); } t.enterTable( ID, line, column ); call( value->params, value->block, arguments, t ); t.exitTable(); return NULL; }
void Call::call( list<Param*> params, Block* block, list<Value*> args, SymbolTable t ) { if ( params.empty() && args.empty() ) block->interpret( t ); else { Param* par = params.front(); Value* arg = args.front(); params.pop_front(); args.pop_front(); if ( par->node_type == Node_ValParam ) { ValParam* param = dynamic_cast<ValParam*>( par ); if ( param->data_type == IntType ) t.bind( param->ID, param->line, param->column, new IntCell( arg->getIntValue( arg->line, arg->column ), param->line, param->column ) ); else t.bind( param->ID, param->line, param->column, new BoolCell( arg->getBoolValue( arg->line, arg->column ), param->line, param->column ) ); } else { VarParam* param = dynamic_cast<VarParam*>( par ); if ( param->data_type == IntType && arg->value_type == Value_IntCell ) t.bind( param->ID, param->line, param->column, dynamic_cast<IntCell*>( arg ) ); else if ( param->data_type == BoolType && arg->value_type == Value_BoolCell ) t.bind( param->ID, param->line, param->column, dynamic_cast<BoolCell*>( arg ) ); else { cout << "(!) Cannot pass " << nameOf( arg->value_type ) << " " << ID << " defined at " << arg->line << ":" << arg->column << " to a parameter of type " << nameOf( param->data_type ) << " at " << param->line << ":" << param->column << endl; exit( 1 ); } } call( params, block, args, t ); } }
//===----------------------------------------------------------------------===// // Match current token's type with each standard statement structure // If it's matched, advance and return the old token //===----------------------------------------------------------------------===// Token Parser::match( int tokenType ) { if ( check( tokenType ) ) return advance(); else { //Strategy 1: print error and end -- used //Strategy 2: ptint error and return the expected Token with empty lexeme //Strategy 3: keep skipping over the rest of the Tokens until found the expected Token cout << "(!) Expected " << nameOf( tokenType ) << " at " << token.line << ":" << token.column << endl; //Token t = *new Token(); //return t; exit( 1 ); } }
Value* Assign::interpret( SymbolTable t ) { Value* lhs = t.lookUp( ID, line, column ); Value* rhs = expr->interpret( t ); if ( lhs->value_type == Value_IntCell ) lhs->setValue( rhs->getIntValue( rhs->line, rhs->column ), lhs->line, lhs->column ); else if ( lhs->value_type == Value_BoolCell ) lhs->setValue( rhs->getBoolValue( rhs->line, rhs->column ), lhs->line, lhs->column ); else { cout << "(!) Cannot perform assignment on " << ID << " at " << line << ":" << column << " because it is " << nameOf( lhs->value_type ) << endl; exit( 1 ); } return NULL; }
void Association::printOn( ostream& outputStream ) const // Summary ----------------------------------------------------------------- // // Displays the contents of this association object. // // Parameters // // outputStream // // The stream on which we are to display the association. // // End --------------------------------------------------------------------- { outputStream << " " << nameOf() << " { "; aKey.printOn( outputStream ); outputStream << ", "; aValue.printOn( outputStream ); outputStream << " }\n"; }
void DataTreeView::dataAttributeValueChanged( const phantom::data& a_Data, size_t a_uiAttributeIndex, const string& a_strValue ) { if(m_bEditorOpened) { QObject::disconnect(this, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(slotItemChanged(QTreeWidgetItem*,int))); } DataTreeViewItem* pItem = getItem(a_Data); if(pItem != NULL) { if(a_uiAttributeIndex == m_uiNameAttributeIndex) { if(a_strValue.empty()) { pItem->setText(0, nameOf(a_Data.type()).c_str()); } else pItem->setText(0, a_strValue.c_str()); } } if(m_bEditorOpened) { QObject::connect(this, SIGNAL(itemChanged(QTreeWidgetItem*,int)), this, SLOT(slotItemChanged(QTreeWidgetItem*,int))); } }
string ComponentVariableNodeDelegate::valueText() const { VariableModel* pVariableModel = m_pVariableNode->getVariableModel(); reflection::ComponentClass* pComponentClass = m_pVariableNode->getValueType()->removeConstReference()->asComponentClass(); std::set<reflection::Class*> currentClasses; size_t count = m_pVariableNode->getExpressionCount(); for(size_t i = 0; i<count; ++i) { void* pOldValue = nullptr; pComponentClass->get(m_pVariableNode->getExpression(i)->loadEffectiveAddress(), &pOldValue); currentClasses.insert(classOf(pOldValue)); } if(currentClasses.size() == 1) { reflection::Class* pClass = *currentClasses.begin(); if(pClass) { return nameOf(pClass); } return "none"; } return "<multiple values>"; }
void FlagsVisualizerNode::expand( VariableNode* a_pParent, const vector<reflection::Expression*>& a_LeftExpressions ) const { map<reflection::Constant*, vector<reflection::Expression*>> flagsExpressions; for(auto it = a_LeftExpressions.begin(); it != a_LeftExpressions.end(); ++it) { reflection::Expression* pLeftExpression = *it; if(NOT(pLeftExpression->hasEffectiveAddress())) continue; reflection::Enum* pEnum = pLeftExpression->getValueType()->removeReference()->removeConst()->getOwner()->asTemplateSpecialization()->getArgument("Enum")->asEnum(); for(size_t i = 0; i<pEnum->getConstantCount(); ++i) { flagsExpressions[pEnum->getConstant(i)].push_back( cplusplus()->qualifiedLookup( cplusplus()->solveBinaryOperator("[]", pLeftExpression->clone(), o_new(reflection::ConstantExpression)(pEnum->getConstant(i))) , "value", nullptr, nullptr, 0)->asExpression() ); } } for(auto it = flagsExpressions.begin(); it != flagsExpressions.end(); ++it) { VariableNode* pNode = o_new(VariableNode)(nameOf(it->first), it->second); pNode->setIcon(QIcon(iconOf(it->first).c_str())); a_pParent->addChildNode(pNode); } }
void Container::printHeader( ostream& outputStream ) const { outputStream << nameOf() << " {\n "; }