From 5e81cef9f026a9f22cfc7f6644dafe9abaa726b1 Mon Sep 17 00:00:00 2001 From: johnvg Date: Tue, 1 Mar 2011 15:20:47 +0000 Subject: in BEConstructorSymbol store constructor index in symb_arity until BERecordType is called, instead of scanning all constructors to find it in BERecordType, (should be passed directly to BERecordType) git-svn-id: https://svn.cs.ru.nl/repos/clean-compiler/trunk@1870 1f8540f1-abd5-4d5b-9d24-4c5ce8603e2d --- backendC/CleanCompilerSources/backend.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/backendC/CleanCompilerSources/backend.c b/backendC/CleanCompilerSources/backend.c index aec28af..5de268d 100644 --- a/backendC/CleanCompilerSources/backend.c +++ b/backendC/CleanCompilerSources/backend.c @@ -1055,8 +1055,11 @@ BEConstructorSymbol (int constructorIndex, int moduleIndex) constructorSymbol = module->bem_constructors [constructorIndex]; /* RWS +++ hack for record constructors, remove this */ - if (constructorSymbol->symb_kind == erroneous_symb) - return (constructorSymbol); + if (constructorSymbol->symb_kind == erroneous_symb){ + /* store index in symb_arity until BERecordType is called, should be passed directly to BERecordType */ + constructorSymbol->symb_arity = constructorIndex; + return constructorSymbol; + } Assert (constructorSymbol->symb_kind == definition || constructorSymbol->symb_kind == cons_symb || (moduleIndex == kPredefinedModuleIndex && constructorSymbol->symb_kind != erroneous_symb)); @@ -2892,20 +2895,21 @@ BERecordType (int moduleIndex, BEFlatTypeP lhs, BETypeNodeP constructorType, int sdef->sdef_arity = constructorType->type_node_arity; sdef->sdef_boxed_record = is_boxed_record; - - // +++ change this - { - int i; - BEModuleP module; - module = &gBEState.be_modules [moduleIndex]; - - for (i = 0; i < module->bem_nConstructors; i++) - if (module->bem_constructors [i] == constructorType->type_node_symbol) - break; + { + int constructor_index; + struct symbol *constructor_symbol_p; + BEModuleP module; + + constructor_symbol_p = constructorType->type_node_symbol; + /* BEConstructorSymbol has stored the index in symb_arity, should be passed directly to BERecordType */ + constructor_index = constructor_symbol_p->symb_arity; + constructor_symbol_p->symb_arity = 0; - Assert (i < module->bem_nConstructors); - module->bem_constructors [i] = type->type_lhs->ft_symbol; + module = &gBEState.be_modules [moduleIndex]; + + Assert (module->bem_constructors[constructor_index]==constructor_symbol_p); + module->bem_constructors[constructor_index] = type->type_lhs->ft_symbol; } } /* BERecordType */ -- cgit v1.2.3