| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 part of universe; | 5 part of universe; |
| 6 | 6 |
| 7 class SideEffects { | 7 class SideEffects { |
| 8 // Changes flags. | 8 // Changes flags. |
| 9 static const int FLAG_CHANGES_INDEX = 0; | 9 static const int FLAG_CHANGES_INDEX = 0; |
| 10 static const int FLAG_CHANGES_INSTANCE_PROPERTY = FLAG_CHANGES_INDEX + 1; | 10 static const int FLAG_CHANGES_INSTANCE_PROPERTY = FLAG_CHANGES_INDEX + 1; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 } | 29 } |
| 30 | 30 |
| 31 SideEffects.empty(); | 31 SideEffects.empty(); |
| 32 | 32 |
| 33 bool operator==(other) => flags == other.flags; | 33 bool operator==(other) => flags == other.flags; |
| 34 | 34 |
| 35 int get hashCode => throw new UnsupportedError('SideEffects.hashCode'); | 35 int get hashCode => throw new UnsupportedError('SideEffects.hashCode'); |
| 36 | 36 |
| 37 bool getFlag(int position) => (flags & (1 << position)) != 0; | 37 bool getFlag(int position) => (flags & (1 << position)) != 0; |
| 38 void setFlag(int position) { flags |= (1 << position); } | 38 void setFlag(int position) { flags |= (1 << position); } |
| 39 void clearFlag(int position) { flags &= ~(1 << position); } | |
| 40 | 39 |
| 41 int getChangesFlags() => flags & ((1 << FLAG_CHANGES_COUNT) - 1); | 40 int getChangesFlags() => flags & ((1 << FLAG_CHANGES_COUNT) - 1); |
| 42 int getDependsOnFlags() { | 41 int getDependsOnFlags() { |
| 43 return (flags & ((1 << FLAG_DEPENDS_ON_COUNT) - 1)) >> FLAG_CHANGES_COUNT; | 42 return (flags & ((1 << FLAG_DEPENDS_ON_COUNT) - 1)) >> FLAG_CHANGES_COUNT; |
| 44 } | 43 } |
| 45 | 44 |
| 46 bool hasSideEffects() => getChangesFlags() != 0; | 45 bool hasSideEffects() => getChangesFlags() != 0; |
| 47 bool dependsOnSomething() => getDependsOnFlags() != 0; | 46 bool dependsOnSomething() => getDependsOnFlags() != 0; |
| 48 | 47 |
| 49 void setAllSideEffects() { flags |= ((1 << FLAG_CHANGES_COUNT) - 1); } | 48 void setAllSideEffects() { flags |= ((1 << FLAG_CHANGES_COUNT) - 1); } |
| 50 bool hasAllSideEffects() { | 49 |
| 51 return getChangesFlags() == (1 << FLAG_CHANGES_COUNT) - 1; | |
| 52 } | |
| 53 void clearAllSideEffects() { flags &= ~((1 << FLAG_CHANGES_COUNT) - 1); } | 50 void clearAllSideEffects() { flags &= ~((1 << FLAG_CHANGES_COUNT) - 1); } |
| 54 | 51 |
| 55 void setDependsOnSomething() { | 52 void setDependsOnSomething() { |
| 56 int count = FLAG_DEPENDS_ON_COUNT - FLAG_CHANGES_COUNT; | 53 int count = FLAG_DEPENDS_ON_COUNT - FLAG_CHANGES_COUNT; |
| 57 flags |= (((1 << count) - 1) << FLAG_CHANGES_COUNT); | 54 flags |= (((1 << count) - 1) << FLAG_CHANGES_COUNT); |
| 58 } | 55 } |
| 59 void clearAllDependencies() { | 56 void clearAllDependencies() { |
| 60 int count = FLAG_DEPENDS_ON_COUNT - FLAG_CHANGES_COUNT; | 57 int count = FLAG_DEPENDS_ON_COUNT - FLAG_CHANGES_COUNT; |
| 61 flags &= ~(((1 << count) - 1) << FLAG_CHANGES_COUNT); | 58 flags &= ~(((1 << count) - 1) << FLAG_CHANGES_COUNT); |
| 62 } | 59 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 if (!dependsOnSomething()) buffer.write(' nothing'); | 98 if (!dependsOnSomething()) buffer.write(' nothing'); |
| 102 buffer.write(', Changes'); | 99 buffer.write(', Changes'); |
| 103 if (changesIndex()) buffer.write(' []'); | 100 if (changesIndex()) buffer.write(' []'); |
| 104 if (changesInstanceProperty()) buffer.write(' field'); | 101 if (changesInstanceProperty()) buffer.write(' field'); |
| 105 if (changesStaticProperty()) buffer.write(' static'); | 102 if (changesStaticProperty()) buffer.write(' static'); |
| 106 if (!hasSideEffects()) buffer.write(' nothing'); | 103 if (!hasSideEffects()) buffer.write(' nothing'); |
| 107 buffer.write('.'); | 104 buffer.write('.'); |
| 108 return buffer.toString(); | 105 return buffer.toString(); |
| 109 } | 106 } |
| 110 } | 107 } |
| OLD | NEW |