-
-
Notifications
You must be signed in to change notification settings - Fork 267
/
Copy pathldcbindings.d
85 lines (77 loc) · 3.07 KB
/
ldcbindings.d
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
//===-- ldcbindings.d -----------------------------------------------------===//
//
// LDC – the LLVM D compiler
//
// This file is distributed under the BSD-style LDC license. See the LICENSE
// file for details.
//
//===----------------------------------------------------------------------===//
module dmd.ldcbindings;
import dmd.arraytypes;
import dmd.dsymbol;
import dmd.expression;
import dmd.globals;
import dmd.location;
import dmd.common.outbuffer;
import dmd.statement;
import dmd.tokens;
extern (C++):
Parameters* createParameters() { return new Parameters(); }
Expressions* createExpressions() { return new Expressions(); }
OutBuffer* createOutBuffer() { return new OutBuffer(); }
InlineAsmStatement createInlineAsmStatement(Loc loc, Token* tokens) { return new InlineAsmStatement(loc, tokens); }
GccAsmStatement createGccAsmStatement(Loc loc, Token* tokens) { return new GccAsmStatement(loc, tokens); }
Expression createExpressionForIntOp(Loc loc, TOK op, Expression e1, Expression e2)
{
switch (op)
{
case TOK.add:
return e2 ? new AddExp(loc, e1, e2) : e1;
case TOK.min:
return e2 ? new MinExp(loc, e1, e2) : new NegExp(loc, e1);
case TOK.mul:
return new MulExp(loc, e1, e2);
case TOK.div:
return new DivExp(loc, e1, e2);
case TOK.mod:
return new ModExp(loc, e1, e2);
case TOK.leftShift:
return new ShlExp(loc, e1, e2);
case TOK.rightShift:
return new ShrExp(loc, e1, e2);
case TOK.unsignedRightShift:
return new UshrExp(loc, e1, e2);
case TOK.not:
return new NotExp(loc, e1);
case TOK.tilde:
return new ComExp(loc, e1);
case TOK.orOr:
return new LogicalExp(loc, EXP.orOr, e1, e2);
case TOK.andAnd:
return new LogicalExp(loc, EXP.andAnd, e1, e2);
case TOK.or:
return new OrExp(loc, e1, e2);
case TOK.and:
return new AndExp(loc, e1, e2);
case TOK.xor:
return new XorExp(loc, e1, e2);
case TOK.equal:
return new EqualExp(EXP.equal, loc, e1, e2);
case TOK.notEqual:
return new EqualExp(EXP.notEqual, loc, e1, e2);
case TOK.greaterThan:
return new CmpExp(EXP.greaterThan, loc, e1, e2);
case TOK.greaterOrEqual:
return new CmpExp(EXP.greaterOrEqual, loc, e1, e2);
case TOK.lessThan:
return new CmpExp(EXP.lessThan, loc, e1, e2);
case TOK.lessOrEqual:
return new CmpExp(EXP.lessOrEqual, loc, e1, e2);
default:
assert(0, "unknown integer operation");
}
}
Expression createExpression(Loc loc, EXP op) { return new Expression(loc, op); }
DsymbolExp createDsymbolExp(Loc loc, Dsymbol s) { return new DsymbolExp(loc, s, /*hasOverloads=*/false); }
AddrExp createAddrExp(Loc loc, Expression e) { return new AddrExp(loc, e); }
CommaExp createCommaExp(Loc loc, Expression e1, Expression e2, bool generated = true) { return new CommaExp(loc, e1, e2, generated); }