#include "stdafx.h" #include #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-- ){ Variable &var = *(*this)[i]; if( var.bLiving //現在のスコープで有効なもの && var.GetScopeLevel() == compiler.codeGenerator.lexicalScopes.GetNowLevel() //現在のスコープと同一レベル ) { if( var.IsEqualSymbol( symbol ) ){ return true; } } } return false; } const Variable *Variables::BackSearch( const Symbol &symbol ) const { //レキシカルスコープを考慮してバックサーチ for( int i=(int)this->size()-1; i>=0 ; i-- ){ Variable &var = *(*this)[i]; if( var.bLiving //現在のスコープで有効なもの && var.GetScopeLevel() <= compiler.codeGenerator.lexicalScopes.GetNowLevel() //現在のスコープレベルを超さないもの(Returnによる解放処理中を考慮) ){ if( var.IsEqualSymbol( symbol ) ){ return &var; } } } 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 Variables::Add( Variable *pVar, bool isResetOffsetAddress ) { int alignment = 0; if( pVar->GetType().IsStruct() ){ alignment = pVar->GetType().GetClass().GetFixedAlignment(); } if( pVar->HasInitData() ){ //初期バッファがあるとき if( alignment ){ if( allInitSize % alignment ){ allInitSize += alignment - (allInitSize % alignment); } } if( isResetOffsetAddress ) { pVar->SetOffsetAddress( allInitSize ); } allInitSize += pVar->GetMemorySize(); } else{ //初期バッファがないとき if( alignment ){ if( allSize % alignment ){ allSize += alignment - (allSize % alignment); } } if( !isResetOffsetAddress ) { Jenga::Throw( "[Variables::Add] 初期バッファがない変数に対してisResetOffsetAddressをfalseにできない" ); } pVar->SetOffsetAddress( allSize | 0x80000000 ); allSize += pVar->GetMemorySize(); } push_back( pVar ); }