Skip to content

Commit

Permalink
HLineRunner: Find dependend symbols (class members) based on class co…
Browse files Browse the repository at this point in the history
…nstructor function.
  • Loading branch information
AmokHuginnsson committed Jan 16, 2019
1 parent c5338b7 commit 5592868
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 18 deletions.
32 changes: 16 additions & 16 deletions src/interactive.cxx
Expand Up @@ -162,25 +162,25 @@ HLineRunner::words_t completion_words( yaal::hcore::HString&& context_, yaal::hc
}
if ( symbol.is_empty() ) {
completions.push_back( dot + w );
} else {
buf.assign( symbol ).append( dot ).append( w );
HString const& doc( repl->line_runner()->doc( tn + w, true ) );
if ( ! doc.is_empty() ) {
int offset( 0 );
if ( doc.front() == '*' ) {
offset += 2;
}
offset += static_cast<int>( w.get_length() );
if ( ( offset < doc.get_length() ) && ( doc[offset] == '(' ) ) {
buf.append( "(" );
++ offset;
if ( ( offset < doc.get_length() ) && ( doc[offset] == ')' ) ) {
buf.append( ")" );
}
continue;
}
buf.assign( symbol ).append( dot ).append( w );
HString const& doc( repl->line_runner()->doc( tn + w, true ) );
if ( ! doc.is_empty() ) {
int offset( 0 );
if ( doc.front() == '*' ) {
offset += 2;
}
offset += static_cast<int>( w.get_length() );
if ( ( offset < doc.get_length() ) && ( doc[offset] == '(' ) ) {
buf.append( "(" );
++ offset;
if ( ( offset < doc.get_length() ) && ( doc[offset] == ')' ) ) {
buf.append( ")" );
}
}
completions.push_back( buf );
}
completions.push_back( buf );
}
} while ( false );
sort( completions.begin(), completions.end() );
Expand Down
17 changes: 15 additions & 2 deletions src/linerunner.cxx
Expand Up @@ -420,6 +420,19 @@ yaal::hcore::HString HLineRunner::doc( yaal::hcore::HString const& symbol_, bool
M_EPILOG
}

yaal::tools::HHuginn::HClass const* HLineRunner::symbol_type_id( yaal::tools::HHuginn::value_t const& value_ ) {
M_PROLOG
HHuginn::HClass const* c( value_->get_class() );
if ( c->type_id() == HHuginn::TYPE::FUNCTION_REFERENCE ) {
HHuginn::HClass const* juncture( static_cast<HHuginn::HFunctionReference const*>( value_.raw() )->juncture() );
if ( !! juncture ) {
c = juncture;
}
}
return ( c );
M_EPILOG
}

yaal::tools::HHuginn::HClass const* HLineRunner::symbol_type_id( yaal::hcore::HString const& symbol_ ) {
M_PROLOG
if ( symbol_.is_empty() ) {
Expand All @@ -438,7 +451,7 @@ yaal::tools::HHuginn::HClass const* HLineRunner::symbol_type_id( yaal::hcore::HS
if ( vv.name() == symbol_ ) {
HHuginn::value_t v( vv.value() );
if ( !! v ) {
c = v->get_class();
c = symbol_type_id( v );
found = true;
}
break;
Expand All @@ -449,7 +462,7 @@ yaal::tools::HHuginn::HClass const* HLineRunner::symbol_type_id( yaal::hcore::HS
if ( add_line( symbol_ ) ) {
HHuginn::value_t res( execute() );
if ( !! res ) {
c = res->get_class();
c = symbol_type_id( res );
undo();
_huginn->reset( 1 );
found = true;
Expand Down
1 change: 1 addition & 0 deletions src/linerunner.hxx
Expand Up @@ -73,6 +73,7 @@ protected:
virtual void do_introspect( yaal::tools::HIntrospecteeInterface& ) override;
private:
void prepare_source( void );
yaal::tools::HHuginn::HClass const* symbol_type_id( yaal::tools::HHuginn::value_t const& );
};

}
Expand Down

0 comments on commit 5592868

Please sign in to comment.