Skip to content

Commit

Permalink
Re indent with -orig option
Browse files Browse the repository at this point in the history
  • Loading branch information
sasagawa888 committed Nov 14, 2021
1 parent 42c1409 commit f8124d1
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 83 deletions.
3 changes: 2 additions & 1 deletion cell.c
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ makefunc(const char *pname, int addr)
// argument
if (generic_func != NIL)
SET_PROP(val, cons(next_method, generic_vars)); // method
//
//
// of
// generic-function
// and
Expand Down Expand Up @@ -1037,6 +1037,7 @@ initinst(int x, int initls)
//
//
//
//
// ((initarg1 . accessor1)(initarg2 .
// accesor2)...)
inst_vars = GET_CDR(x); // instance variable list. This is assoc
Expand Down
1 change: 1 addition & 0 deletions compute.c
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,7 @@ lcm(int x, int y)
//
//
//
//
// x,y
// <
// sqrt(BIGNUM_BASE)
Expand Down
73 changes: 41 additions & 32 deletions data.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,56 +607,65 @@ symbol_list_p(int ls)
return (symbol_list_p(cdr(ls)));
}

int has_multiple_call_next_method_p(int x){
int count,ls;
int
has_multiple_call_next_method_p(int x)
{
int count,
ls;

count = 0;
ls = x;

while(!nullp(ls)){
if(has_multiple_call_next_method_p1(car(ls)))
count++;
if(has_multiple_call_next_method_p2(car(ls)))
return(1);
ls = cdr(ls);
while (!nullp(ls)) {
if (has_multiple_call_next_method_p1(car(ls)))
count++;
if (has_multiple_call_next_method_p2(car(ls)))
return (1);

ls = cdr(ls);
}
if(count >= 2)
return(1);
else
return(0);
if (count >= 2)
return (1);
else
return (0);
}

int has_multiple_call_next_method_p1(int x){
if(nullp(x))
return(0);
else if(symbolp(x) && eqp(x,makesym("CALL-NEXT-METHOD")))
return(1);
int
has_multiple_call_next_method_p1(int x)
{
if (nullp(x))
return (0);
else if (symbolp(x) && eqp(x, makesym("CALL-NEXT-METHOD")))
return (1);
else if (atomp(x))
return(0);
else if(has_multiple_call_next_method_p1(car(x)) || has_multiple_call_next_method_p1(cdr(x)))
return(1);
return (0);
else if (has_multiple_call_next_method_p1(car(x))
|| has_multiple_call_next_method_p1(cdr(x)))
return (1);
else
return(0);
return (0);

}

// e.g. (list (call-next-method) (call-next-method))
int has_multiple_call_next_method_p2(int x){
int count,ls;
int
has_multiple_call_next_method_p2(int x)
{
int count,
ls;

count = 0;
ls = x;
while(!nullp(ls)){
if(has_multiple_call_next_method_p1(car(ls)))
count++;
ls = cdr(ls);
while (!nullp(ls)) {
if (has_multiple_call_next_method_p1(car(ls)))
count++;

ls = cdr(ls);
}
if(count >= 2)
return(1);
if (count >= 2)
return (1);
else
return(0);
return (0);
}

// --------------list operation---------------------
Expand Down
1 change: 1 addition & 0 deletions edit.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ display_buffer()
//
//
//
//
// #|...|#
ESCBOLD();
setcolor(ed_comment_color);
Expand Down
1 change: 1 addition & 0 deletions edlis.c
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,7 @@ display_line(int line)
//
//
//
//
// #|...|#
ESCBOLD();
setcolor(ed_comment_color);
Expand Down
5 changes: 3 additions & 2 deletions extension.c
Original file line number Diff line number Diff line change
Expand Up @@ -762,8 +762,9 @@ superp(int entry, int next)
return (superp(cdr(entry), cdr(next)));
else if (subclassp(GET_AUX(cadar(next)), GET_AUX(cadar(entry)))) // subclass
return (superp(cdr(entry), cdr(next)));
else if (eqp(GET_AUX(cadar(next)), GET_AUX(cadar(entry)))) // same class
return (superp(cdr(entry), cdr(next)));
else if (eqp(GET_AUX(cadar(next)), GET_AUX(cadar(entry)))) // same
// class
return (superp(cdr(entry), cdr(next)));
else
return (0);
}
23 changes: 13 additions & 10 deletions function.c
Original file line number Diff line number Diff line change
Expand Up @@ -3289,6 +3289,7 @@ f_string_index(int arglist)
//
//
//
//
// "" "")
return (makeint(0));

Expand Down Expand Up @@ -3962,6 +3963,7 @@ f_format_fresh_line(int arglist)
//
//
//
//
// stream is at the begining of a fresh line
if (GET_OPT(output_stream) == EISL_OUTSTR
&& strlen(GET_NAME(output_stream)) == 0) {
Expand Down Expand Up @@ -4984,29 +4986,30 @@ f_call_next_method(int arglist)
|| GET_OPT(car(next_method)) == PRIMARY) {
varlist = genlamlis_to_lamlis(varlist);
body = cdr(GET_CAR(car(next_method)));
save2 = multiple_call_next_method;
multiple_call_next_method = has_multiple_call_next_method_p(body);
save2 = multiple_call_next_method;
multiple_call_next_method =
has_multiple_call_next_method_p(body);
bindarg(varlist, generic_vars);
while (!nullp(body)) {
res = eval(car(body));
body = cdr(body);
}
multiple_call_next_method = save2;
multiple_call_next_method = save2;
unbind();
}
if (GET_OPT(car(next_method)) == AROUND){
goto exit;
}
if (GET_OPT(car(next_method)) == AROUND) {
goto exit;
}
}
next_method = cdr(next_method);
}
exit:
exit:
if (pexist == 0 && qexist == 0)
error(NOT_EXIST_METHOD, "call-next-method", generic_vars);

if(multiple_call_next_method){
next_method = save1;
}
if (multiple_call_next_method) {
next_method = save1;
}


return (res);
Expand Down
15 changes: 9 additions & 6 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ bool greeting_flag = true; // for (quit)
bool script_flag = false; // for -s option
bool handling_resource_err = false; // stop infinite recursion
bool looking_for_shebang = false; // skip over #!
bool multiple_call_next_method; // method body has multiple (call-next-method)
bool multiple_call_next_method; // method body has
// multiple
// (call-next-method)

// switch
int gc_sw = 0; // 0= mark-and-sweep-GC 1= copy-GC
Expand Down Expand Up @@ -1727,17 +1729,18 @@ DEF_GETTER(char, TR, trace, NIL)
&& matchp(varlist, args) && pexist == 0)) {

if (GET_OPT(car(next_method)) == PRIMARY) {
// primary method must executes only once.
if(pexist == 1){
goto exit;
}
// primary method must executes only once.
if (pexist == 1) {
goto exit;
}
pexist = 1;
} else {
qexist = 1;
}
varlist = genlamlis_to_lamlis(varlist);
body = cdr(GET_CAR(car(next_method)));
multiple_call_next_method = has_multiple_call_next_method_p(body);
multiple_call_next_method =
has_multiple_call_next_method_p(body);
bindarg(varlist, args);
while (!nullp(body)) {
res = eval(car(body));
Expand Down
71 changes: 39 additions & 32 deletions syntax.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,14 +484,14 @@ f_setf(int arglist)
cons(arg2,
list2(cadr(arg1), list2(makesym("QUOTE"), var))));
}
// e.g. when (setf (foo 1 2) 3) foo was define with (defgeneric (setf foo) (x y z))
else if (listp(arg1)){
// e.g. above case (foo 3 1 2)
newform = cons(car(arg1),cons(arg2,cdr(arg1)));
if(!genericp(car(arg1)))
error(ILLEGAL_FORM,"setf",arg1);
}
else if (symbolp(arg1)) {
// e.g. when (setf (foo 1 2) 3) foo was define with (defgeneric (setf
// foo) (x y z))
else if (listp(arg1)) {
// e.g. above case (foo 3 1 2)
newform = cons(car(arg1), cons(arg2, cdr(arg1)));
if (!genericp(car(arg1)))
error(ILLEGAL_FORM, "setf", arg1);
} else if (symbolp(arg1)) {
newform = cons(makesym("SETQ"), list2(arg1, arg2));
} else
error(IMPROPER_ARGS, "setf", arglist);
Expand Down Expand Up @@ -1234,6 +1234,7 @@ f_catch(int arglist)
//
//
//
//
// sp
return (res);
}
Expand Down Expand Up @@ -1796,7 +1797,7 @@ f_defgeneric(int arglist)
arg2,
arg3,
val;

arg1 = car(arglist); // func-name
arg2 = cadr(arglist); // lambda-list
arg3 = cddr(arglist); // body
Expand All @@ -1809,12 +1810,16 @@ f_defgeneric(int arglist)
if (symbolp(arg1) && (genericp(arg1) && eqp(arg1, makesym("CREATE")))) {
error(CANT_MODIFY, "defgeneric", arg1);
}
if (symbolp(arg1) && (STRING_REF(arg1, 0) == ':' || STRING_REF(arg1, 0) == '&')){
if (symbolp(arg1)
&& (STRING_REF(arg1, 0) == ':' || STRING_REF(arg1, 0) == '&')) {
error(WRONG_ARGS, "defgeneric", arg1);
}
if (!symbolp(arg1) && (listp(arg1) && !(length(arg1) == 2 && eqp(car(arg1),makesym("SETF")) && symbolp(cadr(arg1))))){
error(ILLEGAL_FORM, "defgeneric", arg1);
}
}
if (!symbolp(arg1)
&& (listp(arg1)
&& !(length(arg1) == 2 && eqp(car(arg1), makesym("SETF"))
&& symbolp(cadr(arg1))))) {
error(ILLEGAL_FORM, "defgeneric", arg1);
}
if (!listp(arg2)) {
error(NOT_LIST, "defgeneric", arg2);
}
Expand All @@ -1827,15 +1832,14 @@ f_defgeneric(int arglist)
if (illegal_lambda_p(arg2)) {
error(ILLEGAL_ARGS, "defgeneric", arg2);
}
if (!top_flag && !ignore_topchk){
if (!top_flag && !ignore_topchk) {
error(NOT_TOP_LEVEL, "defgeneric", arglist);
}
}
// when (defgeneric (set foo) ...)
if (listp(arg1)) {
arg1 = cadr(arg1);
}

//when (defgeneric (set foo) ...)
if (listp(arg1)){
arg1 = cadr(arg1);
}

if (!member(arg1, generic_list))
generic_list = hcons(arg1, generic_list);

Expand Down Expand Up @@ -1893,17 +1897,20 @@ f_defmethod(int arglist)
if (symbolp(arg1) && (functionp(arg1) || macrop(arg1))) {
error(ILLEGAL_FORM, "defmethod", arg1);
}
if (symbolp(arg1) && (GET_CAR(arg1) == NIL && !member(arg1, generic_list))) {
if (symbolp(arg1)
&& (GET_CAR(arg1) == NIL && !member(arg1, generic_list))) {
error(UNDEF_FUN, "defmethod", arg1);
}
if (!symbolp(arg1) && (listp(arg1) && !(length(arg1) == 2 && eqp(car(arg1),makesym("SETF")) && symbolp(cadr(arg1))))){
error(ILLEGAL_FORM, "defmethod", arg1);
}

// when (defmethod (set foo) ...)
if(listp(arg1)){
arg1 = cadr(arg1);
}
if (!symbolp(arg1)
&& (listp(arg1)
&& !(length(arg1) == 2 && eqp(car(arg1), makesym("SETF"))
&& symbolp(cadr(arg1))))) {
error(ILLEGAL_FORM, "defmethod", arg1);
}
// when (defmethod (set foo) ...)
if (listp(arg1)) {
arg1 = cadr(arg1);
}

if (listp(car(arg2)) && illegal_lambda_p(car(arg2))) {
error(ILLEGAL_ARGS, "defmethod", arg2);
Expand All @@ -1927,8 +1934,8 @@ f_defmethod(int arglist)
// if (!top_flag && !ignore_topchk) {
// error(NOT_TOP_LEVEL, "defmethod", arglist);
// }


gen = generic_func = GET_CAR(arg1);
insert_method(makemethod(arg2), gen);
generic_func = NIL;
Expand Down

0 comments on commit f8124d1

Please sign in to comment.