aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeddy <[email protected]>2013-08-17 16:53:48 +0800
committerTeddy <[email protected]>2013-08-17 16:53:48 +0800
commitd8ed26377bb05631d77c4800d2dd99a653e24651 (patch)
tree22b51a948749aa64f4056aee7a4c0dfb4979dfa4
parent3b0217d2a2d4e345a31a68948dfb0feaec4a8a2a (diff)
...
-rw-r--r--builtin.cpp82
-rw-r--r--eval.cpp14
-rw-r--r--gc.cpp16
-rw-r--r--main.cpp2
-rw-r--r--parser.cpp4
-rw-r--r--types.cpp2
6 files changed, 60 insertions, 60 deletions
diff --git a/builtin.cpp b/builtin.cpp
index 1ab1d37..1061478 100644
--- a/builtin.cpp
+++ b/builtin.cpp
@@ -13,7 +13,7 @@ extern EmptyList *empty_list;
extern UnspecObj *unspec_obj;
#define EXC_WRONG_ARG_NUM \
- throw TokenError(name, RUN_ERR_WRONG_NUM_OF_ARGS)
+ throw TokenError(name, RUN_ERR_WRONG_NUM_OF_ARGS)
SpecialOptIf::SpecialOptIf() : SpecialOptObj("if") {}
@@ -114,28 +114,28 @@ Pair *SpecialOptIf::call(Pair *args, Environment * &lenvt,
}
#define CHECK_SYMBOL(ptr) \
-do \
+ do \
{ \
if (!(ptr)->is_sym_obj()) \
- throw TokenError("a symbol", RUN_ERR_WRONG_TYPE); \
+ throw TokenError("a symbol", RUN_ERR_WRONG_TYPE); \
} while (0)
#define CHECK_NUMBER(ptr) \
-do \
+ do \
{ \
if (!(ptr)->is_num_obj()) \
- throw TokenError("a number", RUN_ERR_WRONG_TYPE); \
+ throw TokenError("a number", RUN_ERR_WRONG_TYPE); \
} while (0)
#define CHECK_EXACT(ptr) \
-do \
+ do \
{ \
if (!(static_cast<NumObj*>(ptr))->is_exact()) \
- throw TokenError("an integer", RUN_ERR_WRONG_TYPE); \
+ throw TokenError("an integer", RUN_ERR_WRONG_TYPE); \
} while (0)
#define CHECK_PARA_LIST(p) \
-do \
+ do \
{ \
if (p == empty_list) break; \
EvalObj *nptr; \
@@ -144,11 +144,11 @@ do \
{ \
CHECK_SYMBOL(ptr->car); \
if ((nptr = ptr->cdr)->is_pair_obj()) \
- ptr = TO_PAIR(nptr); \
+ ptr = TO_PAIR(nptr); \
else break; \
} \
if (ptr->cdr != empty_list) \
- CHECK_SYMBOL(ptr->cdr); \
+ CHECK_SYMBOL(ptr->cdr); \
} \
while (0)
@@ -325,7 +325,7 @@ SpecialOptEval::SpecialOptEval() : SpecialOptObj("eval") {}
void SpecialOptEval::prepare(Pair *pc) {
if (pc->cdr == empty_list ||
- TO_PAIR(pc->cdr)->cdr != empty_list)
+ TO_PAIR(pc->cdr)->cdr != empty_list)
EXC_WRONG_ARG_NUM;
}
@@ -554,7 +554,7 @@ SpecialOptForce::SpecialOptForce() : SpecialOptObj("force") {}
void SpecialOptForce::prepare(Pair *pc) {
if (pc->cdr == empty_list ||
- TO_PAIR(pc->cdr)->cdr != empty_list)
+ TO_PAIR(pc->cdr)->cdr != empty_list)
EXC_WRONG_ARG_NUM;
}
@@ -603,7 +603,7 @@ SpecialOptDelay::SpecialOptDelay() : SpecialOptObj("delay") {}
void SpecialOptDelay::prepare(Pair *pc) {
if (pc->cdr == empty_list ||
- TO_PAIR(pc->cdr)->cdr != empty_list)
+ TO_PAIR(pc->cdr)->cdr != empty_list)
EXC_WRONG_ARG_NUM;
pc->next = NULL;
}
@@ -625,12 +625,12 @@ Pair *SpecialOptDelay::call(Pair *args, Environment * &lenvt,
if (args == empty_list || \
args->cdr == empty_list || \
TO_PAIR(args->cdr)->cdr != empty_list) \
- EXC_WRONG_ARG_NUM
+EXC_WRONG_ARG_NUM
#define ARGS_EXACTLY_ONE \
if (args == empty_list || \
args->cdr != empty_list ) \
- EXC_WRONG_ARG_NUM
+EXC_WRONG_ARG_NUM
#define ARGS_AT_LEAST_ONE \
if (args == empty_list) EXC_WRONG_ARG_NUM
@@ -662,7 +662,7 @@ BUILTIN_PROC_DEF(make_list) {
}
BUILTIN_PROC_DEF(num_add) {
-// ARGS_AT_LEAST_ONE;
+ // ARGS_AT_LEAST_ONE;
NumObj *res = new IntNumObj(0), *opr; // the most accurate type
for (;args != empty_list; args = TO_PAIR(args->cdr))
{
@@ -722,7 +722,7 @@ BUILTIN_PROC_DEF(num_sub) {
}
BUILTIN_PROC_DEF(num_mul) {
-// ARGS_AT_LEAST_ONE;
+ // ARGS_AT_LEAST_ONE;
NumObj *res = new IntNumObj(1), *opr; // the most accurate type
for (;args != empty_list; args = TO_PAIR(args->cdr))
{
@@ -1161,12 +1161,12 @@ BUILTIN_PROC_DEF(is_eqv) {
if (otype != obj2->get_otype()) return new BoolObj(false);
if (otype & CLS_BOOL_OBJ)
return new BoolObj(
- static_cast<BoolObj*>(obj1)->val ==
- static_cast<BoolObj*>(obj2)->val);
+ static_cast<BoolObj*>(obj1)->val ==
+ static_cast<BoolObj*>(obj2)->val);
if (otype & CLS_SYM_OBJ)
return new BoolObj(
- static_cast<SymObj*>(obj1)->val ==
- static_cast<SymObj*>(obj2)->val);
+ static_cast<SymObj*>(obj1)->val ==
+ static_cast<SymObj*>(obj2)->val);
if (otype & CLS_NUM_OBJ)
{
NumObj *num1 = static_cast<NumObj*>(obj1);
@@ -1180,29 +1180,29 @@ BUILTIN_PROC_DEF(is_eqv) {
}
if (otype & CLS_CHAR_OBJ)
return new BoolObj(
- static_cast<CharObj*>(obj1)->ch ==
- static_cast<CharObj*>(obj2)->ch); // (char=?)
+ static_cast<CharObj*>(obj1)->ch ==
+ static_cast<CharObj*>(obj2)->ch); // (char=?)
return new BoolObj(obj1 == obj2);
}
BUILTIN_PROC_DEF(is_equal) {
-//#define INC1(x) (++(x) == t1 ? (x) = q1:0)
-//#define INC2(x) (++(x) == t2 ? (x) = q2:0)
+ //#define INC1(x) (++(x) == t1 ? (x) = q1:0)
+ //#define INC2(x) (++(x) == t2 ? (x) = q2:0)
#define INC1(x) (++(x))
#define INC2(x) (++(x))
#define CHK1 \
-do { \
- if (r1 == q1 + EQUAL_QUEUE_SIZE) \
+ do { \
+ if (r1 == q1 + EQUAL_QUEUE_SIZE) \
throw NormalError(RUN_ERR_QUEUE_OVERFLOW); \
-} while (0)
+ } while (0)
#define CHK2 \
-do { \
- if (r2 == q2 + EQUAL_QUEUE_SIZE) \
+ do { \
+ if (r2 == q2 + EQUAL_QUEUE_SIZE) \
throw NormalError(RUN_ERR_QUEUE_OVERFLOW); \
-} while (0)
+ } while (0)
static EvalObj *q1[EQUAL_QUEUE_SIZE], *q2[EQUAL_QUEUE_SIZE];
@@ -1222,7 +1222,7 @@ do { \
if (otype != (b = *l2)->get_otype())
return new BoolObj(false);
if (a != empty_list && b != empty_list &&
- otype & CLS_PAIR_OBJ)
+ otype & CLS_PAIR_OBJ)
{
*r1 = TO_PAIR(a)->car;
INC1(r1);
@@ -1265,13 +1265,13 @@ do { \
else if (otype & CLS_BOOL_OBJ)
{
if (static_cast<BoolObj*>(a)->val !=
- static_cast<BoolObj*>(b)->val)
+ static_cast<BoolObj*>(b)->val)
return new BoolObj(false);
}
else if (otype & CLS_SYM_OBJ)
{
if (static_cast<SymObj*>(a)->val !=
- static_cast<SymObj*>(b)->val)
+ static_cast<SymObj*>(b)->val)
return new BoolObj(false);
}
else if (otype & CLS_NUM_OBJ)
@@ -1279,7 +1279,7 @@ do { \
NumObj *num1 = static_cast<NumObj*>(a);
NumObj *num2 = static_cast<NumObj*>(b);
if (num1->is_exact() != num2->is_exact())
- return new BoolObj(false);
+ return new BoolObj(false);
if (num1->level < num2->level)
{
if (!num1->eq(num1->convert(num2)))
@@ -1294,13 +1294,13 @@ do { \
else if (otype & CLS_CHAR_OBJ)
{
if (static_cast<CharObj*>(a)->ch !=
- static_cast<CharObj*>(b)->ch)
+ static_cast<CharObj*>(b)->ch)
return new BoolObj(false); // (char=?)
}
else if (otype & CLS_STR_OBJ)
{
if (static_cast<StrObj*>(a)->str !=
- static_cast<StrObj*>(b)->str)
+ static_cast<StrObj*>(b)->str)
return new BoolObj(false); // (string=?)
}
else if (a != b)
@@ -1334,13 +1334,13 @@ BUILTIN_PROC_DEF(is_real) {
BUILTIN_PROC_DEF(is_rational) {
ARGS_EXACTLY_ONE;
return new BoolObj(args->car->is_num_obj() &&
- static_cast<NumObj*>(args->car)->level >= NUM_LVL_RAT);
+ static_cast<NumObj*>(args->car)->level >= NUM_LVL_RAT);
}
BUILTIN_PROC_DEF(is_integer) {
ARGS_EXACTLY_ONE;
return new BoolObj(args->car->is_num_obj() &&
- static_cast<NumObj*>(args->car)->level >= NUM_LVL_INT);
+ static_cast<NumObj*>(args->car)->level >= NUM_LVL_INT);
}
BUILTIN_PROC_DEF(num_abs) {
@@ -1406,7 +1406,7 @@ BUILTIN_PROC_DEF(num_rem) {
}
BUILTIN_PROC_DEF(num_gcd) {
-// ARGS_AT_LEAST_ONE;
+ // ARGS_AT_LEAST_ONE;
IntNumObj *res = new IntNumObj(0);
IntNumObj *opr;
for (;args != empty_list; args = TO_PAIR(args->cdr))
@@ -1423,7 +1423,7 @@ BUILTIN_PROC_DEF(num_gcd) {
}
BUILTIN_PROC_DEF(num_lcm) {
-// ARGS_AT_LEAST_ONE;
+ // ARGS_AT_LEAST_ONE;
IntNumObj *res = new IntNumObj(1);
IntNumObj *opr;
for (;args != empty_list; args = TO_PAIR(args->cdr))
diff --git a/eval.cpp b/eval.cpp
index 918311e..d371838 100644
--- a/eval.cpp
+++ b/eval.cpp
@@ -16,11 +16,11 @@ EvalObj *eval_stack[EVAL_STACK_SIZE];
void Evaluator::add_builtin_routines() {
#define ADD_ENTRY(name, rout) \
-do { \
- SymObj *tmp = new SymObj(name); \
- envt->add_binding(tmp, rout); \
- delete tmp; \
-} while (0)
+ do { \
+ SymObj *tmp = new SymObj(name); \
+ envt->add_binding(tmp, rout); \
+ delete tmp; \
+ } while (0)
#define ADD_BUILTIN_PROC(name, rout) \
ADD_ENTRY(name, new BuiltinProcObj(rout, name))
@@ -208,8 +208,8 @@ EvalObj *Evaluator::run_expr(Pair *prog) {
}
else
throw TokenError((args->car)->ext_repr(), SYN_ERR_CAN_NOT_APPLY);
-// gc.collect(); THIS IS DEPRECATED BECAUSE IT'S NOT A SAFE POINT
-// ANYMORE DUE TO THE TAIL RECURSION OPT
+ // gc.collect(); THIS IS DEPRECATED BECAUSE IT'S NOT A SAFE POINT
+ // ANYMORE DUE TO THE TAIL RECURSION OPT
}
}
// remove the protection
diff --git a/gc.cpp b/gc.cpp
index de5ef7e..0f4b9a7 100644
--- a/gc.cpp
+++ b/gc.cpp
@@ -87,7 +87,7 @@ void GarbageCollector::force() {
fprintf(stderr, "GC: Forced clear, %lu objects are freed, "
"%lu remains\n"
"=============================\n", cnt, joined_size);
-
+
#endif
#ifdef GC_DEBUG
#endif
@@ -95,17 +95,17 @@ void GarbageCollector::force() {
EvalObj *GarbageCollector::attach(EvalObj *ptr) {
if (!ptr) return NULL; // NULL pointer
-/* bool flag = mapping.count(ptr);
- if (flag) mapping[ptr]++;
- else mapping[ptr] = 1;
- */
+ /* bool flag = mapping.count(ptr);
+ if (flag) mapping[ptr]++;
+ else mapping[ptr] = 1;
+ */
ptr->gc_rec->gc_cnt++;
#ifdef GC_DEBUG
fprintf(stderr, "GC: 0x%llx attached. count = %lu \"%s\"\n",
(ull)ptr, ptr->gc_rec->gc_cnt, ptr->ext_repr().c_str());
#endif
-/* if (mapping.size() > GC_QUEUE_SIZE >> 1)
- force();*/
+ /* if (mapping.size() > GC_QUEUE_SIZE >> 1)
+ force();*/
return ptr; // passing through
}
@@ -183,4 +183,4 @@ void GarbageCollector::quit(EvalObj *ptr) {
}
GCRecord::GCRecord(GCRecord *_prev, GCRecord *_next) :
- prev(_prev), next(_next) {}
+prev(_prev), next(_next) {}
diff --git a/main.cpp b/main.cpp
index 455d6d0..8a6519f 100644
--- a/main.cpp
+++ b/main.cpp
@@ -75,7 +75,7 @@ int main(int argc, char **argv) {
}
}
else if (strcmp(argv[i], "-h") == 0 ||
- strcmp(argv[i], "--help") == 0)
+ strcmp(argv[i], "--help") == 0)
print_help(*argv);
else
{
diff --git a/parser.cpp b/parser.cpp
index 8fbbc4e..6b52c7a 100644
--- a/parser.cpp
+++ b/parser.cpp
@@ -186,8 +186,8 @@ Pair *ASTGenerator::absorb(Tokenizor *tk) {
if (obj->is_sym_obj() && static_cast<SymObj*>(obj)->val == ".")
{
if (improper ||
- lst == empty_list ||
- TO_PAIR(lst)->cdr != empty_list)
+ lst == empty_list ||
+ TO_PAIR(lst)->cdr != empty_list)
throw NormalError(PAR_ERR_IMPROPER_PAIR);
improper = true;
Pair *_lst = TO_PAIR(lst);
diff --git a/types.cpp b/types.cpp
index 9ace5ce..f074ec3 100644
--- a/types.cpp
+++ b/types.cpp
@@ -396,7 +396,7 @@ EvalObj *Environment::get_obj(EvalObj *obj) {
}
Continuation::Continuation(Environment *_envt, Pair *_pc,
- Continuation *_prev_cont ) :
+ Continuation *_prev_cont ) :
Container(), prev_cont(_prev_cont), envt(_envt), pc(_pc),
state(NULL), prog(NULL), tail(false) {
gc.attach(prev_cont);