0
|
1 /*
|
|
2 Copyright (C) 1988,2005, Shinji Kono
|
|
3 Everyone is permitted to copy and distribute verbatim copies
|
|
4 of this license, but changing it is not allowed. You can also
|
|
5 use this wording to make the terms for other programs.
|
|
6
|
|
7 send your comments to kono@ie.u-ryukyu.ac.jp
|
|
8 */
|
|
9
|
|
10 /*
|
|
11 tokio compier function evaluator
|
|
12 Sat Jan 11 12:11:22 JST 1986
|
|
13 */
|
|
14
|
|
15 /*
|
|
16 Now we move hole computation routines to tp
|
|
17 preprocessor part. So we only try to make temporal varible
|
|
18 structures here.
|
|
19 */
|
|
20
|
|
21 % c_eval(Expression, Generate_Expression, Qhead, Qtail, Control).
|
|
22
|
|
23 c_eval(Var, Now, Q, Q, _C) :-
|
|
24 variable(Var),!,
|
|
25 c_seperate_now(Var, Now).
|
|
26 %c_eval(Exp, Value, Q, Q1, C) :- n_function(Exp,A,B,Exp1,AA,BB),!,
|
|
27 % c_eval_exp(A, AA, Q, Q2, C),
|
|
28 % c_eval_exp(B, BB, Q2, (Value is Exp1,Q1), C).
|
|
29 c_eval(Atomic, Atomic, Q, Q, _C) :- atomic(Atomic),!.
|
|
30 c_eval(@E, Next, Q, Q1, C) :- !,
|
|
31 c_seperate_next(E, EE),
|
|
32 c_eval(EE, Next, Q, Q1, C).
|
|
33 % c_eval(*S, Value, Q, Q1, C) :- !, % move into tp (macro expanstion)
|
|
34 % c_eval(S, Name, Q, ('r_read_value'(Name,Value),Q1), C).
|
|
35 c_eval(Func, Value, Q, Q1, C) :-
|
|
36 functor(Func, H, A), functor(Value, H, A),
|
|
37 c_eval_arg(0, A, Func, Value, Q, Q1, C).
|
|
38
|
|
39 c_eval_arg(N, N, _, _, Q, Q, _) :- !.
|
|
40 c_eval_arg(N, M, A, B, Q, Q2, C) :-
|
|
41 N1 is N+1,
|
|
42 arg(N1, A, A1), arg(N1, B, B1),
|
|
43 c_eval(A1, B1, Q, Q1, C),
|
|
44 c_eval_arg(N1, M, A, B, Q1, Q2, C).
|
|
45
|
|
46 %c_eval_exp(Exp, Exp1, Q, Q1, C) :- nonvar(Exp),
|
|
47 % n_function(Exp,A,B,Exp1,AA,BB),!,
|
|
48 % c_eval_exp(A, AA, Q, Q2, C),
|
|
49 % c_eval_exp(B, BB, Q2, Q1, C).
|
|
50 %c_eval_exp(Exp, Exp1, Q, Q1, C) :-
|
|
51 % c_eval(Exp, Exp1, Q, Q1, C).
|
|
52
|
|
53 c_hex(H,V) :- c_hex(H,0,V).
|
|
54 c_hex([],V,V):-!.
|
|
55 c_hex([H|T],V,V1) :- c_hex1([H],VH), V2 is V*16+VH,
|
|
56 c_hex(T,V2,V1).
|
|
57
|
|
58 c_binary(H,V) :- c_binary(H,0,V).
|
|
59 c_binary([],V,V):-!.
|
|
60 c_binary([H|T],V,V1) :- c_binary1([H],VH), V2 is V*2+VH,
|
|
61 c_binary(T,V2,V1).
|
|
62
|
|
63 c_binary1("0",0). c_binary1("1",1).
|
|
64
|
|
65 c_hex1("0",0). c_hex1("1",1). c_hex1("2",2). c_hex1("3",3).
|
|
66 c_hex1("4",4). c_hex1("5",5). c_hex1("6",6). c_hex1("7",7).
|
|
67 c_hex1("8",8). c_hex1("9",9). c_hex1("A",10). c_hex1("B",11).
|
|
68 c_hex1("C",12). c_hex1("D",13). c_hex1("E",14). c_hex1("F",15).
|
|
69 c_hex1("a",10). c_hex1("b",11). c_hex1("c",12). c_hex1("d",13).
|
|
70 c_hex1("e",14). c_hex1("f",15).
|
|
71
|
|
72 n_predicate(A<B,A,B,AA<BB,AA,BB).
|
|
73 n_predicate(A>B,A,B,AA>BB,AA,BB).
|
|
74 n_predicate(A=<B,A,B,AA=<BB,AA,BB).
|
|
75 n_predicate(A>=B,A,B,AA>=BB,AA,BB).
|
|
76 n_predicate(A\=B,A,B,AA\==BB,AA,BB).
|
|
77
|
|
78 % n_function(cputime,0,0,cputime,_,_).
|
|
79 n_function(A+B,A,B,AA+BB,AA,BB).
|
|
80 n_function(A-B,A,B,AA-BB,AA,BB).
|
|
81 n_function(A*B,A,B,AA*BB,AA,BB).
|
|
82 n_function(A/B,A,B,AA/BB,AA,BB).
|
|
83 n_function(A//B,A,B,AA//BB,AA,BB).
|
|
84 n_function(A^B,A,B,AA^BB,AA,BB).
|
|
85 n_function(A mod B,A,B,AA mod BB,AA,BB).
|
|
86 n_function(A/\B,A,B,AA/\BB,AA,BB).
|
|
87 n_function(A\/B,A,B,AA\/BB,AA,BB).
|
|
88 n_function(A<<B,A,B,AA<<BB,AA,BB).
|
|
89 n_function(A>>B,A,B,AA>>BB,AA,BB).
|
|
90
|
|
91 /* evalator end */
|