diff options
Diffstat (limited to 'src/analysis/scan/exprs')
-rw-r--r-- | src/analysis/scan/exprs/access-int.h | 2 | ||||
-rw-r--r-- | src/analysis/scan/exprs/access.c | 11 | ||||
-rw-r--r-- | src/analysis/scan/exprs/arithmetic.c | 9 | ||||
-rw-r--r-- | src/analysis/scan/exprs/call.c | 4 | ||||
-rw-r--r-- | src/analysis/scan/exprs/counter.c | 9 | ||||
-rw-r--r-- | src/analysis/scan/exprs/handler.c | 13 | ||||
-rw-r--r-- | src/analysis/scan/exprs/intersect.c | 4 | ||||
-rw-r--r-- | src/analysis/scan/exprs/item.c | 9 | ||||
-rw-r--r-- | src/analysis/scan/exprs/literal.c | 9 | ||||
-rw-r--r-- | src/analysis/scan/exprs/logical.c | 9 | ||||
-rw-r--r-- | src/analysis/scan/exprs/range.c | 17 | ||||
-rw-r--r-- | src/analysis/scan/exprs/relational.c | 9 | ||||
-rw-r--r-- | src/analysis/scan/exprs/set-int.h | 4 | ||||
-rw-r--r-- | src/analysis/scan/exprs/set.c | 36 | ||||
-rw-r--r-- | src/analysis/scan/exprs/set.h | 2 | ||||
-rw-r--r-- | src/analysis/scan/exprs/strop.c | 9 |
16 files changed, 110 insertions, 46 deletions
diff --git a/src/analysis/scan/exprs/access-int.h b/src/analysis/scan/exprs/access-int.h index 725051c..3216493 100644 --- a/src/analysis/scan/exprs/access-int.h +++ b/src/analysis/scan/exprs/access-int.h @@ -67,7 +67,7 @@ struct _GScanNamedAccessClass bool g_scan_named_access_create(GScanNamedAccess *, const sized_string_t *); /* Prépare une réduction en menant une résolution locale. */ -GRegisteredItem *_g_scan_named_access_prepare_reduction(GScanNamedAccess *, GScanContext *, GScanScope *); +GRegisteredItem *_g_scan_named_access_prepare_reduction(const GScanNamedAccess *, GScanContext *, GScanScope *); diff --git a/src/analysis/scan/exprs/access.c b/src/analysis/scan/exprs/access.c index a8f0dc9..0df46e6 100644 --- a/src/analysis/scan/exprs/access.c +++ b/src/analysis/scan/exprs/access.c @@ -59,7 +59,7 @@ static void g_scan_named_access_copy(GScanNamedAccess *, const GScanNamedAccess /* Réduit une expression à une forme plus simple. */ -static ScanReductionState g_scan_named_access_reduce(GScanNamedAccess *, GScanContext *, GScanScope *, GScanExpression **); +static ScanReductionState g_scan_named_access_reduce(const GScanNamedAccess *, GScanContext *, GScanScope *, GScanExpression **); @@ -214,11 +214,14 @@ bool g_scan_named_access_create(GScanNamedAccess *access, const sized_string_t * { bool result; /* Bilan à retourner */ - result = true; + result = g_scan_expression_create(G_SCAN_EXPRESSION(access), SRS_PENDING); + if (!result) goto exit; if (target != NULL) access->target = strndup(target->data, target->len); + exit: + return result; } @@ -369,7 +372,7 @@ void g_scan_named_access_attach_next(GScanNamedAccess *access, GScanNamedAccess * * ******************************************************************************/ -GRegisteredItem *_g_scan_named_access_prepare_reduction(GScanNamedAccess *expr, GScanContext *ctx, GScanScope *scope) +GRegisteredItem *_g_scan_named_access_prepare_reduction(const GScanNamedAccess *expr, GScanContext *ctx, GScanScope *scope) { GRegisteredItem *result; /* Etat synthétisé à retourner */ GRegisteredItem *base; /* Base de recherche courante */ @@ -423,7 +426,7 @@ GRegisteredItem *_g_scan_named_access_prepare_reduction(GScanNamedAccess *expr, * * ******************************************************************************/ -static ScanReductionState g_scan_named_access_reduce(GScanNamedAccess *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) +static ScanReductionState g_scan_named_access_reduce(const GScanNamedAccess *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) { ScanReductionState result; /* Etat synthétisé à retourner */ GRegisteredItem *resolved; /* Cible concrète obtenue */ diff --git a/src/analysis/scan/exprs/arithmetic.c b/src/analysis/scan/exprs/arithmetic.c index 0c01d2a..06cfc48 100644 --- a/src/analysis/scan/exprs/arithmetic.c +++ b/src/analysis/scan/exprs/arithmetic.c @@ -56,7 +56,7 @@ static void g_scan_arithmetic_operation_finalize(GScanArithmeticOperation *); static bool g_scan_arithmetic_operation_compare_rich(const GScanArithmeticOperation *, const GScanArithmeticOperation *, RichCmpOperation, bool *); /* Réduit une expression à une forme plus simple. */ -static ScanReductionState g_scan_arithmetic_operation_reduce(GScanArithmeticOperation *, GScanContext *, GScanScope *, GScanExpression **); +static ScanReductionState g_scan_arithmetic_operation_reduce(const GScanArithmeticOperation *, GScanContext *, GScanScope *, GScanExpression **); @@ -207,7 +207,8 @@ bool g_scan_arithmetic_operation_create(GScanArithmeticOperation *op, Arithmetic { bool result; /* Bilan à retourner */ - result = true; + result = g_scan_expression_create(G_SCAN_EXPRESSION(op), SRS_PENDING); + if (!result) goto exit; op->operator = operator; @@ -217,6 +218,8 @@ bool g_scan_arithmetic_operation_create(GScanArithmeticOperation *op, Arithmetic op->right = right; g_object_ref(G_OBJECT(op->right)); + exit: + return result; } @@ -290,7 +293,7 @@ static bool g_scan_arithmetic_operation_compare_rich(const GScanArithmeticOperat * * ******************************************************************************/ -static ScanReductionState g_scan_arithmetic_operation_reduce(GScanArithmeticOperation *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) +static ScanReductionState g_scan_arithmetic_operation_reduce(const GScanArithmeticOperation *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) { ScanReductionState result; /* Etat synthétisé à retourner */ GScanExpression *new_left; /* Expression réduite (gauche) */ diff --git a/src/analysis/scan/exprs/call.c b/src/analysis/scan/exprs/call.c index 83aff85..d9b2c13 100644 --- a/src/analysis/scan/exprs/call.c +++ b/src/analysis/scan/exprs/call.c @@ -55,7 +55,7 @@ static void g_scan_pending_call_finalize(GScanPendingCall *); /* Réduit une expression à une forme plus simple. */ -static ScanReductionState g_scan_pending_call_reduce(GScanPendingCall *, GScanContext *, GScanScope *, GScanExpression **); +static ScanReductionState g_scan_pending_call_reduce(const GScanPendingCall *, GScanContext *, GScanScope *, GScanExpression **); /* Reproduit un accès en place dans une nouvelle instance. */ static void g_scan_pending_call_copy(GScanPendingCall *, const GScanPendingCall *); @@ -260,7 +260,7 @@ bool g_scan_pending_call_create(GScanPendingCall *call, const sized_string_t *ta * * ******************************************************************************/ -static ScanReductionState g_scan_pending_call_reduce(GScanPendingCall *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) +static ScanReductionState g_scan_pending_call_reduce(const GScanPendingCall *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) { ScanReductionState result; /* Etat synthétisé à retourner */ GScanNamedAccess *access; /* Autre vision de l'expression*/ diff --git a/src/analysis/scan/exprs/counter.c b/src/analysis/scan/exprs/counter.c index bb4e523..7fadb91 100644 --- a/src/analysis/scan/exprs/counter.c +++ b/src/analysis/scan/exprs/counter.c @@ -50,7 +50,7 @@ static void g_scan_match_counter_finalize(GScanMatchCounter *); /* Réduit une expression à une forme plus simple. */ -static ScanReductionState g_scan_match_counter_reduce(GScanMatchCounter *, GScanContext *, GScanScope *, GScanExpression **); +static ScanReductionState g_scan_match_counter_reduce(const GScanMatchCounter *, GScanContext *, GScanScope *, GScanExpression **); @@ -195,11 +195,14 @@ bool g_scan_match_counter_create(GScanMatchCounter *counter, GSearchPattern *pat { bool result; /* Bilan à retourner */ - result = true; + result = g_scan_expression_create(G_SCAN_EXPRESSION(counter), SRS_WAIT_FOR_SCAN); + if (!result) goto exit; counter->pattern = pattern; g_object_ref(G_OBJECT(pattern)); + exit: + return result; } @@ -226,7 +229,7 @@ bool g_scan_match_counter_create(GScanMatchCounter *counter, GSearchPattern *pat * * ******************************************************************************/ -static ScanReductionState g_scan_match_counter_reduce(GScanMatchCounter *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) +static ScanReductionState g_scan_match_counter_reduce(const GScanMatchCounter *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) { ScanReductionState result; /* Etat synthétisé à retourner */ size_t count; /* Quantité de correspondances */ diff --git a/src/analysis/scan/exprs/handler.c b/src/analysis/scan/exprs/handler.c index a14140a..1676522 100644 --- a/src/analysis/scan/exprs/handler.c +++ b/src/analysis/scan/exprs/handler.c @@ -54,10 +54,10 @@ static void g_scan_pattern_handler_finalize(GScanPatternHandler *); /* Réduit une expression à une forme plus simple. */ -static ScanReductionState g_scan_pattern_handler_reduce(GScanPatternHandler *, GScanContext *, GScanScope *, GScanExpression **); +static ScanReductionState g_scan_pattern_handler_reduce(const GScanPatternHandler *, GScanContext *, GScanScope *, GScanExpression **); /* Réduit une expression à une forme booléenne. */ -static bool g_scan_pattern_handler_reduce_to_boolean(GScanPatternHandler *, GScanContext *, GScanScope *, GScanExpression **); +static bool g_scan_pattern_handler_reduce_to_boolean(const GScanPatternHandler *, GScanContext *, GScanScope *, GScanExpression **); /* Dénombre les éléments portés par une expression. */ static bool g_scan_pattern_handler_count_items(const GScanPatternHandler *, GScanContext *, size_t *); @@ -213,13 +213,16 @@ bool g_scan_pattern_handler_create(GScanPatternHandler *handler, GSearchPattern { bool result; /* Bilan à retourner */ - result = true; + result = g_scan_expression_create(G_SCAN_EXPRESSION(handler), SRS_WAIT_FOR_SCAN); + if (!result) goto exit; handler->pattern = pattern; g_object_ref(G_OBJECT(pattern)); handler->type = type; + exit: + return result; } @@ -246,7 +249,7 @@ bool g_scan_pattern_handler_create(GScanPatternHandler *handler, GSearchPattern * * ******************************************************************************/ -static ScanReductionState g_scan_pattern_handler_reduce(GScanPatternHandler *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) +static ScanReductionState g_scan_pattern_handler_reduce(const GScanPatternHandler *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) { ScanReductionState result; /* Etat synthétisé à retourner */ @@ -276,7 +279,7 @@ static ScanReductionState g_scan_pattern_handler_reduce(GScanPatternHandler *exp * * ******************************************************************************/ -static bool g_scan_pattern_handler_reduce_to_boolean(GScanPatternHandler *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) +static bool g_scan_pattern_handler_reduce_to_boolean(const GScanPatternHandler *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) { bool result; /* Bilan à retourner */ size_t count; /* Quantité de correspondances */ diff --git a/src/analysis/scan/exprs/intersect.c b/src/analysis/scan/exprs/intersect.c index f0660e0..c56d28c 100644 --- a/src/analysis/scan/exprs/intersect.c +++ b/src/analysis/scan/exprs/intersect.c @@ -53,7 +53,7 @@ static void g_scan_sets_intersection_finalize(GScanSetsIntersection *); /* Réduit une expression à une forme plus simple. */ -static ScanReductionState g_scan_sets_intersection_reduce(GScanSetsIntersection *, GScanContext *, GScanScope *, GScanExpression **); +static ScanReductionState g_scan_sets_intersection_reduce(const GScanSetsIntersection *, GScanContext *, GScanScope *, GScanExpression **); @@ -236,7 +236,7 @@ bool g_scan_sets_intersection_create(GScanSetsIntersection *inter, GScanExpressi * * ******************************************************************************/ -static ScanReductionState g_scan_sets_intersection_reduce(GScanSetsIntersection *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) +static ScanReductionState g_scan_sets_intersection_reduce(const GScanSetsIntersection *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) { ScanReductionState result; /* Etat synthétisé à retourner */ GScanExpression *new_first; /* Nouvelle réduction #1 */ diff --git a/src/analysis/scan/exprs/item.c b/src/analysis/scan/exprs/item.c index a6b22f0..b7cd970 100644 --- a/src/analysis/scan/exprs/item.c +++ b/src/analysis/scan/exprs/item.c @@ -53,7 +53,7 @@ static void g_scan_set_item_finalize(GScanSetItem *); /* Réduit une expression à une forme plus simple. */ -static ScanReductionState g_scan_set_item_reduce(GScanSetItem *, GScanContext *, GScanScope *, GScanExpression **); +static ScanReductionState g_scan_set_item_reduce(const GScanSetItem *, GScanContext *, GScanScope *, GScanExpression **); @@ -201,7 +201,8 @@ bool g_scan_set_item_create(GScanSetItem *item, GScanExpression *set, GScanExpre { bool result; /* Bilan à retourner */ - result = true; + result = g_scan_expression_create(G_SCAN_EXPRESSION(item), SRS_PENDING); + if (!result) goto exit; item->set = set; g_object_ref(G_OBJECT(set)); @@ -209,6 +210,8 @@ bool g_scan_set_item_create(GScanSetItem *item, GScanExpression *set, GScanExpre item->index = index; g_object_ref(G_OBJECT(index)); + exit: + return result; } @@ -235,7 +238,7 @@ bool g_scan_set_item_create(GScanSetItem *item, GScanExpression *set, GScanExpre * * ******************************************************************************/ -static ScanReductionState g_scan_set_item_reduce(GScanSetItem *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) +static ScanReductionState g_scan_set_item_reduce(const GScanSetItem *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) { ScanReductionState result; /* Etat synthétisé à retourner */ GScanExpression *new_set; /* Expression réduite (série) */ diff --git a/src/analysis/scan/exprs/literal.c b/src/analysis/scan/exprs/literal.c index 070c177..de7e32a 100644 --- a/src/analysis/scan/exprs/literal.c +++ b/src/analysis/scan/exprs/literal.c @@ -57,7 +57,7 @@ static void g_scan_literal_expression_finalize(GScanLiteralExpression *); static bool g_scan_literal_expression_compare_rich(const GScanLiteralExpression *, const GScanLiteralExpression *, RichCmpOperation, bool *); /* Réduit une expression à une forme booléenne. */ -static bool g_scan_literal_expression_reduce_to_boolean(GScanLiteralExpression *, GScanContext *, GScanScope *, GScanExpression **); +static bool g_scan_literal_expression_reduce_to_boolean(const GScanLiteralExpression *, GScanContext *, GScanScope *, GScanExpression **); /* Dénombre les éléments portés par une expression. */ static bool g_scan_literal_expression_count(const GScanLiteralExpression *, GScanContext *, size_t *); @@ -225,6 +225,9 @@ bool g_scan_literal_expression_create(GScanLiteralExpression *expr, LiteralValue char *tmp; /* Zone de travail temporaire */ int ret; /* Bilan d'une opération */ + result = g_scan_expression_create(G_SCAN_EXPRESSION(expr), SRS_REDUCED); + if (!result) goto exit; + va_start(ap, vtype); switch (vtype) @@ -312,6 +315,8 @@ bool g_scan_literal_expression_create(GScanLiteralExpression *expr, LiteralValue expr->value_type = vtype; + exit: + return result; } @@ -582,7 +587,7 @@ static bool g_scan_literal_expression_compare_rich(const GScanLiteralExpression * * ******************************************************************************/ -static bool g_scan_literal_expression_reduce_to_boolean(GScanLiteralExpression *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) +static bool g_scan_literal_expression_reduce_to_boolean(const GScanLiteralExpression *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) { bool result; /* Bilan à retourner */ diff --git a/src/analysis/scan/exprs/logical.c b/src/analysis/scan/exprs/logical.c index 4c82b1e..cc78a75 100644 --- a/src/analysis/scan/exprs/logical.c +++ b/src/analysis/scan/exprs/logical.c @@ -56,7 +56,7 @@ static void g_scan_logical_operation_finalize(GScanLogicalOperation *); static bool g_scan_logical_operation_compare_rich(const GScanLogicalOperation *, const GScanLogicalOperation *, RichCmpOperation, bool *); /* Réduit une expression à une forme plus simple. */ -static ScanReductionState g_scan_logical_operation_reduce(GScanLogicalOperation *, GScanContext *, GScanScope *, GScanExpression **); +static ScanReductionState g_scan_logical_operation_reduce(const GScanLogicalOperation *, GScanContext *, GScanScope *, GScanExpression **); @@ -207,6 +207,9 @@ bool g_scan_logical_operation_create(GScanLogicalOperation *op, BooleanOperation { bool result; /* Bilan à retourner */ + result = g_scan_expression_create(G_SCAN_EXPRESSION(op), SRS_PENDING); + if (!result) goto exit; + op->type = type; switch (type) @@ -236,6 +239,8 @@ bool g_scan_logical_operation_create(GScanLogicalOperation *op, BooleanOperation } + exit: + return result; } @@ -332,7 +337,7 @@ static bool g_scan_logical_operation_compare_rich(const GScanLogicalOperation *i * * ******************************************************************************/ -static ScanReductionState g_scan_logical_operation_reduce(GScanLogicalOperation *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) +static ScanReductionState g_scan_logical_operation_reduce(const GScanLogicalOperation *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) { ScanReductionState result; /* Etat synthétisé à retourner */ GScanExpression *new_first; /* Expression réduite (gauche) */ diff --git a/src/analysis/scan/exprs/range.c b/src/analysis/scan/exprs/range.c index f97b15e..9716149 100644 --- a/src/analysis/scan/exprs/range.c +++ b/src/analysis/scan/exprs/range.c @@ -50,13 +50,13 @@ static void g_scan_compact_range_finalize(GScanCompactRange *); /* Réduit une expression à une forme plus simple. */ -static ScanReductionState g_scan_compact_range_reduce(GScanCompactRange *, GScanContext *, GScanScope *, GScanExpression **); +static ScanReductionState g_scan_compact_range_reduce(const GScanCompactRange *, GScanContext *, GScanScope *, GScanExpression **); /* Réduit une expression à une forme booléenne. */ -static bool g_scan_compact_range_reduce_to_boolean(GScanCompactRange *, GScanContext *, GScanScope *, GScanExpression **); +static bool g_scan_compact_range_reduce_to_boolean(const GScanCompactRange *, GScanContext *, GScanScope *, GScanExpression **); /* Réalise l'intersection entre deux ensembles. */ -static GScanExpression *g_scan_compact_range_intersect(GScanCompactRange *expr, const GScanExpression *, GScanContext *, GScanScope *); +static GScanExpression *g_scan_compact_range_intersect(const GScanCompactRange *expr, const GScanExpression *, GScanContext *, GScanScope *); @@ -206,7 +206,8 @@ bool g_scan_compact_range_create(GScanCompactRange *range, GScanExpression *star { bool result; /* Bilan à retourner */ - result = true; + result = g_scan_expression_create(G_SCAN_EXPRESSION(range), SRS_PENDING); + if (!result) goto exit; range->start = start; g_object_ref(G_OBJECT(start)); @@ -214,6 +215,8 @@ bool g_scan_compact_range_create(GScanCompactRange *range, GScanExpression *star range->end = end; g_object_ref(G_OBJECT(end)); + exit: + return result; } @@ -240,7 +243,7 @@ bool g_scan_compact_range_create(GScanCompactRange *range, GScanExpression *star * * ******************************************************************************/ -static ScanReductionState g_scan_compact_range_reduce(GScanCompactRange *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) +static ScanReductionState g_scan_compact_range_reduce(const GScanCompactRange *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) { ScanReductionState result; /* Etat synthétisé à retourner */ GScanExpression *new_start; /* Nouvelle réduction #1 */ @@ -298,7 +301,7 @@ static ScanReductionState g_scan_compact_range_reduce(GScanCompactRange *expr, G * * ******************************************************************************/ -static bool g_scan_compact_range_reduce_to_boolean(GScanCompactRange *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) +static bool g_scan_compact_range_reduce_to_boolean(const GScanCompactRange *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) { bool result; /* Bilan à retourner */ bool status; /* Bilan d'une comparaison */ @@ -335,7 +338,7 @@ static bool g_scan_compact_range_reduce_to_boolean(GScanCompactRange *expr, GSca * * ******************************************************************************/ -static GScanExpression *g_scan_compact_range_intersect(GScanCompactRange *expr, const GScanExpression *other, GScanContext *ctx, GScanScope *scope) +static GScanExpression *g_scan_compact_range_intersect(const GScanCompactRange *expr, const GScanExpression *other, GScanContext *ctx, GScanScope *scope) { GScanExpression *result; /* Instance à retourner */ diff --git a/src/analysis/scan/exprs/relational.c b/src/analysis/scan/exprs/relational.c index b56b599..74a972b 100644 --- a/src/analysis/scan/exprs/relational.c +++ b/src/analysis/scan/exprs/relational.c @@ -56,7 +56,7 @@ static void g_scan_relational_operation_finalize(GScanRelationalOperation *); static bool g_scan_relational_operation_compare_rich(const GScanRelationalOperation *, const GScanRelationalOperation *, RichCmpOperation, bool *); /* Réduit une expression à une forme plus simple. */ -static ScanReductionState g_scan_relational_operation_reduce(GScanRelationalOperation *, GScanContext *, GScanScope *, GScanExpression **); +static ScanReductionState g_scan_relational_operation_reduce(const GScanRelationalOperation *, GScanContext *, GScanScope *, GScanExpression **); @@ -207,7 +207,8 @@ bool g_scan_relational_operation_create(GScanRelationalOperation *op, RichCmpOpe { bool result; /* Bilan à retourner */ - result = true; + result = g_scan_expression_create(G_SCAN_EXPRESSION(op), SRS_PENDING); + if (!result) goto exit; op->rel_type = type; @@ -217,6 +218,8 @@ bool g_scan_relational_operation_create(GScanRelationalOperation *op, RichCmpOpe op->right = right; g_object_ref(G_OBJECT(op->right)); + exit: + return result; } @@ -290,7 +293,7 @@ static bool g_scan_relational_operation_compare_rich(const GScanRelationalOperat * * ******************************************************************************/ -static ScanReductionState g_scan_relational_operation_reduce(GScanRelationalOperation *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) +static ScanReductionState g_scan_relational_operation_reduce(const GScanRelationalOperation *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) { ScanReductionState result; /* Etat synthétisé à retourner */ GScanExpression *new_left; /* Expression réduite (gauche) */ diff --git a/src/analysis/scan/exprs/set-int.h b/src/analysis/scan/exprs/set-int.h index ebb4380..10ca8d0 100644 --- a/src/analysis/scan/exprs/set-int.h +++ b/src/analysis/scan/exprs/set-int.h @@ -50,5 +50,9 @@ struct _GScanGenericSetClass }; +/* Met en place un ensemble d'éléments homogènes ou hétérogènes. */ +bool g_scan_generic_set_create(GScanGenericSet *); + + #endif /* _ANALYSIS_SCAN_EXPRS_SET_INT_H */ diff --git a/src/analysis/scan/exprs/set.c b/src/analysis/scan/exprs/set.c index d76af4d..438e7e3 100644 --- a/src/analysis/scan/exprs/set.c +++ b/src/analysis/scan/exprs/set.c @@ -54,10 +54,10 @@ static void g_scan_generic_set_finalize(GScanGenericSet *); /* Réduit une expression à une forme plus simple. */ -static ScanReductionState g_scan_generic_set_reduce(GScanGenericSet *, GScanContext *, GScanScope *, GScanExpression **); +static ScanReductionState g_scan_generic_set_reduce(const GScanGenericSet *, GScanContext *, GScanScope *, GScanExpression **); /* Réduit une expression à une forme booléenne. */ -static bool g_scan_generic_set_reduce_to_boolean(GScanGenericSet *, GScanContext *, GScanScope *, GScanExpression **); +static bool g_scan_generic_set_reduce_to_boolean(const GScanGenericSet *, GScanContext *, GScanScope *, GScanExpression **); /* Dénombre les éléments portés par une expression. */ static bool g_scan_generic_set_count_items(const GScanGenericSet *, GScanContext *, size_t *); @@ -178,7 +178,7 @@ static void g_scan_generic_set_finalize(GScanGenericSet *set) * * * Paramètres : - * * * -* Description : Met en place un ensemble d'éléments homogènes ou hétérogènes.* +* Description : Constitue un ensemble d'éléments homogènes ou hétérogènes. * * * * Retour : Expression mise en place. * * * @@ -192,6 +192,32 @@ GScanExpression *g_scan_generic_set_new(void) result = g_object_new(G_TYPE_SCAN_GENERIC_SET, NULL); + if (!g_scan_generic_set_create(G_SCAN_GENERIC_SET(result))) + g_clear_object(&result); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : set = instance à initialiser pleinement. * +* * +* Description : Met en place un ensemble d'éléments homogènes ou hétérogènes.* +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_scan_generic_set_create(GScanGenericSet *set) +{ + bool result; /* Bilan à retourner */ + + result = g_scan_expression_create(G_SCAN_EXPRESSION(set), SRS_PENDING); + return result; } @@ -241,7 +267,7 @@ void g_scan_generic_set_add_item(GScanGenericSet *set, GScanExpression *item) * * ******************************************************************************/ -static ScanReductionState g_scan_generic_set_reduce(GScanGenericSet *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) +static ScanReductionState g_scan_generic_set_reduce(const GScanGenericSet *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) { ScanReductionState result; /* Etat synthétisé à retourner */ size_t i; /* Boucle de parcours #1 */ @@ -312,7 +338,7 @@ static ScanReductionState g_scan_generic_set_reduce(GScanGenericSet *expr, GScan * * ******************************************************************************/ -static bool g_scan_generic_set_reduce_to_boolean(GScanGenericSet *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) +static bool g_scan_generic_set_reduce_to_boolean(const GScanGenericSet *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) { bool result; /* Bilan à retourner */ diff --git a/src/analysis/scan/exprs/set.h b/src/analysis/scan/exprs/set.h index f857ce9..c9fb3b3 100644 --- a/src/analysis/scan/exprs/set.h +++ b/src/analysis/scan/exprs/set.h @@ -47,7 +47,7 @@ typedef struct _GScanGenericSetClass GScanGenericSetClass; /* Indique le type défini pour une base d'ensembles d'éléments homogènes ou hétérogènes. */ GType g_scan_generic_set_get_type(void); -/* Met en place un ensemble d'éléments homogènes ou hétérogènes. */ +/* Constitue un ensemble d'éléments homogènes ou hétérogènes. */ GScanExpression *g_scan_generic_set_new(void); /* Ajoute un nouvel élément à un ensemble. */ diff --git a/src/analysis/scan/exprs/strop.c b/src/analysis/scan/exprs/strop.c index c7c2878..c188c36 100644 --- a/src/analysis/scan/exprs/strop.c +++ b/src/analysis/scan/exprs/strop.c @@ -55,7 +55,7 @@ static void g_scan_string_operation_finalize(GScanStringOperation *); /* Réduit une expression à une forme plus simple. */ -static ScanReductionState g_scan_string_operation_reduce(GScanStringOperation *, GScanContext *, GScanScope *, GScanExpression **); +static ScanReductionState g_scan_string_operation_reduce(const GScanStringOperation *, GScanContext *, GScanScope *, GScanExpression **); @@ -208,7 +208,8 @@ bool g_scan_string_operation_create(GScanStringOperation *op, StringOperationTyp { bool result; /* Bilan à retourner */ - result = true; + result = g_scan_expression_create(G_SCAN_EXPRESSION(op), SRS_PENDING); + if (!result) goto exit; op->type = type; @@ -236,6 +237,8 @@ bool g_scan_string_operation_create(GScanStringOperation *op, StringOperationTyp op->right = right; g_object_ref(G_OBJECT(op->right)); + exit: + return result; } @@ -262,7 +265,7 @@ bool g_scan_string_operation_create(GScanStringOperation *op, StringOperationTyp * * ******************************************************************************/ -static ScanReductionState g_scan_string_operation_reduce(GScanStringOperation *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) +static ScanReductionState g_scan_string_operation_reduce(const GScanStringOperation *expr, GScanContext *ctx, GScanScope *scope, GScanExpression **out) { ScanReductionState result; /* Etat synthétisé à retourner */ GScanExpression *new_left; /* Expression réduite (gauche) */ |