src/typecheck.h

Go to the documentation of this file.
00001 /* -*- Mode: objc; c-basic-offset: 2; tab-width: 2 indent-tabs-mode: nil -*- */
00002 /* vim: set filetype=objc ts=2 sw=2 expandtab: */
00003 
00004 /*
00005  * Copyright (C) 2007 Neil Dantam
00006  *               2007 Jeff Seibert
00007  *
00008  * This program is free software: you can redistribute it and/or modify it
00009  * under the terms of the GNU General Public License, verson 3 ONLY, as
00010  * published by the Free Software Foundation.
00011  * 
00012  * This program is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
00015  * more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License along with
00018  * this program.  If not, see <http://www.gnu.org/licenses/>.
00019  */
00020 
00021 
00029 #ifndef _TYPECHECK_H_
00030 #define _TYPECHECK_H_
00031 #include "scope.h"
00032 
00040 @interface ClassType : Object{
00041   BOOL seenInterface;        
00042   BOOL seenImplementation;   
00043   SymTable *fields;          
00044   SymTable *instMethods;     
00045   SymTable *classMethods;    
00046   Interface *iface;          
00047   Implementation *impl;      
00048   ClassType *parent;         
00049   ObjectTipe *tipe;        
00050 }
00051 
00053 -(void) setInterface: (Interface*) i;
00055 -(void) setImplementation: (Implementation*) i;
00057 -(void) setSuper: (ClassType*) i;
00059 -(void) addField: (char*) f tipe: (Tipe*) t;
00060 -(void) addInstMethods: (char *) n : (Method *) m;
00061 -(void) addClassMethods: (char *) n : (Method *) m;
00063 -(char*) classname;
00065 -(ObjectTipe*) tipe;
00067 -(Implementation*) impl;
00069 -(Interface*) iface;
00075 -(int) findField: (char*) f;
00076 
00079 -(BOOL) hasField: (char*) f;
00080 -(ClassType*) parent;
00081 -(BOOL) hasClassMethod: (char*) m;
00082 -(Method*) getClassMethod: (char*) m;
00083 
00086 -(Method*) findClassMethod: (char *) method;
00087 @end
00088 /*
00089 @interface MethodType {
00090   SymTable *args;
00091   Method *method;
00092   SymTable *locals;
00093 }
00094 @end
00095 */
00096 
00097 
00099 typedef struct {
00100   Klass *klass;
00101   ClassType *ct;
00102   BOOL namespaced;
00103 } check_context;
00104 
00107 @interface DeclReg : Object {
00108   id o;
00109 }
00110 -(id) init: (id) i;
00111 -(void) reg: (Tipe*) t id: (char*) i;
00112 -(void) regFormal: (Tipe*) t id: (char*) i;
00113 @end
00114 
00116 @interface ClassReg : DeclReg {
00117   ClassType *ct;
00118 }
00119 @end
00120 
00122 @interface ScopeReg : DeclReg {
00123   Scope *s;
00124 }
00125 @end
00126 
00128 @interface ContainerReg : DeclReg {
00129   ContainerTipe *cn;
00130 }
00131 @end
00132 
00133 
00135 @interface SymTableReg : DeclReg {
00136   SymTable *table;
00137 }
00138 @end
00139 
00141 @interface FormalReg : DeclReg {
00142   Scope *local; 
00143   Scope *global; 
00144 }
00145 -(id) init: (id) l: (id) g;
00146 @end
00147 
00153 @interface FormalWrapReg : DeclReg {
00154   FormalReg *fr; 
00155 }
00156 -(id) init: (id) f;
00157 @end
00158 
00160 @interface NullReg : DeclReg
00161 @end
00162 
00163 
00164 @interface ASTNode (TypeCheck)
00165 -(ASTNode*) check;//: (check_context*) context;
00166 //-(void) checkVar: (ClassType*) ct;
00167 -(void) checkMethod: (Klass*) k;
00168 -(Tipe*) checkDecl: (Tipe*) base reg: (DeclReg*) r;
00169 -(Tipe*) checkExpr: (ASTNode**) node;// context: (check_context*) context ;
00170 -(Tipe*) genTipe;
00171 @end
00172 
00173 
00174 extern SymTable *classEnv;
00175         
00176 #endif
00177 

Generated on Mon Dec 24 06:11:58 2007 for gfront by  doxygen 1.5.2