Thread: [pure-lang-svn] SF.net SVN: pure-lang: [16] pure/trunk/interpreter.cc
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-05-01 09:36:02
|
Revision: 16 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=16&view=rev Author: agraef Date: 2008-05-01 02:36:07 -0700 (Thu, 01 May 2008) Log Message: ----------- Fix issues with field alignment on 64 bit systems. Modified Paths: -------------- pure/trunk/interpreter.cc Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-05-01 08:50:27 UTC (rev 15) +++ pure/trunk/interpreter.cc 2008-05-01 09:36:07 UTC (rev 16) @@ -134,10 +134,12 @@ ExprTy = cast<StructType>(StructTy.get()); module->addTypeName("struct.expr", ExprTy); } - // other variants + // Other variants. Note that on 64 bit systems we have to add a dummy field + // so that the following value field is aligned properly. { std::vector<const Type*> elts; elts.push_back(Type::Int32Ty); + if (sizeof(void*)==8) elts.push_back(Type::Int32Ty); // dummy elts.push_back(Type::Int32Ty); IntExprTy = StructType::get(elts); module->addTypeName("struct.intexpr", IntExprTy); @@ -145,6 +147,7 @@ { std::vector<const Type*> elts; elts.push_back(Type::Int32Ty); + if (sizeof(void*)==8) elts.push_back(Type::Int32Ty); // dummy elts.push_back(Type::DoubleTy); DblExprTy = StructType::get(elts); module->addTypeName("struct.dblexpr", DblExprTy); @@ -152,6 +155,7 @@ { std::vector<const Type*> elts; elts.push_back(Type::Int32Ty); + if (sizeof(void*)==8) elts.push_back(Type::Int32Ty); // dummy elts.push_back(PointerType::get(Type::Int8Ty, 0)); StrExprTy = StructType::get(elts); module->addTypeName("struct.strexpr", StrExprTy); @@ -159,6 +163,7 @@ { std::vector<const Type*> elts; elts.push_back(Type::Int32Ty); + if (sizeof(void*)==8) elts.push_back(Type::Int32Ty); // dummy elts.push_back(VoidPtrTy); PtrExprTy = StructType::get(elts); module->addTypeName("struct.ptrexpr", PtrExprTy); @@ -1410,6 +1415,7 @@ #define Zero UInt(0) #define One UInt(1) #define Two UInt(2) +#define ValFldIndex (sizeof(void*)==8?Two:One) #define NullExprPtr ConstantPointerNull::get(ExprPtrTy) #define NullExprPtrPtr ConstantPointerNull::get(ExprPtrPtrTy) @@ -2244,7 +2250,7 @@ f->getBasicBlockList().push_back(okbb); b.SetInsertPoint(okbb); Value *pv = b.CreateBitCast(x, IntExprPtrTy, "intexpr"); - idx[1] = One; + idx[1] = ValFldIndex; Value *iv = b.CreateLoad(b.CreateGEP(pv, idx, idx+2), "intval"); unboxed[i] = b.CreateICmpNE(iv, Zero); } else if (argt[i] == Type::Int8Ty) { @@ -2256,7 +2262,7 @@ f->getBasicBlockList().push_back(okbb); b.SetInsertPoint(okbb); Value *pv = b.CreateBitCast(x, IntExprPtrTy, "intexpr"); - idx[1] = One; + idx[1] = ValFldIndex; Value *iv = b.CreateLoad(b.CreateGEP(pv, idx, idx+2), "intval"); unboxed[i] = b.CreateTrunc(iv, Type::Int8Ty); } else if (argt[i] == Type::Int32Ty) { @@ -2268,7 +2274,7 @@ f->getBasicBlockList().push_back(okbb); b.SetInsertPoint(okbb); Value *pv = b.CreateBitCast(x, IntExprPtrTy, "intexpr"); - idx[1] = One; + idx[1] = ValFldIndex; Value *iv = b.CreateLoad(b.CreateGEP(pv, idx, idx+2), "intval"); unboxed[i] = iv; } else if (argt[i] == Type::Int64Ty) { @@ -2280,7 +2286,7 @@ f->getBasicBlockList().push_back(okbb); b.SetInsertPoint(okbb); Value *pv = b.CreateBitCast(x, IntExprPtrTy, "intexpr"); - idx[1] = One; + idx[1] = ValFldIndex; Value *iv = b.CreateLoad(b.CreateGEP(pv, idx, idx+2), "intval"); unboxed[i] = b.CreateSExt(iv, Type::Int64Ty); } else if (argt[i] == Type::DoubleTy) { @@ -2292,7 +2298,7 @@ f->getBasicBlockList().push_back(okbb); b.SetInsertPoint(okbb); Value *pv = b.CreateBitCast(x, DblExprPtrTy, "dblexpr"); - idx[1] = One; + idx[1] = ValFldIndex; Value *dv = b.CreateLoad(b.CreateGEP(pv, idx, idx+2), "dblval"); unboxed[i] = dv; } else if (argt[i] == PointerType::get(Type::Int8Ty, 0)) { @@ -2314,7 +2320,7 @@ f->getBasicBlockList().push_back(okbb); b.SetInsertPoint(okbb); Value *pv = b.CreateBitCast(x, PtrExprPtrTy, "ptrexpr"); - idx[1] = One; + idx[1] = ValFldIndex; Value *ptrv = b.CreateLoad(b.CreateGEP(pv, idx, idx+2), "ptrval"); unboxed[i] = b.CreateBitCast(ptrv, argt[i]); } else if (argt[i] == PointerType::get(Type::DoubleTy, 0)) { @@ -2326,7 +2332,7 @@ f->getBasicBlockList().push_back(okbb); b.SetInsertPoint(okbb); Value *pv = b.CreateBitCast(x, PtrExprPtrTy, "ptrexpr"); - idx[1] = One; + idx[1] = ValFldIndex; Value *ptrv = b.CreateLoad(b.CreateGEP(pv, idx, idx+2), "ptrval"); unboxed[i] = b.CreateBitCast(ptrv, argt[i]); } else if (argt[i] == ExprPtrTy) { @@ -2353,7 +2359,7 @@ b.SetInsertPoint(ptrbb); // The following will work with both pointer and string expressions. Value *pv = b.CreateBitCast(x, PtrExprPtrTy, "ptrexpr"); - idx[1] = One; + idx[1] = ValFldIndex; Value *ptrv = b.CreateLoad(b.CreateGEP(pv, idx, idx+2), "ptrval"); b.CreateBr(okbb); f->getBasicBlockList().push_back(mpzbb); @@ -2670,7 +2676,7 @@ assert(x.tag() == EXPR::VAR); Value *u = codegen(x); Value *p = e.builder.CreateBitCast(u, IntExprPtrTy, "intexpr"); - Value *v = e.CreateLoadGEP(p, Zero, One, "intval"); + Value *v = e.CreateLoadGEP(p, Zero, ValFldIndex, "intval"); // collect the temporary, it's not needed any more call("pure_freenew", u); return v; @@ -2679,7 +2685,7 @@ assert(x.tag() == EXPR::VAR && x.ttag() == EXPR::DBL); Value *u = codegen(x); Value *p = e.builder.CreateBitCast(u, DblExprPtrTy, "dblexpr"); - Value *v = e.CreateLoadGEP(p, Zero, One, "dblval"); + Value *v = e.CreateLoadGEP(p, Zero, ValFldIndex, "dblval"); v = e.builder.CreateFPToSI(v, Type::Int32Ty); // collect the temporary, it's not needed any more call("pure_freenew", u); @@ -2693,7 +2699,7 @@ verify_tag(u, EXPR::INT); // get the value Value *p = e.builder.CreateBitCast(u, IntExprPtrTy, "intexpr"); - Value *v = e.CreateLoadGEP(p, Zero, One, "intval"); + Value *v = e.CreateLoadGEP(p, Zero, ValFldIndex, "intval"); // collect the temporary, it's not needed any more call("pure_freenew", u); return v; @@ -2722,7 +2728,7 @@ assert(x.tag() == EXPR::VAR); Value *u = codegen(x); Value *p = e.builder.CreateBitCast(u, IntExprPtrTy, "intexpr"); - Value *v = e.CreateLoadGEP(p, Zero, One, "intval"); + Value *v = e.CreateLoadGEP(p, Zero, ValFldIndex, "intval"); v = e.builder.CreateSIToFP(v, Type::DoubleTy); // collect the temporary, it's not needed any more call("pure_freenew", u); @@ -2732,7 +2738,7 @@ assert(x.tag() == EXPR::VAR && x.ttag() == EXPR::DBL); Value *u = codegen(x); Value *p = e.builder.CreateBitCast(u, DblExprPtrTy, "dblexpr"); - Value *v = e.CreateLoadGEP(p, Zero, One, "dblval"); + Value *v = e.CreateLoadGEP(p, Zero, ValFldIndex, "dblval"); // collect the temporary, it's not needed any more call("pure_freenew", u); return v; @@ -2745,7 +2751,7 @@ verify_tag(u, EXPR::DBL); // get the value Value *p = e.builder.CreateBitCast(u, DblExprPtrTy, "dblexpr"); - Value *v = e.CreateLoadGEP(p, Zero, One, "dblval"); + Value *v = e.CreateLoadGEP(p, Zero, ValFldIndex, "dblval"); // collect the temporary, it's not needed any more call("pure_freenew", u); return v; @@ -4067,11 +4073,11 @@ Value *cmpv; if (t.tag == EXPR::INT) { Value *pv = f.builder.CreateBitCast(x, IntExprPtrTy, "intexpr"); - Value *iv = f.CreateLoadGEP(pv, Zero, One, "intval"); + Value *iv = f.CreateLoadGEP(pv, Zero, ValFldIndex, "intval"); cmpv = f.builder.CreateICmpEQ(iv, SInt(t.i), "cmp"); } else { Value *pv = f.builder.CreateBitCast(x, DblExprPtrTy, "dblexpr"); - Value *dv = f.CreateLoadGEP(pv, Zero, One, "dblval"); + Value *dv = f.CreateLoadGEP(pv, Zero, ValFldIndex, "dblval"); cmpv = f.builder.CreateFCmpOEQ(dv, Dbl(t.d), "cmp"); } f.builder.CreateCondBr(cmpv, matchedbb, failedbb); @@ -4331,11 +4337,11 @@ Value *cmpv; if (tag == EXPR::INT) { Value *pv = f.builder.CreateBitCast(x, IntExprPtrTy, "intexpr"); - Value *iv = f.CreateLoadGEP(pv, Zero, One, "intval"); + Value *iv = f.CreateLoadGEP(pv, Zero, ValFldIndex, "intval"); cmpv = f.builder.CreateICmpEQ(iv, SInt(l->t->i), "cmp"); } else { Value *pv = f.builder.CreateBitCast(x, DblExprPtrTy, "dblexpr"); - Value *dv = f.CreateLoadGEP(pv, Zero, One, "dblval"); + Value *dv = f.CreateLoadGEP(pv, Zero, ValFldIndex, "dblval"); cmpv = f.builder.CreateFCmpOEQ(dv, Dbl(l->t->d), "cmp"); } f.builder.CreateCondBr(cmpv, okbb, trynextbb); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-13 20:59:04
|
Revision: 80 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=80&view=rev Author: agraef Date: 2008-05-13 13:59:09 -0700 (Tue, 13 May 2008) Log Message: ----------- 64 bit: bigint fixes, correction. Modified Paths: -------------- pure/trunk/interpreter.cc Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-05-13 18:41:46 UTC (rev 79) +++ pure/trunk/interpreter.cc 2008-05-13 20:59:09 UTC (rev 80) @@ -204,7 +204,8 @@ declare_extern((void*)pure_apply, "pure_apply", "expr*", 2, "expr*", "expr*"); declare_extern((void*)pure_cmp_bigint, - "pure_cmp_bigint", "int", 3, "expr*", "int", "long*"); + "pure_cmp_bigint", "int", 3, "expr*", "int", + sizeof(mp_limb_t)==8?"long*":"int*"); declare_extern((void*)pure_cmp_string, "pure_cmp_string", "int", 2, "expr*", "char*"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-18 09:27:53
|
Revision: 97 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=97&view=rev Author: agraef Date: 2008-05-18 02:28:00 -0700 (Sun, 18 May 2008) Log Message: ----------- Remove some optimizations so that all argument refcounting goes through pure_new_args/pure_free_args. Modified Paths: -------------- pure/trunk/interpreter.cc Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-05-18 09:07:35 UTC (rev 96) +++ pure/trunk/interpreter.cc 2008-05-18 09:28:00 UTC (rev 97) @@ -1677,14 +1677,7 @@ // We must garbage-collect args and environment here, immediately before the // call (if any), or the return instruction otherwise. vector<Value*> myargs; - if (pi != ret && n == 1 && m == 0) - new CallInst(interp.module->getFunction("pure_free"), - args[0], "", pi); - else if (pi != ret && n == 0 && m == 1) { - Value *v = new GetElementPtrInst(envs, Zero, "", pi); - new CallInst(interp.module->getFunction("pure_free"), - new LoadInst(v, "", pi), "", pi); - } else if (n+m != 0) { + if (n+m != 0) { if (pi == ret) myargs.push_back(v); else @@ -3060,13 +3053,9 @@ if (n>0) { for (i = 0; i < n; i++) argv[i] = codegen(args[i]); - if (n == 1) - call("pure_new", argv[0]); - else { - vector<Value*> argv1 = argv; - argv1.push_back(NullExprPtr); - act_env().CreateCall(module->getFunction("pure_new_args"), argv1); - } + vector<Value*> argv1 = argv; + argv1.push_back(NullExprPtr); + act_env().CreateCall(module->getFunction("pure_new_args"), argv1); } return act_env().CreateCall(info.f, argv); } @@ -3585,7 +3574,7 @@ // direct call of a function, with parameters assert(f.f); // initialize the environment parameter - size_t n = args.size(), m = env.size(); + size_t m = env.size(); assert(f.local || m == 0); for (size_t i = 0; i < m; i++) e.builder.CreateStore(env[i], e.CreateGEP(e.argv, UInt(i))); @@ -3596,13 +3585,9 @@ x.push_back(e.argv); } // count references to parameters - if (n == 1) - call("pure_new", args[0]); - else if (n > 0) { - vector<Value*> args1 = args; - args1.push_back(NullExprPtr); - e.CreateCall(module->getFunction("pure_new_args"), args1); - } + vector<Value*> args1 = args; + args1.push_back(NullExprPtr); + e.CreateCall(module->getFunction("pure_new_args"), args1); // pass the function parameters x.insert(x.end(), args.begin(), args.end()); // create the call This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-27 08:38:29
|
Revision: 141 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=141&view=rev Author: agraef Date: 2008-05-27 01:38:37 -0700 (Tue, 27 May 2008) Log Message: ----------- Make body of 'when' clause tail-recursive. Modified Paths: -------------- pure/trunk/interpreter.cc Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-05-27 04:46:07 UTC (rev 140) +++ pure/trunk/interpreter.cc 2008-05-27 08:38:37 UTC (rev 141) @@ -2765,8 +2765,8 @@ // end = end of rule list { if (r == end) { - Value *v = codegen(x); - return v; + toplevel_codegen(x); + return 0; } else { Env& act = act_env(); rulel::const_iterator s = r; @@ -2788,7 +2788,8 @@ // matched => emit code for the reduct e.f->getBasicBlockList().push_back(matchedbb); e.builder.SetInsertPoint(matchedbb); - e.CreateRet(when_codegen(x, m+1, s, end)); + Value *v = when_codegen(x, m+1, s, end); + if (v) e.CreateRet(v); // failed => throw an exception e.f->getBasicBlockList().push_back(failedbb); e.builder.SetInsertPoint(failedbb); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-28 04:58:09
|
Revision: 151 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=151&view=rev Author: agraef Date: 2008-05-27 21:58:13 -0700 (Tue, 27 May 2008) Log Message: ----------- Wrapper should do a tail call of the Pure function if possible. Modified Paths: -------------- pure/trunk/interpreter.cc Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-05-28 03:56:18 UTC (rev 150) +++ pure/trunk/interpreter.cc 2008-05-28 04:58:13 UTC (rev 151) @@ -4115,6 +4115,7 @@ f.builder.SetInsertPoint(bb); CallInst* v = f.builder.CreateCall(f.f, myargs.begin(), myargs.end()); v->setCallingConv(cc); + if (cc == CallingConv::Fast) v->setTailCall(); f.builder.CreateRet(v); // validate the generated code, checking for consistency verifyFunction(*f.h); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-28 06:08:35
|
Revision: 154 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=154&view=rev Author: agraef Date: 2008-05-27 23:08:40 -0700 (Tue, 27 May 2008) Log Message: ----------- Flush stdout before printing error messages. This hopefully fixes error messages being printed too early, as reported by Jiri Spitz for the eee PC. Modified Paths: -------------- pure/trunk/interpreter.cc Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-05-28 05:58:54 UTC (rev 153) +++ pure/trunk/interpreter.cc 2008-05-28 06:08:40 UTC (rev 154) @@ -23,6 +23,7 @@ { // This is just to give a little more informative error message before we // bail out anyway. + cout.flush(); cerr << "error trying to resolve external: " << name << endl; assert(0); return 0; @@ -317,6 +318,7 @@ interpreter::error(const yy::location& l, const string& m) { nerrs++; + cout.flush(); if (!source_s) cerr << l << ": " << m << endl; } @@ -324,18 +326,21 @@ interpreter::error(const string& m) { nerrs++; + cout.flush(); if (!source_s) cerr << m << endl; } void interpreter::warning(const yy::location& l, const string& m) { + cout.flush(); if (!source_s) cerr << l << ": " << m << endl; } void interpreter::warning(const string& m) { + cout.flush(); if (!source_s) cerr << m << endl; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-18 15:44:27
|
Revision: 258 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=258&view=rev Author: agraef Date: 2008-06-18 08:44:34 -0700 (Wed, 18 Jun 2008) Log Message: ----------- Bugfix: Reset last lhs at the beginning and end of each parse. Modified Paths: -------------- pure/trunk/interpreter.cc Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-06-18 15:43:29 UTC (rev 257) +++ pure/trunk/interpreter.cc 2008-06-18 15:44:34 UTC (rev 258) @@ -400,7 +400,9 @@ parser.set_debug_level((verbose&verbosity::parser) != 0); // parse if (result) pure_free(result); result = 0; + last.clear(); parser.parse(); + last.clear(); // finalize lex_end(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-22 23:08:30
|
Revision: 282 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=282&view=rev Author: agraef Date: 2008-06-22 16:08:38 -0700 (Sun, 22 Jun 2008) Log Message: ----------- Placing an "as" pattern at the head symbol of a function application causes trouble; forbid this. Modified Paths: -------------- pure/trunk/interpreter.cc Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-06-22 22:54:24 UTC (rev 281) +++ pure/trunk/interpreter.cc 2008-06-22 23:08:38 UTC (rev 282) @@ -1075,7 +1075,7 @@ if (sym.s != "_") { if (sym.prec < 10 || sym.fix == nullary) throw err("error in pattern (bad variable symbol '"+sym.s+"')"); - if (p.len() == 0 && !b) + if (p.len() == 0 && !b || x.tag() > 0 && p.len() > 0 && p.last() == 0) throw err("error in pattern (misplaced variable '"+sym.s+"')"); env::iterator it = vars.find(sym.f); if (it != vars.end()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-07-06 08:54:11
|
Revision: 398 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=398&view=rev Author: agraef Date: 2008-07-06 01:54:21 -0700 (Sun, 06 Jul 2008) Log Message: ----------- Bugfix: copy strings in constant definitions. Reported by Eddie Rucker. Modified Paths: -------------- pure/trunk/interpreter.cc Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-07-06 07:44:56 UTC (rev 397) +++ pure/trunk/interpreter.cc 2008-07-06 08:54:21 UTC (rev 398) @@ -606,7 +606,7 @@ case EXPR::DBL: return expr(EXPR::DBL, x->data.d); case EXPR::STR: - return expr(EXPR::STR, x->data.s); + return expr(EXPR::STR, strdup(x->data.s)); case EXPR::PTR: if (x->data.p != 0) // Only null pointer constants permitted right now. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-27 04:32:42
|
Revision: 139 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=139&view=rev Author: agraef Date: 2008-05-26 21:32:49 -0700 (Mon, 26 May 2008) Log Message: ----------- Remove bogus tail call flag on calls to pure_throw. Modified Paths: -------------- pure/trunk/interpreter.cc Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-05-27 04:28:33 UTC (rev 138) +++ pure/trunk/interpreter.cc 2008-05-27 04:32:49 UTC (rev 139) @@ -4010,8 +4010,7 @@ else args.push_back(NullExprPtr); Env& e = act_env(); - CallInst *v = e.CreateCall(f, args); - v->setTailCall(); + e.CreateCall(f, args); // add a ret instruction to terminate the current block e.builder.CreateRet(NullExprPtr); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-05-28 06:10:25
|
Revision: 155 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=155&view=rev Author: agraef Date: 2008-05-27 23:10:33 -0700 (Tue, 27 May 2008) Log Message: ----------- Remove obsolete debugging code. Modified Paths: -------------- pure/trunk/interpreter.cc Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-05-28 06:08:40 UTC (rev 154) +++ pure/trunk/interpreter.cc 2008-05-28 06:10:33 UTC (rev 155) @@ -3669,12 +3669,6 @@ // local arg reference Env &e = act_env(); uint32_t k = 0; - if (e.b && e.n == 0) { - llvm::cerr << e.name << ": vref: " << symtab.sym(tag).s << ":"; - for (size_t i = 0; i < p.len(); i++) - llvm::cerr << (unsigned)p[i]; - llvm::cerr << endl; - } if (e.b) // pattern binding assert(e.n==1); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-18 22:53:24
|
Revision: 262 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=262&view=rev Author: agraef Date: 2008-06-18 15:53:32 -0700 (Wed, 18 Jun 2008) Log Message: ----------- Fix segfault in reporting of conflicting fixity declarations. Modified Paths: -------------- pure/trunk/interpreter.cc Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-06-18 20:32:46 UTC (rev 261) +++ pure/trunk/interpreter.cc 2008-06-18 22:53:32 UTC (rev 262) @@ -759,8 +759,9 @@ if (sym) { // crosscheck declarations if (sym->prec != prec || sym->fix != fix) { + string id = *it; delete ids; - throw err("conflicting fixity declaration for symbol '"+*it+"'"); + throw err("conflicting fixity declaration for symbol '"+id+"'"); } } else symtab.sym(*it, prec, fix); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-22 23:55:47
|
Revision: 283 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=283&view=rev Author: agraef Date: 2008-06-22 16:55:56 -0700 (Sun, 22 Jun 2008) Log Message: ----------- Correction: Placing an "as" pattern at the spine of a function application causes trouble; forbid this. Modified Paths: -------------- pure/trunk/interpreter.cc Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-06-22 23:08:38 UTC (rev 282) +++ pure/trunk/interpreter.cc 2008-06-22 23:55:56 UTC (rev 283) @@ -1028,7 +1028,7 @@ case EXPR::APP: { if (p.len() >= MAXDEPTH) throw err("error in pattern (nesting too deep)"); - expr u = bind(vars, x.xval1(), 1, path(p, 0)), + expr u = bind(vars, x.xval1(), b, path(p, 0)), v = bind(vars, x.xval2(), 1, path(p, 1)); y = expr(u, v); break; @@ -1075,7 +1075,10 @@ if (sym.s != "_") { if (sym.prec < 10 || sym.fix == nullary) throw err("error in pattern (bad variable symbol '"+sym.s+"')"); - if (p.len() == 0 && !b || x.tag() > 0 && p.len() > 0 && p.last() == 0) + // Unless we're doing a pattern binding, subterms at the spine of a + // function application won't be available at runtime, so we forbid + // placing an "as" pattern there. + if (!b) throw err("error in pattern (misplaced variable '"+sym.s+"')"); env::iterator it = vars.find(sym.f); if (it != vars.end()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-23 00:06:57
|
Revision: 284 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=284&view=rev Author: agraef Date: 2008-06-22 17:07:02 -0700 (Sun, 22 Jun 2008) Log Message: ----------- '_' on the lhs should always be the anonymous variable, even if it occurs as the head symbol of a function application. Modified Paths: -------------- pure/trunk/interpreter.cc Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-06-22 23:55:56 UTC (rev 283) +++ pure/trunk/interpreter.cc 2008-06-23 00:07:02 UTC (rev 284) @@ -1052,8 +1052,9 @@ default: assert(x.tag() > 0); const symbol& sym = symtab.sym(x.tag()); - if (sym.prec < 10 || sym.fix == nullary || p.len() == 0 && !b || - p.len() > 0 && p.last() == 0) { + if (sym.s != "_" && + (sym.prec < 10 || sym.fix == nullary || p.len() == 0 && !b || + p.len() > 0 && p.last() == 0)) { // constant or constructor if (x.ttag() != 0) throw err("error in pattern (misplaced type tag)"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-24 14:49:12
|
Revision: 299 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=299&view=rev Author: agraef Date: 2008-06-24 07:49:19 -0700 (Tue, 24 Jun 2008) Log Message: ----------- Bugfix: source_s must be saved during a recursive parse. Modified Paths: -------------- pure/trunk/interpreter.cc Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-06-24 14:36:02 UTC (rev 298) +++ pure/trunk/interpreter.cc 2008-06-24 14:49:19 UTC (rev 299) @@ -398,6 +398,7 @@ string l_source = source; int l_nerrs = nerrs; uint8_t l_temp = temp; + const char *l_source_s = source_s; // save global data uint8_t s_verbose = g_verbose; bool s_interactive = g_interactive; @@ -408,6 +409,7 @@ // initialize nerrs = 0; source = s; declare_op = false; + source_s = 0; errmsg.clear(); if (check && !interactive) temp = 0; bool ok = lex_begin(); @@ -432,6 +434,7 @@ source = l_source; nerrs = l_nerrs; temp = l_temp; + source_s = l_source_s; // return last computed result, if any return result; } @@ -449,6 +452,7 @@ bool l_interactive = interactive; string l_source = source; int l_nerrs = nerrs; + const char *l_source_s = source_s; // save global data uint8_t s_verbose = g_verbose; bool s_interactive = g_interactive; @@ -479,6 +483,7 @@ source = l_source; source_s = 0; nerrs = l_nerrs; + source_s = l_source_s; // return last computed result, if any return result; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-06-25 07:39:50
|
Revision: 310 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=310&view=rev Author: agraef Date: 2008-06-25 00:39:52 -0700 (Wed, 25 Jun 2008) Log Message: ----------- Comment change. Modified Paths: -------------- pure/trunk/interpreter.cc Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-06-24 23:46:23 UTC (rev 309) +++ pure/trunk/interpreter.cc 2008-06-25 07:39:52 UTC (rev 310) @@ -2745,9 +2745,7 @@ // expression. /* NOTE: The environment is allocated dynamically, so that its child environments survive for the entire lifetime of any embedded closures, - which might still be called at a later time. XXXFIXME: This leaks memory - right now. How do we keep track of environments that might still be - needed? */ + which might still be called at a later time. */ Env *save_fptr = fptr; fptr = new Env(0, 0, x, false); fptr->refc = 1; Env &f = *fptr; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ag...@us...> - 2008-07-04 20:03:52
|
Revision: 384 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=384&view=rev Author: agraef Date: 2008-07-04 13:04:01 -0700 (Fri, 04 Jul 2008) Log Message: ----------- Optimization: Skip compile for 'using' clause if possible. Modified Paths: -------------- pure/trunk/interpreter.cc Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-07-04 19:54:52 UTC (rev 383) +++ pure/trunk/interpreter.cc 2008-07-04 20:04:01 UTC (rev 384) @@ -443,12 +443,16 @@ { uint8_t s_verbose = verbose; // Temporarily suppress verbose output for using clause. - compile(); - verbose = 0; + if (verbose) { + compile(); + verbose = 0; + } for (list<string>::const_iterator s = sl.begin(); s != sl.end(); s++) run(*s, check); - compile(); - verbose = s_verbose; + if (s_verbose) { + compile(); + verbose = s_verbose; + } return result; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |