Stop using ccache on OS X.
1 /* vim: set ts=4 sw=4 tw=99 et:
3 * Copyright (C) 2012 David Anderson
5 * This file is part of JITCraft.
7 * JITCraft is free software: you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License as published by the Free
9 * Software Foundation, either version 3 of the License, or (at your option)
12 * Foobar is distributed in the hope that it will be useful, but WITHOUT ANY
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with
17 * JITCraft. If not, see http://www.gnu.org/licenses/.
19 #ifndef _include_semantic_analysis_h_
20 #define _include_semantic_analysis_h_
27 class SemanticAnalysis : public AstVisitor
33 ScopedRoot<Type> function_;
42 // Tuple that describes whether a path terminates control flow, and
43 // if it is guaranteed to end in a return.
47 ReturnStatus returns_;
50 ControlStatus(bool terminates, ReturnStatus returns)
51 : terminates_(terminates),
56 bool terminates() const {
59 ReturnStatus returns() const {
64 // Used to keep track of terminating control flow and return statements
65 // inside control structures.
68 ReturnStatus returns_;
69 ControlScope **prevp_;
74 ControlScope(ControlScope **prev)
75 : returns_(Returns_Never),
83 ControlStatus status() const {
84 return ControlStatus(terminates_, returns_);
87 // We allow multiple terminators, but only the first one takes effect.
88 // For example, |break; continue;| is legal but the continue is
90 void returns(ReturnStatus status) {
93 if (status > returns_)
96 void terminate(ReturnStatus status) {
102 void merge(const ControlStatus &left, const ControlStatus &right);
118 LoopScope(LoopScope **prev)
138 unsigned breaks() const {
141 unsigned continues() const {
146 ControlScope *control_;
150 bool canTest(AstNode *node, Handle<Type> type);
151 void unaryTypeError(AstNode *node, TokenKind token, Handle<Type> type);
152 void binaryTypeError(AstNode *node, TokenKind token, Handle<Type> left, Handle<Type> right);
153 Type *typeCheckBinary(AstNode *node, TokenKind token, Handle<Type> left, Handle<Type> right);
155 // These check if one type is compatible with another type, for various
157 // return (expr) matches function return type
158 // call(a, b) matches expected arg type
159 // a = b matches declared type
161 bool typeCheckArrayAssignment(AstNode *node, Handle<Type> given, Handle<Type> actual, bool forAssign);
162 bool typeCheckAssignment(AstNode *node, Handle<Type> given, Handle<Type> actual, bool forAssign);
163 bool typeCheckParameter(AstNode *node, Handle<Type> given, Handle<Type> actual);
165 Type *visitForLoad(Expression *expression);
166 bool preanalyze(FunctionStatement *node);
167 Type *visitForLValue(Expression *expression);
168 Type *visitAndApplyType(Expression *expression);
169 ControlStatus visitForControl(Statement *statement);
171 void markCallResultUsed(CallExpression *call);
174 SemanticAnalysis(Zone *zone, CompileContext &cc, ParseTree *tree);
178 void visit(NameProxy *name);
179 void visit(Assignment *node);
180 void visit(BinaryExpression *node);
181 void visit(ReturnStatement *node);
182 void visit(ForStatement *node);
183 void visit(BlockStatement *node);
184 void visit(VariableDeclaration *node);
185 void visit(IntegerLiteral *node);
186 void visit(ExpressionStatement *node);
187 void visit(FunctionStatement *node);
188 void visit(CallExpression *node);
189 void visit(IfStatement *node);
190 void visit(IndexExpression *node);
191 void visit(EnumStatement *node);
192 void visit(FloatLiteral *node);
193 void visit(WhileStatement *node);
194 void visit(BreakStatement *node);
195 void visit(ContinueStatement *node);
196 void visit(StringLiteral *node);
197 void visit(IncDecExpression *node);
198 void visit(UnaryExpression *node);
199 void visit(TernaryExpression *node);
204 #endif // _include_semantic_analysis_h_