adlint 3.0.8 → 3.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/ChangeLog +295 -0
  2. data/MANIFEST +9 -0
  3. data/NEWS +25 -4
  4. data/etc/mesg.d/c_builtin/en_US/messages.yml +1 -1
  5. data/etc/mesg.d/c_builtin/ja_JP/messages.yml +1 -1
  6. data/etc/mesg.d/core/en_US/messages.yml +1 -1
  7. data/etc/mesg.d/core/ja_JP/messages.yml +1 -1
  8. data/features/code_check/E0008.feature +20 -0
  9. data/features/code_check/W0093.feature +1 -1
  10. data/features/code_check/W0097.feature +30 -0
  11. data/features/code_check/W0100.feature +66 -0
  12. data/features/code_check/W0422.feature +157 -0
  13. data/features/code_check/W0459.feature +118 -0
  14. data/features/code_check/W0461.feature +115 -0
  15. data/features/code_check/W0610.feature +59 -0
  16. data/features/code_check/W0612.feature +29 -0
  17. data/features/code_check/W0613.feature +33 -0
  18. data/features/code_check/W0704.feature +25 -0
  19. data/features/code_check/W0705.feature +33 -0
  20. data/features/code_check/W1050.feature +43 -0
  21. data/features/code_check/W1071.feature +30 -0
  22. data/features/code_check/W9001.feature +24 -0
  23. data/lib/adlint/cc1/branch.rb +32 -9
  24. data/lib/adlint/cc1/builtin.rb +2 -2
  25. data/lib/adlint/cc1/conv.rb +33 -33
  26. data/lib/adlint/cc1/ctrlexpr.rb +30 -30
  27. data/lib/adlint/cc1/domain.rb +12 -4
  28. data/lib/adlint/cc1/environ.rb +2 -1
  29. data/lib/adlint/cc1/expr.rb +135 -125
  30. data/lib/adlint/cc1/format.rb +3 -3
  31. data/lib/adlint/cc1/interp.rb +123 -109
  32. data/lib/adlint/cc1/lexer.rb +44 -40
  33. data/lib/adlint/cc1/mediator.rb +2 -2
  34. data/lib/adlint/cc1/object.rb +121 -36
  35. data/lib/adlint/cc1/option.rb +1 -0
  36. data/lib/adlint/cc1/parser.rb +874 -845
  37. data/lib/adlint/cc1/parser.y +22 -2
  38. data/lib/adlint/cc1/syntax.rb +37 -18
  39. data/lib/adlint/cc1/type.rb +3 -3
  40. data/lib/adlint/cc1/value.rb +58 -50
  41. data/lib/adlint/cpp/lexer.rb +5 -1
  42. data/lib/adlint/cpp/macro.rb +30 -30
  43. data/lib/adlint/cpp/subst.rb +4 -4
  44. data/lib/adlint/exam/c_builtin/cc1_check.rb +172 -172
  45. data/lib/adlint/exam/c_builtin/cc1_check_shima.rb +11 -11
  46. data/lib/adlint/exam/c_builtin/cpp_check.rb +2 -2
  47. data/lib/adlint/memo.rb +13 -13
  48. data/lib/adlint/prelude.rb +2 -2
  49. data/lib/adlint/version.rb +2 -2
  50. data/share/doc/developers_guide_ja.html +7 -5
  51. data/share/doc/developers_guide_ja.texi +5 -3
  52. data/share/doc/users_guide_en.html +3 -3
  53. data/share/doc/users_guide_en.texi +1 -1
  54. data/share/doc/users_guide_ja.html +3 -3
  55. data/share/doc/users_guide_ja.texi +1 -1
  56. metadata +11 -2
@@ -985,6 +985,9 @@ enum_specifier
985
985
  result = EnumSpecifier.new(create_anon_tag_name(val[0]), val[2])
986
986
  result.head_token = val[0]
987
987
  result.tail_token = val[3]
988
+ result.enumerators.each do |enum|
989
+ @lexer.add_enumerator_name(enum.identifier)
990
+ end
988
991
  }
989
992
  | ENUM IDENTIFIER "{" enumerator_list "}"
990
993
  {
@@ -992,6 +995,9 @@ enum_specifier
992
995
  result = EnumSpecifier.new(val[1], val[3])
993
996
  result.head_token = val[0]
994
997
  result.tail_token = val[4]
998
+ result.enumerators.each do |enum|
999
+ @lexer.add_enumerator_name(enum.identifier)
1000
+ end
995
1001
  }
996
1002
  | ENUM "{" enumerator_list "," "}"
997
1003
  {
@@ -1000,6 +1006,9 @@ enum_specifier
1000
1006
  val[2], val[3])
1001
1007
  result.head_token = val[0]
1002
1008
  result.tail_token = val[4]
1009
+ result.enumerators.each do |enum|
1010
+ @lexer.add_enumerator_name(enum.identifier)
1011
+ end
1003
1012
  }
1004
1013
  | ENUM IDENTIFIER "{" enumerator_list "," "}"
1005
1014
  {
@@ -1007,6 +1016,9 @@ enum_specifier
1007
1016
  result = EnumSpecifier.new(val[1], val[3], val[4])
1008
1017
  result.head_token = val[0]
1009
1018
  result.tail_token = val[5]
1019
+ result.enumerators.each do |enum|
1020
+ @lexer.add_enumerator_name(enum.identifier)
1021
+ end
1010
1022
  }
1011
1023
  | ENUM IDENTIFIER
1012
1024
  {
@@ -1031,14 +1043,14 @@ enumerator_list
1031
1043
  ;
1032
1044
 
1033
1045
  enumerator
1034
- : IDENTIFIER
1046
+ : enumerator_name
1035
1047
  {
1036
1048
  checkpoint(val[0].location)
1037
1049
  sym = @sym_tbl.create_new_symbol(EnumeratorName, val[0])
1038
1050
  result = Enumerator.new(val[0], nil, sym)
1039
1051
  result.head_token = result.tail_token = val[0]
1040
1052
  }
1041
- | IDENTIFIER "=" constant_expression
1053
+ | enumerator_name "=" constant_expression
1042
1054
  {
1043
1055
  checkpoint(val[0].location)
1044
1056
  val[2].full = true
@@ -1049,6 +1061,14 @@ enumerator
1049
1061
  }
1050
1062
  ;
1051
1063
 
1064
+ enumerator_name
1065
+ : IDENTIFIER
1066
+ | TYPEDEF_NAME
1067
+ {
1068
+ result = val[0].class.new(:IDENTIFIER, val[0].value, val[0].location)
1069
+ }
1070
+ ;
1071
+
1052
1072
  type_qualifier
1053
1073
  : CONST
1054
1074
  | VOLATILE
@@ -3619,10 +3619,17 @@ module Cc1 #:nodoc:
3619
3619
 
3620
3620
  private
3621
3621
  def deduct_controlling_expression_candidates(rough_cands)
3622
- varying_var_names = varying_variable_names
3623
- rough_cands.select do |expr_pair|
3624
- collect_object_specifiers(expr_pair.first).any? do |os|
3625
- varying_var_names.include?(os.identifier.value)
3622
+ case
3623
+ when rough_cands.empty?
3624
+ [[nil, nil]]
3625
+ when rough_cands.size == 1
3626
+ rough_cands
3627
+ else
3628
+ varying_var_names = varying_variable_names
3629
+ rough_cands.select do |expr_pair|
3630
+ collect_object_specifiers(expr_pair.first).any? do |os|
3631
+ varying_var_names.include?(os.identifier.value)
3632
+ end
3626
3633
  end
3627
3634
  end
3628
3635
  end
@@ -3726,7 +3733,8 @@ module Cc1 #:nodoc:
3726
3733
 
3727
3734
  def deduct_controlling_expression
3728
3735
  sels = collect_loop_breaking_selection_statements(@statement)
3729
- rough_cands = [[@expression, @expression]] + sels.map { |stmt|
3736
+ expr = @expression
3737
+ rough_cands = [[expr, expr.to_normalized_logical]] + sels.map { |stmt|
3730
3738
  [stmt.expression,
3731
3739
  stmt.expression.to_normalized_logical.to_complemental_logical]
3732
3740
  }
@@ -3765,7 +3773,8 @@ module Cc1 #:nodoc:
3765
3773
 
3766
3774
  def deduct_controlling_expression
3767
3775
  sels = collect_loop_breaking_selection_statements(@statement)
3768
- rough_cands = [[@expression, @expression]] + sels.map { |stmt|
3776
+ expr = @expression
3777
+ rough_cands = [[expr, expr.to_normalized_logical]] + sels.map { |stmt|
3769
3778
  [stmt.expression,
3770
3779
  stmt.expression.to_normalized_logical.to_complemental_logical]
3771
3780
  }
@@ -3806,12 +3815,17 @@ module Cc1 #:nodoc:
3806
3815
 
3807
3816
  def deduct_controlling_expression
3808
3817
  sels = collect_loop_breaking_selection_statements(@body_statement)
3809
- rough_cands = [
3810
- [@condition_statement.expression, @condition_statement.expression]
3811
- ] + sels.map { |stmt|
3812
- [stmt.expression,
3813
- stmt.expression.to_normalized_logical.to_complemental_logical]
3814
- }
3818
+ if expr = @condition_statement.expression
3819
+ rough_cands = [[expr, expr.to_normalized_logical]] + sels.map { |stmt|
3820
+ [stmt.expression,
3821
+ stmt.expression.to_normalized_logical.to_complemental_logical]
3822
+ }
3823
+ else
3824
+ rough_cands = sels.map { |stmt|
3825
+ [stmt.expression,
3826
+ stmt.expression.to_normalized_logical.to_complemental_logical]
3827
+ }
3828
+ end
3815
3829
 
3816
3830
  # FIXME: When many loop breaking selection-statements are found, how can
3817
3831
  # I select one selection-statement?
@@ -3852,12 +3866,17 @@ module Cc1 #:nodoc:
3852
3866
 
3853
3867
  def deduct_controlling_expression
3854
3868
  sels = collect_loop_breaking_selection_statements(@body_statement)
3855
- rough_cands = [
3856
- [@condition_statement.expression, @condition_statement.expression]
3857
- ] + sels.map { |stmt|
3858
- [stmt.expression,
3859
- stmt.expression.to_normalized_logical.to_complemental_logical]
3860
- }
3869
+ if expr = @condition_statement.expression
3870
+ rough_cands = [[expr, expr.to_normalized_logical]] + sels.map { |stmt|
3871
+ [stmt.expression,
3872
+ stmt.expression.to_normalized_logical.to_complemental_logical]
3873
+ }
3874
+ else
3875
+ rough_cands = sels.map { |stmt|
3876
+ [stmt.expression,
3877
+ stmt.expression.to_normalized_logical.to_complemental_logical]
3878
+ }
3879
+ end
3861
3880
 
3862
3881
  # FIXME: When many loop breaking selection-statements are found, how can
3863
3882
  # I select one selection-statement?
@@ -5646,15 +5646,15 @@ module Cc1 #:nodoc:
5646
5646
  end
5647
5647
 
5648
5648
  def const?
5649
- false
5649
+ @base_type.const?
5650
5650
  end
5651
5651
 
5652
5652
  def volatile?
5653
- false
5653
+ @base_type.volatile?
5654
5654
  end
5655
5655
 
5656
5656
  def restrict?
5657
- false
5657
+ @base_type.restrict?
5658
5658
  end
5659
5659
 
5660
5660
  def bitfield?
@@ -440,9 +440,9 @@ module Cc1 #:nodoc:
440
440
  def narrow_domain!(op, ope_val)
441
441
  case ope_single_val = ope_val.to_single_value
442
442
  when ScalarValue
443
- org_dom = @domain
443
+ orig_dom = @domain
444
444
  @domain = @domain.narrow(op, ope_single_val.domain)
445
- !@domain.equal?(org_dom)
445
+ !@domain.equal?(orig_dom)
446
446
  else
447
447
  raise TypeError, "cannot narrow scalar value domain with non-scalar."
448
448
  end
@@ -451,9 +451,9 @@ module Cc1 #:nodoc:
451
451
  def widen_domain!(op, ope_val)
452
452
  case ope_single_val = ope_val.to_single_value
453
453
  when ScalarValue
454
- org_dom = @domain
454
+ orig_dom = @domain
455
455
  @domain = @domain.widen(op, ope_single_val.domain)
456
- !@domain.equal?(org_dom)
456
+ !@domain.equal?(orig_dom)
457
457
  else
458
458
  raise TypeError, "cannot widen scalar value domain with non-scalar."
459
459
  end
@@ -997,8 +997,8 @@ module Cc1 #:nodoc:
997
997
  when ArrayValue
998
998
  if @values.size == rhs_single_val.values.size
999
999
  zipped = @values.zip(rhs_single_val.values)
1000
- zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1001
- res_val.single_value_unified_with(lhs < rhs)
1000
+ zipped.reduce(scalar_value_of_nil) do |rslt_val, (lhs, rhs)|
1001
+ rslt_val.single_value_unified_with(lhs < rhs)
1002
1002
  end
1003
1003
  else
1004
1004
  scalar_value_of_false
@@ -1017,8 +1017,8 @@ module Cc1 #:nodoc:
1017
1017
  when ArrayValue
1018
1018
  if @values.size == rhs_single_val.values.size
1019
1019
  zipped = @values.zip(rhs_single_val.values)
1020
- zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1021
- res_val.single_value_unified_with(lhs > rhs)
1020
+ zipped.reduce(scalar_value_of_nil) do |rslt_val, (lhs, rhs)|
1021
+ rslt_val.single_value_unified_with(lhs > rhs)
1022
1022
  end
1023
1023
  else
1024
1024
  scalar_value_of_false
@@ -1037,8 +1037,8 @@ module Cc1 #:nodoc:
1037
1037
  when ArrayValue
1038
1038
  if @values.size == rhs_single_value.values.size
1039
1039
  zipped = @values.zip(rhs_single_val.values)
1040
- zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1041
- res_val.single_value_unified_with(lhs == rhs)
1040
+ zipped.reduce(scalar_value_of_nil) do |rslt_val, (lhs, rhs)|
1041
+ rslt_val.single_value_unified_with(lhs == rhs)
1042
1042
  end
1043
1043
  else
1044
1044
  scalar_value_of_false
@@ -1057,8 +1057,8 @@ module Cc1 #:nodoc:
1057
1057
  when ArrayValue
1058
1058
  if @values.size == rhs_single_val.values.size
1059
1059
  zipped = @values.zip(rhs_single_val.values)
1060
- zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1061
- res_val.single_value_unified_with(lhs != rhs)
1060
+ zipped.reduce(scalar_value_of_nil) do |rslt_val, (lhs, rhs)|
1061
+ rslt_val.single_value_unified_with(lhs != rhs)
1062
1062
  end
1063
1063
  else
1064
1064
  scalar_value_of_false
@@ -1077,8 +1077,8 @@ module Cc1 #:nodoc:
1077
1077
  when ArrayValue
1078
1078
  if @values.size == rhs_single_val.values.size
1079
1079
  zipped = @values.zip(rhs_single_val.values)
1080
- zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1081
- res_val.single_value_unified_with(lhs <= rhs)
1080
+ zipped.reduce(scalar_value_of_nil) do |rslt_val, (lhs, rhs)|
1081
+ rslt_val.single_value_unified_with(lhs <= rhs)
1082
1082
  end
1083
1083
  else
1084
1084
  scalar_value_of_false
@@ -1097,8 +1097,8 @@ module Cc1 #:nodoc:
1097
1097
  when ArrayValue
1098
1098
  if @values.size == rhs_single_value.values.size
1099
1099
  zipped = @values.zip(rhs_single_val.values)
1100
- zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1101
- res_val.single_value_unified_with(lhs >= rhs)
1100
+ zipped.reduce(scalar_value_of_nil) do |rslt_val, (lhs, rhs)|
1101
+ rslt_val.single_value_unified_with(lhs >= rhs)
1102
1102
  end
1103
1103
  else
1104
1104
  scalar_value_of_false
@@ -1117,8 +1117,8 @@ module Cc1 #:nodoc:
1117
1117
  when ArrayValue
1118
1118
  if @values.size == rhs_single_val.values.size
1119
1119
  zipped = @values.zip(rhs_single_val.values)
1120
- zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1121
- res_val.single_value_unified_with(lhs.logical_and(rhs))
1120
+ zipped.reduce(scalar_value_of_nil) do |rslt_val, (lhs, rhs)|
1121
+ rslt_val.single_value_unified_with(lhs.logical_and(rhs))
1122
1122
  end
1123
1123
  else
1124
1124
  scalar_value_of_false
@@ -1137,8 +1137,8 @@ module Cc1 #:nodoc:
1137
1137
  when ArrayValue
1138
1138
  if @values.size == rhs_single_val.values.size
1139
1139
  zipped = @values.zip(rhs_single_val.values)
1140
- zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1141
- res_val.single_value_unified_with(lhs.logical_or(rhs))
1140
+ zipped.reduce(scalar_value_of_nil) do |rslt_val, (lhs, rhs)|
1141
+ rslt_val.single_value_unified_with(lhs.logical_or(rhs))
1142
1142
  end
1143
1143
  else
1144
1144
  scalar_value_of_false
@@ -1484,8 +1484,8 @@ module Cc1 #:nodoc:
1484
1484
  when CompositeValue
1485
1485
  if @values.size == rhs_single_val.values.size
1486
1486
  zipped = @values.zip(rhs_single_val.values)
1487
- zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1488
- res_val.single_value_unified_with(lhs < rhs)
1487
+ zipped.reduce(scalar_value_of_nil) do |rslt_val, (lhs, rhs)|
1488
+ rslt_val.single_value_unified_with(lhs < rhs)
1489
1489
  end
1490
1490
  else
1491
1491
  scalar_value_of_false
@@ -1502,8 +1502,8 @@ module Cc1 #:nodoc:
1502
1502
  when CompositeValue
1503
1503
  if @values.size == rhs_single_val.values.size
1504
1504
  zipped = @values.zip(rhs_single_val.values)
1505
- zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1506
- res_val.single_value_unified_with(lhs > rhs)
1505
+ zipped.reduce(scalar_value_of_nil) do |rslt_val, (lhs, rhs)|
1506
+ rslt_val.single_value_unified_with(lhs > rhs)
1507
1507
  end
1508
1508
  else
1509
1509
  scalar_value_of_false
@@ -1520,8 +1520,8 @@ module Cc1 #:nodoc:
1520
1520
  when CompositeValue
1521
1521
  if @values.size == rhs_single_val.values.size
1522
1522
  zipped = @values.zip(rhs_single_val.values)
1523
- zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1524
- res_val.single_value_unified_with(lhs == rhs)
1523
+ zipped.reduce(scalar_value_of_nil) do |rslt_val, (lhs, rhs)|
1524
+ rslt_val.single_value_unified_with(lhs == rhs)
1525
1525
  end
1526
1526
  else
1527
1527
  scalar_value_of_false
@@ -1538,8 +1538,8 @@ module Cc1 #:nodoc:
1538
1538
  when CompositeValue
1539
1539
  if @values.size == rhs_single_val.values.size
1540
1540
  zipped = @values.zip(rhs_single_val.values)
1541
- zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1542
- res_val.single_value_unified_with(lhs != rhs)
1541
+ zipped.reduce(scalar_value_of_nil) do |rslt_val, (lhs, rhs)|
1542
+ rslt_val.single_value_unified_with(lhs != rhs)
1543
1543
  end
1544
1544
  else
1545
1545
  scalar_value_of_false
@@ -1556,8 +1556,8 @@ module Cc1 #:nodoc:
1556
1556
  when CompositeValue
1557
1557
  if @values.size == rhs_single_val.values.size
1558
1558
  zipped = @values.zip(rhs_single_val.values)
1559
- zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1560
- res_val.single_value_unified_with(lhs <= rhs)
1559
+ zipped.reduce(scalar_value_of_nil) do |rslt_val, (lhs, rhs)|
1560
+ rslt_val.single_value_unified_with(lhs <= rhs)
1561
1561
  end
1562
1562
  else
1563
1563
  scalar_value_of_false
@@ -1574,8 +1574,8 @@ module Cc1 #:nodoc:
1574
1574
  when CompositeValue
1575
1575
  if @values.size == rhs_single_val.values.size
1576
1576
  zipped = @values.zip(rhs_single_val.values)
1577
- zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1578
- res_val.single_value_unified_with(lhs >= rhs)
1577
+ zipped.reduce(scalar_value_of_nil) do |rslt_val, (lhs, rhs)|
1578
+ rslt_val.single_value_unified_with(lhs >= rhs)
1579
1579
  end
1580
1580
  else
1581
1581
  scalar_value_of_false
@@ -1592,8 +1592,8 @@ module Cc1 #:nodoc:
1592
1592
  when CompositeValue
1593
1593
  if @values.size == rhs_single_val.values.size
1594
1594
  zipped = @values.zip(rhs_single_val.values)
1595
- zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1596
- res_val.single_value_unified_with(lhs.logical_and(rhs))
1595
+ zipped.reduce(scalar_value_of_nil) do |rslt_val, (lhs, rhs)|
1596
+ rslt_val.single_value_unified_with(lhs.logical_and(rhs))
1597
1597
  end
1598
1598
  else
1599
1599
  scalar_value_of_false
@@ -1610,8 +1610,8 @@ module Cc1 #:nodoc:
1610
1610
  when CompositeValue
1611
1611
  if @values.size == rhs_single_val.values.size
1612
1612
  zipped = @values.zip(rhs_single_val.values)
1613
- zipped.reduce(scalar_value_of_nil) do |res_val, (lhs, rhs)|
1614
- res_val.single_value_unified_with(lhs.logical_or(rhs))
1613
+ zipped.reduce(scalar_value_of_nil) do |rslt_val, (lhs, rhs)|
1614
+ rslt_val.single_value_unified_with(lhs.logical_or(rhs))
1615
1615
  end
1616
1616
  else
1617
1617
  scalar_value_of_false
@@ -2120,10 +2120,10 @@ module Cc1 #:nodoc:
2120
2120
  end
2121
2121
 
2122
2122
  class VersionedValue < MultipleValue
2123
- def initialize(org_val)
2124
- # NOTE: `org_val.to_single_value' will be done in
2123
+ def initialize(orig_val)
2124
+ # NOTE: `orig_val.to_single_value' will be done in
2125
2125
  # MultipleValue#initialize.
2126
- super(org_val, nil)
2126
+ super(orig_val, nil)
2127
2127
 
2128
2128
  @version_controller = ValueVersionController.new(self)
2129
2129
  end
@@ -2155,22 +2155,30 @@ module Cc1 #:nodoc:
2155
2155
 
2156
2156
  def rollback_all_versions!
2157
2157
  delete_descendants!
2158
- org_val = @version_controller.original_value
2158
+ orig_val = @version_controller.original_value
2159
2159
  @version_controller = nil
2160
- _org_overwrite!(org_val)
2160
+ _orig_overwrite!(orig_val)
2161
2161
  @version_controller = ValueVersionController.new(self)
2162
2162
  invalidate_memo!
2163
2163
  end
2164
2164
 
2165
- alias :_org_overwrite! :overwrite!
2165
+ alias :_orig_overwrite! :overwrite!
2166
2166
 
2167
2167
  def overwrite!(val)
2168
2168
  @version_controller.fork_current_version
2169
- super(val.to_single_value)
2169
+ super
2170
2170
  @version_controller.mark_current_versioning_group_as_sticky
2171
2171
  invalidate_memo!
2172
2172
  end
2173
2173
 
2174
+ def force_overwrite!(val)
2175
+ # NOTE: This method will be invoked only from VariableTable#define.
2176
+ single_val = val.to_single_value
2177
+ @version_controller.original_value.overwrite!(single_val)
2178
+ _orig_overwrite!(single_val)
2179
+ invalidate_memo!
2180
+ end
2181
+
2174
2182
  def narrow_domain!(op, ope_val)
2175
2183
  @version_controller.fork_current_version
2176
2184
  super
@@ -2212,8 +2220,8 @@ module Cc1 #:nodoc:
2212
2220
  end
2213
2221
 
2214
2222
  class ValueVersionController
2215
- def initialize(org_val)
2216
- @versioning_group_stack = [RootVersioningGroup.new(org_val)]
2223
+ def initialize(orig_val)
2224
+ @versioning_group_stack = [RootVersioningGroup.new(orig_val)]
2217
2225
  end
2218
2226
 
2219
2227
  def original_value
@@ -2255,8 +2263,8 @@ module Cc1 #:nodoc:
2255
2263
  current_versioning_group.delete_current_version_completely
2256
2264
  base_vals = current_versioning_group.base_values
2257
2265
  base_vals.zip(initial_vals).each do |multi_val, initial_val|
2258
- forked and multi_val.rollback!
2259
- initial_val and multi_val.overwrite!(initial_val)
2266
+ multi_val.rollback! if forked
2267
+ multi_val.overwrite!(initial_val) if initial_val
2260
2268
  end
2261
2269
  begin_forking
2262
2270
  else
@@ -2316,7 +2324,7 @@ module Cc1 #:nodoc:
2316
2324
  vals.each do |base_multi_val, initial_single_val|
2317
2325
  base_multi_val.delete_descendants!
2318
2326
  if base_multi_val.kind_of?(VersionedValue)
2319
- base_multi_val._org_overwrite!(initial_single_val)
2327
+ base_multi_val._orig_overwrite!(initial_single_val)
2320
2328
  else
2321
2329
  base_multi_val.overwrite!(initial_single_val)
2322
2330
  end
@@ -2415,8 +2423,8 @@ module Cc1 #:nodoc:
2415
2423
  private_constant :VersioningGroup
2416
2424
 
2417
2425
  class RootVersioningGroup < VersioningGroup
2418
- def initialize(org_val)
2419
- super(Version.new([org_val], true), true)
2426
+ def initialize(orig_val)
2427
+ super(Version.new([orig_val], true), true)
2420
2428
  end
2421
2429
  end
2422
2430
  private_constant :RootVersioningGroup