@@ -37,7 +37,7 @@ public partial class AstCsToJsonVisitor : IAstVisitor
37
37
Dictionary < string , int > typeReferences = new Dictionary < string , int > ( ) ;
38
38
39
39
40
- bool isLambda = false ;
40
+
41
41
public JsonValue LastValue { get ; private set ; }
42
42
43
43
public AstCsToJsonVisitor ( ITextOutput output )
@@ -135,22 +135,10 @@ JsonValue GetTypeInfoList(List<string> typeInfoList)
135
135
}
136
136
return typeArr ;
137
137
}
138
- bool isSuspectLambda = false ;
139
- int countLamda = 0 ;
138
+
140
139
JsonElement GetIdentifier ( Identifier identifier )
141
140
{
142
- //TODO: review here
143
- string name = identifier . Name ;
144
- if ( name [ 0 ] == '<' && name [ 1 ] == '>' )
145
- {
146
- isSuspectLambda = true ;
147
- countLamda ++ ;
148
- if ( countLamda == 4 )
149
- {
150
-
151
- }
152
- }
153
- return new JsonElement ( name ) ;
141
+ return new JsonElement ( identifier . Name ) ;
154
142
}
155
143
156
144
JsonValue GetKeyword ( TokenRole tokenRole )
@@ -466,18 +454,9 @@ public void VisitDirectionExpression(DirectionExpression directionExpression)
466
454
public void VisitIdentifierExpression ( IdentifierExpression identifierExpression )
467
455
{
468
456
JsonValue getIdentifier = GetIdentifier ( identifierExpression . IdentifierToken ) ;
469
- if ( isLambda )
470
- {
471
- //?
472
- //TODO: review here
473
- Push ( getIdentifier ) ;
474
- }
475
- else
476
- {
477
- JsonObject jsonIdenExpr = CreateJsonExpression ( identifierExpression ) ;
478
- jsonIdenExpr . AddJsonValue ( "name" , getIdentifier ) ;
479
- Push ( jsonIdenExpr ) ;
480
- }
457
+ JsonObject jsonIdenExpr = CreateJsonExpression ( identifierExpression ) ;
458
+ jsonIdenExpr . AddJsonValue ( "name" , getIdentifier ) ;
459
+ Push ( jsonIdenExpr ) ;
481
460
}
482
461
483
462
public void VisitIndexerExpression ( IndexerExpression indexerExpression )
@@ -825,11 +804,10 @@ public void VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration)
825
804
{
826
805
member . AcceptVisitor ( this ) ;
827
806
var temp = Pop ( ) ;
828
- if ( temp != null && ! isLambda )
807
+ if ( temp != null )
829
808
{
830
809
memberList . AddJsonValue ( temp ) ;
831
810
}
832
- isLambda = false ;
833
811
}
834
812
if ( memberList . Count == 0 )
835
813
{
@@ -838,9 +816,8 @@ public void VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration)
838
816
declaration . AddJsonValue ( "members" , memberList ) ;
839
817
840
818
Push ( declaration ) ;
841
- }
842
-
843
- Dictionary < string , TypeDeclaration > lambdaClass = new Dictionary < string , TypeDeclaration > ( ) ;
819
+ }
820
+
844
821
public void VisitTypeDeclaration ( TypeDeclaration typeDeclaration )
845
822
{
846
823
JsonObject declaration = new JsonObject ( ) ;
@@ -864,18 +841,9 @@ public void VisitTypeDeclaration(TypeDeclaration typeDeclaration)
864
841
break ;
865
842
}
866
843
JsonElement identifier = GetIdentifier ( typeDeclaration . NameToken ) ;
867
- if ( identifier . ElementValue [ 0 ] == '<' && identifier . ElementValue [ 0 ] == '>' )
868
- {
869
- isLambda = true ;
870
- }
844
+
871
845
872
- bool thisTypeIsLamda = false ;
873
- if ( isLambda )
874
- {
875
- thisTypeIsLamda = true ;
876
- lambdaClass [ identifier . ElementValue ] = typeDeclaration ;
877
- isLambda = false ;
878
- }
846
+ bool thisTypeIsLamda = false ;
879
847
declaration . AddJsonValue ( "identifier" , identifier ) ;
880
848
declaration . AddJsonValue ( "parameters" , GetTypeParameters ( typeDeclaration . TypeParameters ) ) ;
881
849
if ( typeDeclaration . BaseTypes . Any ( ) )
@@ -900,8 +868,7 @@ public void VisitTypeDeclaration(TypeDeclaration typeDeclaration)
900
868
{
901
869
declaration = null ;
902
870
}
903
- Push ( declaration ) ;
904
- isLambda = false ;
871
+ Push ( declaration ) ;
905
872
}
906
873
907
874
public void VisitUsingAliasDeclaration ( UsingAliasDeclaration usingAliasDeclaration )
@@ -1086,59 +1053,10 @@ public void VisitIfElseStatement(IfElseStatement ifElseStatement)
1086
1053
statement . AddJsonValue ( "condition" , GenExpression ( ifElseStatement . Condition ) ) ;
1087
1054
statement . AddJsonValue ( "true-statement" , GenStatement ( ifElseStatement . TrueStatement ) ) ;
1088
1055
statement . AddJsonValue ( "false-statement" , GenStatement ( ifElseStatement . FalseStatement ) ) ;
1089
- //TODO: ckeck lambda
1090
- if ( isSuspectLambda )
1091
- {
1092
-
1093
- }
1094
- if ( isLambda )
1095
- {
1096
- //TODO: review here
1097
- //?
1098
- CreateLamda ( statement ) ;
1099
- isLambda = false ;
1100
- return ;
1101
- }
1102
-
1056
+
1103
1057
Push ( statement ) ;
1104
1058
}
1105
- void CreateLamda ( JsonObject ifElseNode )
1106
- {
1107
- JsonObject condition = GetValue ( "condition" , ifElseNode ) ;
1108
- JsonObject leftOperand = GetValue ( "left-operand" , condition ) ;
1109
- JsonElement identifier = GetElement ( "left-operand" , leftOperand ) ;
1110
-
1111
- JsonObject trueStatement = GetValue ( "true-statement" , ifElseNode ) ;
1112
- JsonArray list = GetArray ( "statement-list" , trueStatement ) ;
1113
- JsonObject statement = ( JsonObject ) list . ValueList [ 0 ] ;
1114
- JsonObject rigthOperand = GetValue ( "right-operand" , statement ) ;
1115
- JsonObject arguments = GetValue ( "arguments" , rigthOperand ) ;
1116
- JsonElement methodName = GetElement ( "identifier-name" , arguments ) ;
1117
- JsonObject typeInfo = GetValue ( "type-info" , arguments ) ;
1118
- JsonObject memberRef = GetValue ( "type-info" , typeInfo ) ;
1119
- JsonElement memName = GetElement ( "member-name" , memberRef ) ;
1120
-
1121
- TypeDeclaration typeDeclare ;
1122
- JsonObject lambdaExpression = new JsonObject ( ) ;
1123
- if ( lambdaClass . TryGetValue ( memName . ElementValue , out typeDeclare ) )
1124
- {
1125
- lambdaExpression . Comment = "CreateLamda" ;
1126
- lambdaExpression . AddJsonValue ( "expression-type" , new JsonElement ( "lambda-expression" ) ) ;
1127
- foreach ( var member in typeDeclare . Members )
1128
- {
1129
- if ( member is MethodDeclaration )
1130
- {
1131
- MethodDeclaration method = ( MethodDeclaration ) member ;
1132
- if ( method . Name == methodName . ElementValue )
1133
- {
1134
- lambdaExpression . AddJsonValue ( "parameters" , GetCommaSeparatedList ( method . Parameters ) ) ;
1135
- lambdaExpression . AddJsonValue ( "body" , GenStatement ( method . Body ) ) ;
1136
- }
1137
- }
1138
- }
1139
- Push ( lambdaExpression ) ;
1140
- }
1141
- }
1059
+
1142
1060
1143
1061
JsonObject GetValue ( string key , JsonObject obj )
1144
1062
{
0 commit comments