Mercurial > projects > dang
changeset 65:932bb3c6b80b new_gen
Merge
author | Anders Halager <halager@gmail.com> |
---|---|
date | Tue, 29 Apr 2008 18:17:09 +0200 |
parents | 91f10c34cd7b (current diff) 78a6808b2e0f (diff) |
children | c62c32e92fde |
files | ast/Exp.d gen/CodeGen.d |
diffstat | 6 files changed, 121 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/ast/Exp.d Tue Apr 29 17:56:52 2008 +0200 +++ b/ast/Exp.d Tue Apr 29 18:17:09 2008 +0200 @@ -78,7 +78,8 @@ i.env = f.env; f.env.add(i); f.env.find(i).type = t; - auto var = new VarDecl(new Identifier(t.name), i, null); + auto ty = new Identifier(t.name); + auto var = new VarDecl(ty, i, null); Exp[] args; args ~= i; args ~= this.args;
--- a/gen/CodeGen.d Tue Apr 29 17:56:52 2008 +0200 +++ b/gen/CodeGen.d Tue Apr 29 18:17:09 2008 +0200 @@ -40,6 +40,7 @@ op.Sub : &b.buildSub, op.Mul : &b.buildMul, op.Div : &b.buildSDiv, + op.Mod : &b.buildSRem, op.Eq : mixin(genBuildCmp("EQ")), op.Ne : mixin(genBuildCmp("NE")), op.Lt : mixin(genBuildCmp("SLT")),
--- a/lexer/Lexer.d Tue Apr 29 17:56:52 2008 +0200 +++ b/lexer/Lexer.d Tue Apr 29 18:17:09 2008 +0200 @@ -39,7 +39,7 @@ foreach( char c ; "0123456789") charTable[c] = CharType.Number; - foreach( char c ; "(){};:.,=!<>+-*/") + foreach( char c ; "(){};:.,=!<>+-*/%") charTable[c] = CharType.Symbol; foreach( char c ; " \n") @@ -63,6 +63,7 @@ symbolFunctions['-'] = ⊂ symbolFunctions['*'] = &mul; symbolFunctions['/'] = ÷ + symbolFunctions['%'] = &mod; } /** @@ -244,6 +245,11 @@ return Token(Tok.Div, Location(position - 1, this.source), 1); } } + + Token mod() + { + return Token(Tok.Mod, Location(position - 1, this.source), 1); + } Token lexNumber () {
--- a/lexer/Token.d Tue Apr 29 17:56:52 2008 +0200 +++ b/lexer/Token.d Tue Apr 29 18:17:09 2008 +0200 @@ -101,7 +101,7 @@ /* Basic operators */ Assign, Add, Sub, - Mul, Div, + Mul, Div, Mod, Comma, /* Symbols */ @@ -176,6 +176,7 @@ Tok.Sub:"Sub", Tok.Mul:"Mul", Tok.Div:"Div", + Tok.Mod:"Mod", Tok.Integer:"Integer", Tok.If:"If", Tok.While:"While",
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/llvm.patch Tue Apr 29 18:17:09 2008 +0200 @@ -0,0 +1,107 @@ +Index: llvm/c/Core.d +=================================================================== +--- llvm/c/Core.d (revision 170) ++++ llvm/c/Core.d (working copy) +@@ -82,6 +82,20 @@ + */ + typedef LLVM_OpaqueMemoryBuffer* LLVMMemoryBufferRef; + ++enum LLVMParamAttr { ++ ZExt = 1<<0, ++ SExt = 1<<1, ++ NoReturn = 1<<2, ++ InReg = 1<<3, ++ StructRet = 1<<4, ++ NoUnwind = 1<<5, ++ NoAlias = 1<<6, ++ ByVal = 1<<7, ++ Nest = 1<<8, ++ ReadNone = 1<<9, ++ ReadOnly = 1<<10 ++} ++ + enum LLVMTypeKind { + Void, /**< type with no size */ + Float, /**< 32 bit floating point type */ +@@ -388,6 +402,14 @@ + /*const*/ char *LLVMGetCollector(LLVMValueRef Fn); + void LLVMSetCollector(LLVMValueRef Fn, /*const*/ char *Coll); + ++void LLVMAddParamAttr(LLVMValueRef Arg, LLVMParamAttr Attr); ++void LLVMRemoveParamAttr(LLVMValueRef Arg, LLVMParamAttr Attr); ++void LLVMSetParamAlignment(LLVMValueRef Arg, uint Align); ++void LLVMAddInstrParamAttr(LLVMValueRef Inst, uint Index, LLVMParamAttr Attr); ++void LLVMRemoveInstrParamAttr(LLVMValueRef Inst, uint Index, LLVMParamAttr Attr); ++void LLVMSetInstrParamAlignment(LLVMValueRef Inst, uint Index, uint Align); ++ ++ + /* Operations on basic blocks */ + LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef Bb); + int LLVMValueIsBasicBlock(LLVMValueRef Val); +Index: llvm/llvm.d +=================================================================== +--- llvm/llvm.d (revision 170) ++++ llvm/llvm.d (working copy) +@@ -43,6 +43,8 @@ + alias LLVMVisibility Visibility; + /// + alias LLVMValueKind ValueKind; ++/// ++public alias LLVMParamAttr ParamAttr; + + /// + class Module +@@ -836,6 +838,20 @@ + return getValueOf(v); + } + /// ++ void addParamAttr(uint idx, ParamAttr PA) ++ { ++ auto v = LLVMGetParam(value, idx); ++ assert(v !is null); ++ LLVMAddParamAttr(v, PA); ++ } ++ /// ++ void removeParamAttr(uint idx, ParamAttr PA) ++ { ++ auto v = LLVMGetParam(value, idx); ++ assert(v !is null); ++ LLVMRemoveParamAttr(v, PA); ++ } ++ /// + uint intrinsicID() + { + return LLVMGetIntrinsicID(value); +Index: llvm-fix.cpp +=================================================================== +--- llvm-fix.cpp (revision 170) ++++ llvm-fix.cpp (working copy) +@@ -29,10 +29,10 @@ + APN.convert(SemanticsForType(unwrap(RealTy)), APFloat::rmNearestTiesToEven); + return wrap(ConstantFP::get(unwrap(RealTy), APN)); + } +- ++/* + LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text) { + return wrap(ConstantFP::get(unwrap(RealTy), + APFloat(SemanticsForType(unwrap(RealTy)), Text))); + } +- ++*/ + } +Index: llvm-ext.cpp +=================================================================== +--- llvm-ext.cpp (revision 170) ++++ llvm-ext.cpp (working copy) +@@ -80,9 +80,11 @@ + LLVMTargetDataRef LLVMGetTargetDataFromModule(LLVMModuleRef M) { + return wrap(new TargetData(unwrap(M))); + } ++/* + void LLVMDisposeTargetData(LLVMTargetDataRef TD) { + delete unwrap(TD); + } ++*/ + + // we need to be able to query the ABI size of a type as an integer + size_t LLVMGetABITypeSize(LLVMTargetDataRef TD, LLVMTypeRef T) {
--- a/parser/Parser.d Tue Apr 29 17:56:52 2008 +0200 +++ b/parser/Parser.d Tue Apr 29 18:17:09 2008 +0200 @@ -419,7 +419,8 @@ {Tok.Sub, 3, true, Operator.Sub}, {Tok.Mul, 5, true, Operator.Mul}, - {Tok.Div, 5, true, Operator.Div} + {Tok.Div, 5, true, Operator.Div}, + {Tok.Mod, 5, true, Operator.Mod} ]; BinOp* binary(Tok t) {