]>
Commit | Line | Data |
---|---|---|
b3378a02 JF |
1 | /* Cycript - Optimizing JavaScript Compiler/Runtime |
2 | * Copyright (C) 2009-2010 Jay Freeman (saurik) | |
4644480a JF |
3 | */ |
4 | ||
b3378a02 | 5 | /* GNU Lesser General Public License, Version 3 {{{ */ |
4644480a | 6 | /* |
b3378a02 JF |
7 | * Cycript is free software: you can redistribute it and/or modify it under |
8 | * the terms of the GNU Lesser General Public License as published by the | |
9 | * Free Software Foundation, either version 3 of the License, or (at your | |
10 | * option) any later version. | |
4644480a | 11 | * |
b3378a02 JF |
12 | * Cycript is distributed in the hope that it will be useful, but WITHOUT |
13 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public | |
15 | * License for more details. | |
4644480a | 16 | * |
b3378a02 JF |
17 | * You should have received a copy of the GNU Lesser General Public License |
18 | * along with Cycript. If not, see <http://www.gnu.org/licenses/>. | |
19 | **/ | |
4644480a JF |
20 | /* }}} */ |
21 | ||
4de0686f JF |
22 | #ifndef REPLACE_HPP |
23 | #define REPLACE_HPP | |
24 | ||
25 | #include "Parser.hpp" | |
26 | ||
2eb8215d | 27 | #define $ new($pool) |
4de0686f JF |
28 | |
29 | #define $D(args...) \ | |
30 | ($ CYNumber(args)) | |
31 | #define $E(args...) \ | |
32 | ($ CYExpress(args)) | |
33 | #define $F(args...) \ | |
34 | ($ CYFunctionExpression(args)) | |
35 | #define $I(args...) \ | |
36 | ($ CYIdentifier(args)) | |
37 | #define $M(args...) \ | |
38 | ($ CYDirectMember(args)) | |
39 | #define $P(args...) \ | |
40 | ($ CYFunctionParameter(args)) | |
41 | #define $S(args...) \ | |
42 | ($ CYString(args)) | |
550ee46a | 43 | #define $U \ |
2eb8215d | 44 | $V($I("undefined")) |
4de0686f | 45 | #define $V(name) \ |
2eb8215d | 46 | ($ CYVariable(name)) |
4de0686f JF |
47 | |
48 | #define $T(value) \ | |
49 | if (this == NULL) \ | |
50 | return value; | |
51 | #define $$ \ | |
52 | CYStatements() | |
53 | ||
54 | #define $P1(arg0, args...) \ | |
55 | $P($I(arg0), ##args) | |
56 | #define $P2(arg0, arg1, args...) \ | |
57 | $P($I(arg0), $P1(arg1, ##args)) | |
58 | #define $P3(arg0, arg1, arg2, args...) \ | |
59 | $P($I(arg0), $P2(arg1, arg2, ##args)) | |
60 | #define $P4(arg0, arg1, arg2, arg3, args...) \ | |
61 | $P($I(arg0), $P3(arg1, arg2, arg3, ##args)) | |
62 | #define $P5(arg0, arg1, arg2, arg3, arg4, args...) \ | |
63 | $P($I(arg0), $P4(arg1, arg2, arg3, arg4, ##args)) | |
64 | #define $P6(arg0, arg1, arg2, arg3, arg4, arg5, args...) \ | |
65 | $P($I(arg0), $P5(arg1, arg2, arg3, arg4, arg5, ##args)) | |
66 | ||
67 | #define $C(args...) \ | |
68 | ($ CYCall(args)) | |
69 | #define $C_(args...) \ | |
70 | ($ CYArgument(args)) | |
71 | #define $N(args...) \ | |
2eb8215d | 72 | ($ cy::Syntax::New(args)) |
4de0686f JF |
73 | |
74 | #define $C1_(arg0, args...) \ | |
75 | $C_(arg0, ##args) | |
76 | #define $C2_(arg0, arg1, args...) \ | |
77 | $C_(arg0, $C1_(arg1, ##args)) | |
78 | #define $C3_(arg0, arg1, arg2, args...) \ | |
79 | $C_(arg0, $C2_(arg1, arg2, ##args)) | |
80 | #define $C4_(arg0, arg1, arg2, arg3, args...) \ | |
81 | $C_(arg0, $C3_(arg1, arg2, arg3, ##args)) | |
82 | #define $C5_(arg0, arg1, arg2, arg3, arg4, args...) \ | |
83 | $C_(arg0, $C4_(arg1, arg2, arg3, arg4, ##args)) | |
84 | #define $C6_(arg0, arg1, arg2, arg3, arg4, arg5, args...) \ | |
85 | $C_(arg0, $C5_(arg1, arg2, arg3, arg4, arg5, ##args)) | |
86 | ||
87 | #define $C0(func, args...) \ | |
88 | $C(func, ##args) | |
89 | #define $C1(func, args...) \ | |
90 | $C(func, $C1_(args)) | |
91 | #define $C2(func, args...) \ | |
92 | $C(func, $C2_(args)) | |
93 | #define $C3(func, args...) \ | |
94 | $C(func, $C3_(args)) | |
95 | #define $C4(func, args...) \ | |
96 | $C(func, $C4_(args)) | |
97 | #define $C5(func, args...) \ | |
98 | $C(func, $C5_(args)) | |
99 | ||
100 | #define $N0(func, args...) \ | |
101 | $N(func, ##args) | |
102 | #define $N1(func, args...) \ | |
103 | $N(func, $C1_(args)) | |
104 | #define $N2(func, args...) \ | |
105 | $N(func, $C2_(args)) | |
106 | #define $N3(func, args...) \ | |
107 | $N(func, $C3_(args)) | |
108 | #define $N4(func, args...) \ | |
109 | $N(func, $C4_(args)) | |
110 | #define $N5(func, args...) \ | |
111 | $N(func, $C5_(args)) | |
112 | ||
550ee46a JF |
113 | #define $L(args...) \ |
114 | $ CYDeclaration(args) | |
115 | #define $L1(arg0) \ | |
116 | $ CYDeclarations(arg0) | |
117 | #define $L2(arg0, args...) \ | |
118 | $ CYDeclarations(arg0, $L1(args)) | |
119 | #define $L3(arg0, args...) \ | |
120 | $ CYDeclarations(arg0, $L2(args)) | |
121 | #define $L4(arg0, args...) \ | |
122 | $ CYDeclarations(arg0, $L3(args)) | |
123 | #define $L5(arg0, args...) \ | |
124 | $ CYDeclarations(arg0, $L4(args)) | |
125 | ||
4de0686f | 126 | #endif/*REPLACE_HPP*/ |