Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(520)

Side by Side Diff: pkg/compiler/lib/src/serialization/values.dart

Issue 1192103002: Support serialization of the compiler backbone. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
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.
4
5 /// Class hiarchy for semantic wrapping of serializable values.
6
7 library dart2js.serialization.values;
8
9 import '../constants/expressions.dart';
10 import '../dart_types.dart';
11 import '../elements/elements.dart';
12 import 'keys.dart';
13
14 abstract class ValueVisitor<R, A> {
15 R apply(Value value, A arg);
16
17 R visitElement(ElementValue value, A arg);
18 R visitType(TypeValue value, A arg);
19 R visitConstant(ConstantValue value, A arg);
20 R visitBool(BoolValue value, A arg);
21 R visitInt(IntValue value, A arg);
22 R visitDouble(DoubleValue value, A arg);
23 R visitString(StringValue value, A arg);
24 R visitObject(ObjectValue value, A arg);
25 R visitMap(MapValue value, A arg);
26 R visitList(ListValue value, A arg);
27 R visitEnum(EnumValue value, A arg);
28 R visitUri(UriValue value, A arg);
29 }
30
31 abstract class Value {
32 accept(ValueVisitor visitor, arg);
33 }
34
35 class ElementValue implements Value {
36 final Element element;
37 final Value id;
38
39 ElementValue(this.element, this.id);
40
41 accept(ValueVisitor visitor, arg) => visitor.visitElement(this, arg);
42
43 String toString() => element.toString();
44 }
45
46 class TypeValue implements Value {
47 final DartType type;
48 final Value id;
49
50 TypeValue(this.type, this.id);
51
52 accept(ValueVisitor visitor, arg) => visitor.visitType(this, arg);
53
54 String toString() => type.toString();
55 }
56
57 class ConstantValue implements Value {
58 final ConstantExpression constant;
59 final Value id;
60
61 ConstantValue(this.constant, this.id);
62
63 accept(ValueVisitor visitor, arg) => visitor.visitConstant(this, arg);
64
65 String toString() => constant.getText();
66 }
67
68 abstract class PrimitiveValue implements Value {
69 get value;
70
71 String toString() => value.toString();
72 }
73
74 class BoolValue extends PrimitiveValue {
75 final bool value;
76
77 BoolValue(this.value);
78
79 accept(ValueVisitor visitor, arg) => visitor.visitBool(this, arg);
80 }
81
82 class IntValue extends PrimitiveValue {
83 final int value;
84
85 IntValue(this.value);
86
87 accept(ValueVisitor visitor, arg) => visitor.visitInt(this, arg);
88 }
89
90 class DoubleValue extends PrimitiveValue {
91 final double value;
92
93 DoubleValue(this.value);
94
95 accept(ValueVisitor visitor, arg) => visitor.visitDouble(this, arg);
96 }
97
98 class StringValue extends PrimitiveValue {
99 final String value;
100
101 StringValue(this.value);
102
103 accept(ValueVisitor visitor, arg) => visitor.visitString(this, arg);
104 }
105
106 class ObjectValue implements Value {
107 final Map<Key, Value> map;
108
109 ObjectValue(this.map);
110
111 accept(ValueVisitor visitor, arg) => visitor.visitObject(this, arg);
112
113 String toString() => map.toString();
114 }
115
116 class MapValue implements Value {
117 final Map<String, Value> map;
118
119 MapValue(this.map);
120
121 accept(ValueVisitor visitor, arg) => visitor.visitMap(this, arg);
122
123 String toString() => map.toString();
124 }
125
126 class ListValue implements Value {
127 final List<Value> values;
128
129 ListValue(this.values);
130
131 accept(ValueVisitor visitor, arg) => visitor.visitList(this, arg);
132
133 String toString() => values.toString();
134 }
135
136 class EnumValue implements Value {
137 final value;
138
139 EnumValue(this.value);
140
141 accept(ValueVisitor visitor, arg) => visitor.visitEnum(this, arg);
142
143 String toString() => value.toString();
144 }
145
146 class UriValue implements Value {
147 final Uri baseUri;
148 final Uri value;
149
150 UriValue(this.baseUri, this.value);
151
152 accept(ValueVisitor visitor, arg) => visitor.visitUri(this, arg);
153
154 String toString() => value.toString();
155 }
156
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698