#include "stdafx.h" #include #include /* TODO: 消す bool Variable::IsEqualSymbol( const Symbol &symbol, bool isSupportStaticMember ) const { if( GetName() == symbol.GetName() && compiler.GetNamespaceSupporter().IsSameAreaNamespace( this->GetNamespaceScopes(), symbol.GetNamespaceScopes() ) ) { return true; } if( isSupportStaticMember && symbol.GetNamespaceScopes().size() >= 1 ) { // 静的メンバを考慮 NamespaceScopes namespaceScopes( symbol.GetNamespaceScopes() ); string name = namespaceScopes[namespaceScopes.size()-1] + "." + symbol.GetName(); namespaceScopes.pop_back(); return IsEqualSymbol( Symbol( namespaceScopes, name ), false ); } return false; }*/ bool Variables::DuplicateCheck( const Symbol &symbol ) const { //レキシカルスコープを考慮して重複判定 for( int i=(int)this->size()-1; i>=0 ; i-- ){ const Variable *pVar = (*this)[i]; if( pVar->isLiving //現在のスコープで有効なもの && pVar->GetScopeLevel() == compiler.codeGenerator.lexicalScopes.GetNowLevel() //現在のスコープと同一レベル ) { if( pVar->IsEqualSymbol( symbol ) ){ return true; } } } return false; } const Variable *Variables::BackSearch( const Symbol &symbol ) const { //レキシカルスコープを考慮してバックサーチ for( int i=(int)this->size()-1; i>=0 ; i-- ){ const Variable *pVar = (*this)[i]; if( pVar->isLiving //現在のスコープで有効なもの && pVar->GetScopeLevel() <= compiler.codeGenerator.lexicalScopes.GetNowLevel() //現在のスコープレベルを超さないもの(Returnによる解放処理中を考慮) ){ if( pVar->IsEqualSymbol( symbol ) ){ return pVar; } } } return NULL; } const Variable *Variables::Find( const Symbol &symbol )const { int max = (int)this->size(); for( int i=0; iIsEqualSymbol( symbol ) ){ return pVar; } } return NULL; } void GlobalVars::Add( Variable *pVar, bool isResetOffsetAddress ) { int alignment = 0; if( pVar->GetType().IsStruct() ){ alignment = pVar->GetType().GetClass().GetFixedAlignment(); } if( pVar->HasInitData() ){ //初期バッファがあるとき if( isResetOffsetAddress ) { if( alignment ){ if( initAreaBuffer.GetSize() % alignment ){ initAreaBuffer.Resize( initAreaBuffer.GetSize() + ( alignment - (initAreaBuffer.GetSize() % alignment) ) ); } } pVar->SetOffsetAddress( initAreaBuffer.GetSize() ); initAreaBuffer.Resize( initAreaBuffer.GetSize() + pVar->GetMemorySize() ); } } else{ //初期バッファがないとき if( alignment ){ if( allSize % alignment ){ allSize += alignment - (allSize % alignment); } } pVar->SetOffsetAddress( allSize | 0x80000000 ); allSize += pVar->GetMemorySize(); } push_back( pVar ); }