Changeset 4554 for trunk/compiler

Show
Ignore:
Timestamp:
10/31/08 14:39:41 (2 months ago)
Author:
pmoura
Message:

Added an auxiliary predicate for reversing the entity prefix used in the compiled code, returning the entity identifier. This predicate is used in error handling.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/compiler/logtalk.pl

    r4553 r4554  
    343343 
    344344'$lgt_runtime_error_handler'(error(existence_error(procedure, TFunctor/8), _)) :- 
    345     once((  atom_concat(ObjArity, '__idcl', TFunctor) 
    346         ;   atom_concat(ObjArity, '__dcl', TFunctor) 
     345    once((  atom_concat(Prefix, '_idcl', TFunctor) 
     346        ;   atom_concat(Prefix, '_dcl', TFunctor) 
    347347    )), 
    348     atom_chars(ObjArity, ObjArityChars), 
    349     '$lgt_append'(FunctorChars, ['_', ArityChar| ArityChars], ObjArityChars), 
    350     catch(number_chars(Arity, [ArityChar| ArityChars]), _, fail), 
    351     atom_chars(Functor, FunctorChars), 
    352     functor(Obj, Functor, Arity), 
     348    '$lgt_reverse_entity_prefix'(Prefix, Obj), 
    353349    (   '$lgt_instantiates_class_'(_, Obj, _) 
    354350    ;   '$lgt_specializes_class_'(_, Obj, _) 
    355351    ;   '$lgt_extends_object_'(_, Obj, _) 
     352    ;   '$lgt_complemented_object_'(Obj, _, _, _, _) 
    356353    ), 
    357354    \+ '$lgt_current_object_'(Obj, _, _, _, _, _, _, _, _, _, _), 
     
    359356 
    360357'$lgt_runtime_error_handler'(error(existence_error(procedure, TFunctor/7), _)) :- 
    361     atom_concat(CtgOrPtc, '_0__dcl', TFunctor), 
     358    atom_concat(Prefix, '_dcl', TFunctor), 
     359    '$lgt_reverse_entity_prefix'(Prefix, CtgOrPtc), 
    362360    (   '$lgt_implements_protocol_'(_, CtgOrPtc, _), \+ '$lgt_current_protocol_'(CtgOrPtc, _, _, _, _) -> 
    363361        throw(error(existence_error(protocol, CtgOrPtc), _, _)) 
     
    1120111199 
    1120211200 
     11201% '$lgt_reverse_entity_prefix'(+atom, -entity_identifier) 
     11202% 
     11203% reverses the entity prefix used in the compiled code 
     11204 
     11205'$lgt_reverse_entity_prefix'(Prefix, Entity) :- 
     11206    '$lgt_compiler_flag'(code_prefix, CodePrefix), 
     11207    atom_concat(CodePrefix, NameUnderscoreArityUnderscore, Prefix), 
     11208    atom_concat(NameUnderscoreArity, '_', NameUnderscoreArityUnderscore), 
     11209    '$lgt_split_name_arity'(NameUnderscoreArity, Name, Arity), 
     11210    functor(Entity, Name, Arity), 
     11211    !. 
     11212 
     11213 
     11214'$lgt_split_name_arity'(NameUnderscoreArity, Name, Arity) :- 
     11215    atom_codes(NameUnderscoreArity, Codes), 
     11216    '$lgt_reverse'(Codes, [], RCodes), 
     11217    '$lgt_find_arity_codes'(RCodes, [], ArityCodes), 
     11218    number_codes(Arity, ArityCodes), 
     11219    atom_codes(ArityAtom, ArityCodes), 
     11220    atom_concat(NameUnderscore, ArityAtom, NameUnderscoreArity), 
     11221    atom_concat(Name, '_', NameUnderscore). 
     11222 
     11223 
     11224'$lgt_find_arity_codes'([Code| Codes], Acc, ArityCodes) :- 
     11225    (   char_code('_', Code) -> 
     11226        ArityCodes = Acc 
     11227    ;   '$lgt_find_arity_codes'(Codes, [Code| Acc], ArityCodes) 
     11228    ). 
     11229 
     11230 
     11231'$lgt_reverse'([], Reversed, Reversed). 
     11232'$lgt_reverse'([Head| Tail], List, Reversed) :- 
     11233    '$lgt_reverse'(Tail, [Head| List], Reversed). 
     11234 
     11235 
     11236 
    1120311237% '$lgt_construct_predicate_indicator'(+atom, +predicate_indicator, -predicate_indicator) 
    1120411238%