forked from dart-lang/native
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathj_elements.dart
118 lines (88 loc) · 2.88 KB
/
j_elements.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'elements.dart' as ast;
abstract class Element {
void accept(Visitor visitor);
}
abstract class Visitor {
void visitClass(ClassDecl c) {}
void visitMethod(Method method) {}
void visitField(Field field) {}
void visitParam(Param parameter) {}
}
class Classes implements Element {
Classes(this._classes);
final ast.Classes _classes;
@override
void accept(Visitor visitor) {
for (final value in _classes.decls.values) {
final classDecl = ClassDecl(value);
classDecl.accept(visitor);
}
}
void let(void Function(dynamic userClasses) param0) {}
}
class ClassDecl implements Element {
ClassDecl(this._classDecl);
final ast.ClassDecl _classDecl;
String get binaryName => _classDecl.binaryName;
bool get isExcluded => _classDecl.isExcluded;
set isExcluded(bool value) => _classDecl.isExcluded = value;
String get name => _classDecl.userDefinedName ?? _classDecl.name;
set name(String newName) => _classDecl.userDefinedName = newName;
String get originalName => _classDecl.name;
@override
void accept(Visitor visitor) {
visitor.visitClass(this);
if (_classDecl.isExcluded) return;
for (final method in _classDecl.methods) {
Method(method).accept(visitor);
}
for (var field in _classDecl.fields) {
Field(field).accept(visitor);
}
}
}
class Method implements Element {
Method(this._method);
final ast.Method _method;
bool get isExcluded => _method.isExcluded;
set isExcluded(bool value) => _method.isExcluded = value;
String get name => _method.userDefinedName ?? _method.name;
set name(String newName) => _method.userDefinedName = newName;
String get originalName => _method.name;
bool get isConstructor => _method.isConstructor;
@override
void accept(Visitor visitor) {
visitor.visitMethod(this);
if (_method.isExcluded) return;
for (final param in _method.params) {
Param(param).accept(visitor);
}
}
}
class Param implements Element {
Param(this._param);
final ast.Param _param;
String get name => _param.userDefinedName ?? _param.name;
set name(String newName) => _param.userDefinedName = newName;
String get originalName => _param.name;
@override
void accept(Visitor visitor) {
visitor.visitParam(this);
}
}
class Field implements Element {
Field(this._field);
final ast.Field _field;
bool get isExcluded => _field.isExcluded;
set isExcluded(bool value) => _field.isExcluded = value;
String get name => _field.userDefinedName ?? _field.name;
set name(String newName) => _field.userDefinedName = newName;
String get originalName => _field.name;
@override
void accept(Visitor visitor) {
visitor.visitField(this);
}
}