Skip to content

Commit da6aa7a

Browse files
committed
update version number
1 parent 15fab78 commit da6aa7a

8 files changed

Lines changed: 168 additions & 159 deletions

File tree

builtin.c

Lines changed: 52 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ void init_builtin(void)
103103
defbuiltin("heapd", b_heapdump, 2);
104104
defbuiltin("ifthen", b_ifthen, 2);
105105
defbuiltin("ifthenelse", b_ifthenelse, 3);
106-
defbuiltin("case", b_case, 1);
106+
defbuiltin("case", b_case, 1);
107107
defbuiltin("inc", b_inc, 2);
108108
defbuiltin("instance", b_instance, 2);
109109
defbuiltin("integer", b_integer, 1);
@@ -322,8 +322,8 @@ void init_builtin(void)
322322
defbuiltin("n_generate_variable", b_n_generate_variable, 2);
323323
defbuiltin("n_clause_with_arity", b_n_clause_with_arity, 3);
324324
defbuiltin("n_property", b_n_property, 2);
325-
defbuiltin("n_imported_predicate", b_n_imported_predicate, 1);
326-
defbuiltin("n_imported_userop", b_n_imported_userop, 1);
325+
defbuiltin("n_imported_predicate", b_n_imported_predicate, 1);
326+
defbuiltin("n_imported_userop", b_n_imported_userop, 1);
327327
defbuiltin("n_bignum", b_n_bignum, 1);
328328
defbuiltin("n_longnum", b_n_longnum, 1);
329329
defbuiltin("n_findatom", b_n_findatom, 3);
@@ -341,9 +341,9 @@ void init_builtin(void)
341341
defbuiltin("n_exec_greater", b_n_exec_greater, 2);
342342
defbuiltin("n_exec_eqsmaller", b_n_exec_eqsmaller, 2);
343343
defbuiltin("n_exec_eqgreater", b_n_exec_eqgreater, 2);
344-
defbuiltin("n_exec_no_operation",b_n_exec_no_operation, 0);
345-
defbuiltin("n_exec_ifthen",b_n_exec_ifthen, 2);
346-
defbuiltin("n_exec_ifthenelse",b_n_exec_ifthenelse, 3);
344+
defbuiltin("n_exec_no_operation", b_n_exec_no_operation, 0);
345+
defbuiltin("n_exec_ifthen", b_n_exec_ifthen, 2);
346+
defbuiltin("n_exec_ifthenelse", b_n_exec_ifthenelse, 3);
347347

348348

349349
builtins = reverse(builtins);
@@ -360,40 +360,41 @@ int exec_all(int goals, int bindings, int th)
360360
if (IS_NIL(goals))
361361
return (YES);
362362
// ((D1;D2),Xs)
363-
else if (structurep(goals) && car(goals) == AND && structurep(cadr(goals)) && car(cadr(goals)) == OR) {
363+
else if (structurep(goals) && car(goals) == AND
364+
&& structurep(cadr(goals)) && car(cadr(goals)) == OR) {
364365
if (exec_all(cadr(cadr(goals)), bindings, th) == YES)
365366
if (exec_all(caddr(goals), sp[th], th) == YES)
366-
return(YES);
367-
unbind(bindings,th);
367+
return (YES);
368+
unbind(bindings, th);
368369
if (exec_all(caddr(cadr(goals)), bindings, th) == YES)
369370
if (exec_all(caddr(goals), sp[th], th) == YES)
370-
return(YES);
371-
unbind(bindings,th);
371+
return (YES);
372+
unbind(bindings, th);
372373
return (NO);
373374
}
374-
// (D1,D2)
375-
else if(structurep(goals) && car(goals) == OR){
376-
if (exec_all(cadr(goals), bindings, th) == YES)
377-
return(YES);
378-
unbind(bindings,th);
375+
// (D1,D2)
376+
else if (structurep(goals) && car(goals) == OR) {
377+
if (exec_all(cadr(goals), bindings, th) == YES)
378+
return (YES);
379+
unbind(bindings, th);
379380
if (exec_all(caddr(goals), bindings, th) == YES)
380-
return(YES);
381-
unbind(bindings,th);
381+
return (YES);
382+
unbind(bindings, th);
382383
return (NO);
383-
}
384+
}
384385
// ((D1,D2),Xs)
385386
else if (structurep(goals) && car(goals) == AND
386387
&& car(cadr(goals)) == AND) {
387388
if (exec_all(cadr(goals), bindings, th) == YES)
388389
return (exec_all(caddr(goals), bindings, th));
389390
else
390391
return (NO);
391-
}
392-
// predicate P
393-
else if ((structurep(goals) && car(goals) != AND) || atomp(goals))
392+
}
393+
// predicate P
394+
else if ((structurep(goals) && car(goals) != AND) || atomp(goals))
394395
return (exec(goals, bindings, NIL, th));
395396
// (P1,P2,...)
396-
else {
397+
else {
397398
return (exec(cadr(goals), bindings, caddr(goals), th));
398399
}
399400

@@ -1850,8 +1851,9 @@ int b_reconsult(int arglist, int rest, int th)
18501851
&& length(clause) == 2) {
18511852
clause = cadr(clause);
18521853
prove_all(clause, sp[th], th);
1853-
if (compiler_flag && builtinp(clause) && compoundp(clause) && car(clause) == makesys("initialization"))
1854-
goto skip;
1854+
if (compiler_flag && builtinp(clause) && compoundp(clause)
1855+
&& car(clause) == makesys("initialization"))
1856+
goto skip;
18551857

18561858
if (!module_flag && car(clause) != makesys("op"))
18571859
execute_list = cons(clause, execute_list);
@@ -2405,7 +2407,7 @@ int b_n_equalp(int arglist, int rest, int th)
24052407
if (anonymousp(arg1) || anonymousp(arg2))
24062408
return (YES);
24072409
else if (variablep(arg1) || variablep(arg2))
2408-
return (YES);
2410+
return (YES);
24092411
else if (equalp(arg1, arg2))
24102412
return (prove_all(rest, sp[th], th));
24112413
else
@@ -3953,7 +3955,7 @@ int b_ifthenelse(int arglist, int rest, int th)
39533955
return (prove_all(addtail_body(rest, arg2, th), sp[th], th));
39543956
} else {
39553957
unbind(save1, th);
3956-
return (prove_all(addtail_body(rest, arg3, th), sp[th], th));
3958+
return (prove_all(addtail_body(rest, arg3, th), sp[th], th));
39573959
}
39583960
}
39593961
exception(ARITY_ERR, ind, arglist, th);
@@ -3963,18 +3965,18 @@ int b_ifthenelse(int arglist, int rest, int th)
39633965
int case_list_p(int x)
39643966
{
39653967

3966-
int elt;
3967-
if (predicatep(x) || builtinp(x) || compiledp(x) || conjunctionp(x))
3968-
return(1);
3969-
else if(nullp(x))
3970-
return(0);
3971-
else {
3972-
elt = car(x);
3973-
if (!(predicatep(elt) && car(elt) == IFTHEN))
3974-
return (case_list_p(cdr(x)));
3975-
else
3976-
return 0;
3977-
}
3968+
int elt;
3969+
if (predicatep(x) || builtinp(x) || compiledp(x) || conjunctionp(x))
3970+
return (1);
3971+
else if (nullp(x))
3972+
return (0);
3973+
else {
3974+
elt = car(x);
3975+
if (!(predicatep(elt) && car(elt) == IFTHEN))
3976+
return (case_list_p(cdr(x)));
3977+
else
3978+
return 0;
3979+
}
39783980
}
39793981

39803982
int b_case(int arglist, int rest, int th)
@@ -3990,14 +3992,18 @@ int b_case(int arglist, int rest, int th)
39903992
if (!(listp(arg1) && case_list_p(arg1)))
39913993
exception(ILLEGAL_ARGS, ind, arg1, th);
39923994

3993-
while(!(predicatep(arg1) || builtinp(arg1) || compiledp(arg1) || conjunctionp(arg1))){
3994-
ifthen = car(arg1);
3995-
if (prove_all(cadr(ifthen), sp[th], th) == YES)
3996-
return (prove_all(addtail_body(rest, caddr(ifthen), th), sp[th], th));
3997-
arg1 = cdr(arg1);
3998-
unbind(save1, th);
3995+
while (!
3996+
(predicatep(arg1) || builtinp(arg1) || compiledp(arg1)
3997+
|| conjunctionp(arg1))) {
3998+
ifthen = car(arg1);
3999+
if (prove_all(cadr(ifthen), sp[th], th) == YES)
4000+
return (prove_all
4001+
(addtail_body(rest, caddr(ifthen), th), sp[th],
4002+
th));
4003+
arg1 = cdr(arg1);
4004+
unbind(save1, th);
39994005
}
4000-
4006+
40014007
return (prove_all(addtail_body(rest, arg1, th), sp[th], th));
40024008

40034009
}

data.c

Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,7 +1796,7 @@ int unify(int x, int y, int th)
17961796

17971797
if (nullp(x) && nullp(y))
17981798
return (YES);
1799-
else if (anonymousp(x) || anonymousp(y))
1799+
else if (anonymousp(x) || anonymousp(y))
18001800
return (YES);
18011801
else if (variablep(x) && !variablep(y)) {
18021802
x1 = deref1(x, th);
@@ -1870,17 +1870,17 @@ int unify(int x, int y, int th)
18701870
//typed unify. y is a pair list e.g. [L|Ls]
18711871
int unify_pair(int x, int y, int th)
18721872
{
1873-
int x1;
1874-
if (anonymousp(x)) {
1875-
return(YES);
1876-
} else if (variablep(x)) {
1877-
x1 = deref(x,th);
1878-
if(variablep(x1)){
1879-
bindsym(x, y, th);
1873+
int x1;
1874+
if (anonymousp(x)) {
18801875
return (YES);
1881-
} else
1882-
return(unify_pair(x1,y,th));
1883-
1876+
} else if (variablep(x)) {
1877+
x1 = deref(x, th);
1878+
if (variablep(x1)) {
1879+
bindsym(x, y, th);
1880+
return (YES);
1881+
} else
1882+
return (unify_pair(x1, y, th));
1883+
18841884
} else if (!listp(x))
18851885
return (NO);
18861886
else if (listp(x) && x != NIL && unify_var(car(x), car(y), th) == YES
@@ -1896,16 +1896,16 @@ int unify_pair(int x, int y, int th)
18961896
//typed unify. y is a small integer
18971897
int unify_int(int x, int y, int th)
18981898
{
1899-
int x1;
1900-
if (anonymousp(x)) {
1901-
return(YES);
1902-
} else if (variablep(x)) {
1903-
x1 = deref(x,th);
1904-
if (variablep(x1)){
1905-
bindsym(x, y, th);
1899+
int x1;
1900+
if (anonymousp(x)) {
19061901
return (YES);
1907-
} else
1908-
return(unify_int(x1,y,th));
1902+
} else if (variablep(x)) {
1903+
x1 = deref(x, th);
1904+
if (variablep(x1)) {
1905+
bindsym(x, y, th);
1906+
return (YES);
1907+
} else
1908+
return (unify_int(x1, y, th));
19091909
} else if (!integerp(x))
19101910
return (NO);
19111911
else if (eqp(x, y))
@@ -1919,16 +1919,16 @@ int unify_int(int x, int y, int th)
19191919
//typed unify. y is a float
19201920
int unify_flt(int x, int y, int th)
19211921
{
1922-
int x1;
1923-
if (anonymousp(x)) {
1924-
return(YES);
1925-
} else if (variablep(x)) {
1926-
x1 = deref(x,th);
1927-
if (variablep(x1)){
1928-
bindsym(x, y, th);
1922+
int x1;
1923+
if (anonymousp(x)) {
19291924
return (YES);
1930-
} else
1931-
return(unify_flt(x1,y,th));
1925+
} else if (variablep(x)) {
1926+
x1 = deref(x, th);
1927+
if (variablep(x1)) {
1928+
bindsym(x, y, th);
1929+
return (YES);
1930+
} else
1931+
return (unify_flt(x1, y, th));
19321932
} else if (!floatp(x))
19331933
return (NO);
19341934
else if (numeqp(x, y))
@@ -1943,16 +1943,16 @@ int unify_flt(int x, int y, int th)
19431943
//typed unify. y is a long integer
19441944
int unify_long(int x, int y, int th)
19451945
{
1946-
int x1;
1947-
if (anonymousp(x)) {
1948-
return(YES);
1949-
} else if (variablep(x)) {
1950-
x1 = deref(x,th);
1951-
if(variablep(x1)){
1952-
bindsym(x, y, th);
1946+
int x1;
1947+
if (anonymousp(x)) {
19531948
return (YES);
1954-
} else
1955-
return(unify_long(x1,y,th));
1949+
} else if (variablep(x)) {
1950+
x1 = deref(x, th);
1951+
if (variablep(x1)) {
1952+
bindsym(x, y, th);
1953+
return (YES);
1954+
} else
1955+
return (unify_long(x1, y, th));
19561956

19571957
} else if (!longnump(x))
19581958
return (NO);
@@ -1967,16 +1967,16 @@ int unify_long(int x, int y, int th)
19671967
//typed unify. y is a long integer
19681968
int unify_big(int x, int y, int th)
19691969
{
1970-
int x1;
1971-
if (anonymousp(x)) {
1972-
return(YES);
1973-
} else if (variablep(x)) {
1974-
x1 = deref(x,th);
1975-
if (variablep(x1)){
1976-
bindsym(x, y, th);
1970+
int x1;
1971+
if (anonymousp(x)) {
19771972
return (YES);
1978-
} else
1979-
return(unify_big(x1,y,th));
1973+
} else if (variablep(x)) {
1974+
x1 = deref(x, th);
1975+
if (variablep(x1)) {
1976+
bindsym(x, y, th);
1977+
return (YES);
1978+
} else
1979+
return (unify_big(x1, y, th));
19801980

19811981
} else if (!bignump(x))
19821982
return (NO);
@@ -1991,16 +1991,16 @@ int unify_big(int x, int y, int th)
19911991
//typed unify. y is an atom
19921992
int unify_atom(int x, int y, int th)
19931993
{
1994-
int x1;
1995-
if (anonymousp(x)) {
1996-
return(YES);
1997-
} else if (variablep(x)) {
1998-
x1 = deref(x,th);
1999-
if (variablep(x1)){
2000-
bindsym(x, y, th);
2001-
return (YES);
2002-
} else
2003-
return (unify_atom(x1,y,th));
1994+
int x1;
1995+
if (anonymousp(x)) {
1996+
return (YES);
1997+
} else if (variablep(x)) {
1998+
x1 = deref(x, th);
1999+
if (variablep(x1)) {
2000+
bindsym(x, y, th);
2001+
return (YES);
2002+
} else
2003+
return (unify_atom(x1, y, th));
20042004
} else if (!atomp(x))
20052005
return (NO);
20062006
else if (eqlp(x, y))
@@ -2014,16 +2014,16 @@ int unify_atom(int x, int y, int th)
20142014
//typed unify. y is a string
20152015
int unify_str(int x, int y, int th)
20162016
{
2017-
int x1;
2018-
if (anonymousp(x)) {
2019-
return(YES);
2020-
} else if (variablep(x)) {
2021-
x1 = deref(x,th);
2022-
if (variablep(x1)){
2023-
bindsym(x, y, th);
2024-
return (YES);
2025-
} else
2026-
return (unify_str(x1,y,th));
2017+
int x1;
2018+
if (anonymousp(x)) {
2019+
return (YES);
2020+
} else if (variablep(x)) {
2021+
x1 = deref(x, th);
2022+
if (variablep(x1)) {
2023+
bindsym(x, y, th);
2024+
return (YES);
2025+
} else
2026+
return (unify_str(x1, y, th));
20272027
} else if (!stringp(x))
20282028
return (NO);
20292029
else if (streqp(x, y))
@@ -2039,9 +2039,9 @@ int unify_var(int x, int y, int th)
20392039
{
20402040
int x1, y1;
20412041

2042-
if (anonymousp(x)) {
2043-
return(YES);
2044-
} else if (!variablep(x)) {
2042+
if (anonymousp(x)) {
2043+
return (YES);
2044+
} else if (!variablep(x)) {
20452045
y1 = deref1(y, th);
20462046
if (y1 == y) {
20472047
bindsym(y, x, th);
@@ -2506,7 +2506,7 @@ int alpha_to_variable(int x)
25062506

25072507
sprintf(str, "_v%d", x - cell_size);
25082508
res = makeatom(str, VAR);
2509-
SET_CAR(res,UNBIND);
2509+
SET_CAR(res, UNBIND);
25102510
return (res);
25112511
}
25122512

0 commit comments

Comments
 (0)