00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 #include "comma/ast/AstResource.h"
00010 #include "comma/ast/AttribDecl.h"
00011 
00012 using namespace comma;
00013 using namespace comma::attrib;
00014 using llvm::dyn_cast;
00015 using llvm::cast;
00016 using llvm::isa;
00017 
00018 
00019 
00020 PosAD *PosAD::create(AstResource &resource, IntegerDecl *prefixDecl)
00021 {
00022     IntegerType *prefix = prefixDecl->getType();
00023     IdentifierInfo *name = resource.getIdentifierInfo(getAttributeString(Pos));
00024     Location loc = prefixDecl->getLocation();
00025 
00026     
00027     
00028     IdentifierInfo *key = resource.getIdentifierInfo("Arg");
00029     Type *argType = prefix->getBaseSubtype();
00030     Type *retType = UniversalType::getUniversalInteger();
00031 
00032     FunctionType *fnTy = resource.getFunctionType(&argType, 1, retType);
00033 
00034     return new PosAD(prefix, name, loc, &key, fnTy, prefixDecl);
00035 }
00036 
00037 PosAD *PosAD::create(AstResource &resource, EnumerationDecl *prefixDecl)
00038 {
00039     EnumerationType *prefix = prefixDecl->getType();
00040     IdentifierInfo *name = resource.getIdentifierInfo(getAttributeString(Pos));
00041     Location loc = prefixDecl->getLocation();
00042 
00043     
00044     
00045     IdentifierInfo *key = resource.getIdentifierInfo("Arg");
00046     Type *argType = prefix->getBaseSubtype();
00047     Type *retType = UniversalType::getUniversalInteger();
00048 
00049     FunctionType *fnTy = resource.getFunctionType(&argType, 1, retType);
00050 
00051     return new PosAD(prefix, name, loc, &key, fnTy, prefixDecl);
00052 }
00053 
00054 
00055 
00056 ValAD *ValAD::create(AstResource &resource, IntegerDecl *prefixDecl)
00057 {
00058     IntegerType *prefix = prefixDecl->getType();
00059     IdentifierInfo *name = resource.getIdentifierInfo(getAttributeString(Val));
00060     Location loc = prefixDecl->getLocation();
00061 
00062     
00063     
00064     IdentifierInfo *key = resource.getIdentifierInfo("Arg");
00065     Type *argType = UniversalType::getUniversalInteger();
00066     Type *retType = prefix->getBaseSubtype();
00067 
00068     FunctionType *fnTy = resource.getFunctionType(&argType, 1, retType);
00069 
00070     return new ValAD(prefix, name, loc, &key, fnTy, prefixDecl);
00071 }
00072 
00073 ValAD *ValAD::create(AstResource &resource, EnumerationDecl *prefixDecl)
00074 {
00075     EnumerationType *prefix = prefixDecl->getType();
00076     IdentifierInfo *name = resource.getIdentifierInfo(getAttributeString(Val));
00077     Location loc = prefixDecl->getLocation();
00078 
00079     
00080     
00081     IdentifierInfo *key = resource.getIdentifierInfo("Arg");
00082     Type *argType = UniversalType::getUniversalInteger();
00083     Type *retType = prefix->getBaseSubtype();
00084 
00085     FunctionType *fnTy = resource.getFunctionType(&argType, 1, retType);
00086 
00087     return new ValAD(prefix, name, loc, &key, fnTy, prefixDecl);
00088 }