diff options
Diffstat (limited to 'giscanner')
-rw-r--r-- | giscanner/scannerparser.y | 6 | ||||
-rw-r--r-- | giscanner/sourcescanner.c | 20 | ||||
-rw-r--r-- | giscanner/sourcescanner.h | 1 |
3 files changed, 24 insertions, 3 deletions
diff --git a/giscanner/scannerparser.y b/giscanner/scannerparser.y index 773e9612..3457b499 100644 --- a/giscanner/scannerparser.y +++ b/giscanner/scannerparser.y @@ -366,15 +366,15 @@ unary_expression $$ = $2; break; case UNARY_MINUS: - $$ = $2; + $$ = gi_source_symbol_copy ($2); $$->const_int = -$2->const_int; break; case UNARY_BITWISE_COMPLEMENT: - $$ = $2; + $$ = gi_source_symbol_copy ($2); $$->const_int = ~$2->const_int; break; case UNARY_LOGICAL_NEGATION: - $$ = $2; + $$ = gi_source_symbol_copy ($2); $$->const_int = !gi_source_symbol_get_const_boolean ($2); break; default: diff --git a/giscanner/sourcescanner.c b/giscanner/sourcescanner.c index 1b775b46..339bd897 100644 --- a/giscanner/sourcescanner.c +++ b/giscanner/sourcescanner.c @@ -45,6 +45,26 @@ ctype_free (GISourceType * type) } GISourceSymbol * +gi_source_symbol_copy (GISourceSymbol * symbol) +{ + GISourceSymbol *new_symbol = gi_source_symbol_new (symbol->type, + symbol->source_filename, + symbol->line); + new_symbol->ident = g_strdup (symbol->ident); + + if (symbol->base_type) + new_symbol->base_type = gi_source_type_copy (symbol->base_type); + if (symbol->const_int_set) + new_symbol->const_int = symbol->const_int; + else if (symbol->const_double_set) + new_symbol->const_double = symbol->const_double_set; + else if (symbol->const_string != NULL) + new_symbol->const_string = g_strdup (symbol->const_string); + + return new_symbol; +} + +GISourceSymbol * gi_source_symbol_ref (GISourceSymbol * symbol) { symbol->ref_count++; diff --git a/giscanner/sourcescanner.h b/giscanner/sourcescanner.h index 1c0a8b0b..f67ae6bd 100644 --- a/giscanner/sourcescanner.h +++ b/giscanner/sourcescanner.h @@ -162,6 +162,7 @@ GISourceSymbol * gi_source_symbol_new (GISourceSymbolType type gboolean gi_source_symbol_get_const_boolean (GISourceSymbol *symbol); GISourceSymbol * gi_source_symbol_ref (GISourceSymbol *symbol); void gi_source_symbol_unref (GISourceSymbol *symbol); +GISourceSymbol * gi_source_symbol_copy (GISourceSymbol *symbol); /* Private */ void gi_source_scanner_add_symbol (GISourceScanner *scanner, |