-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCs2.cs
More file actions
114 lines (103 loc) · 3.53 KB
/
Copy pathCs2.cs
File metadata and controls
114 lines (103 loc) · 3.53 KB
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ICSharpCode.NRefactory.CSharp;
using ICSharpCode.NRefactory.Semantics;
using ICSharpCode.NRefactory.TypeSystem;
namespace JSharp.Compiler
{
static class Cs3
{
public static bool IsVoid(this AstType type)
{
if(type==null)
return true;
var x = type as PrimitiveType;
if (x == null)
return false;
return x.KnownTypeCode == KnownTypeCode.Void;
}
public static IfElseStatement If(ResolveResult condition, Statement trueStatement, Statement falseStatement = null)
{
return new IfElseStatement(condition.ToExpression(), trueStatement, falseStatement);
}
public static ExpressionStatement Statement(this ResolveResult exp)
{
return new ExpressionStatement(exp.ToExpression());
}
public static Expression ToExpression(this ResolveResult res)
{
return new ResolveResultExpression(res);
}
}
static class Cs2
{
public static IfElseStatement If(Expression condition, Statement trueStatement, Statement falseStatement = null)
{
return new IfElseStatement(condition, trueStatement, falseStatement);
}
public static ThisReferenceExpression This()
{
return new ThisReferenceExpression();
}
public static IdentifierExpression Access(this ParameterDeclaration prm)
{
return Identifier(prm.Name);
}
public static IdentifierExpression Identifier(string name)
{
return new IdentifierExpression(name);
}
public static PrimitiveExpression Value(object value)
{
return new PrimitiveExpression(value);
}
public static AnonymousTypeCreateExpression New()
{
return new AnonymousTypeCreateExpression();
}
public static AssignmentExpression Assign(this Expression left, Expression right)
{
return new AssignmentExpression(left, right);
}
public static AnonymousTypeCreateExpression Set(this AnonymousTypeCreateExpression exp, string name, Expression value)
{
exp.Initializers.Add(Cs2.Identifier(name).Assign(value));
return exp;
}
public static AnonymousTypeCreateExpression Set(this AnonymousTypeCreateExpression exp, Expression memberAndValue)
{
exp.Initializers.Add(memberAndValue);
return exp;
}
public static ExpressionStatement Statement(this Expression exp)
{
return new ExpressionStatement(exp);
}
}
class ResolveResultExpression : Expression
{
private ResolveResult ResolveResult;
public ResolveResultExpression(ResolveResult res)
{
ResolveResult = res;
}
public override void AcceptVisitor(IAstVisitor visitor)
{
throw new NotImplementedException();
}
public override T AcceptVisitor<T>(IAstVisitor<T> visitor)
{
throw new NotImplementedException();
}
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data)
{
throw new NotImplementedException();
}
protected override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match)
{
throw new NotImplementedException();
}
}
}