~ubuntu-branches/ubuntu/intrepid/ecl/intrepid

« back to all changes in this revision

Viewing changes to src/c/interpreter.d

  • Committer: Bazaar Package Importer
  • Author(s): Peter Van Eynde
  • Date: 2007-04-09 11:51:51 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070409115151-ql8cr0kalzx1jmla
Tags: 0.9i-20070324-2
Upload to unstable. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 
15
15
#include <ecl/ecl.h>
16
16
#include <string.h>
 
17
#include <stdio.h>
17
18
#include <ecl/ecl-inl.h>
18
19
#include <ecl/bytecodes.h>
19
20
 
186
187
static void
187
188
lambda_bind_var(cl_object var, cl_object val, cl_object specials)
188
189
{
189
 
        if (!member_eq(var, specials))
 
190
        if (!ecl_member_eq(var, specials))
190
191
                bind_var(var, val);
191
192
        else
192
193
                bds_bind(var, val);
217
218
          } else {
218
219
            cl_object defaults = data[1];
219
220
            if (FIXNUMP(defaults)) {
220
 
              interpret(lambda, (cl_opcode*)lambda->bytecodes.code + fix(defaults));
 
221
              ecl_interpret(lambda, (cl_opcode*)lambda->bytecodes.code + fix(defaults));
221
222
              defaults = VALUES(0);
222
223
            }
223
224
            lambda_bind_var(data[0], defaults, specials);
303
304
            else {
304
305
              cl_object defaults = data[2];
305
306
              if (FIXNUMP(defaults)) {
306
 
                      interpret(lambda, (cl_opcode*)lambda->bytecodes.code + fix(defaults));
 
307
                      ecl_interpret(lambda, (cl_opcode*)lambda->bytecodes.code + fix(defaults));
307
308
                      defaults = VALUES(0);
308
309
              }
309
310
              lambda_bind_var(data[1],defaults,specials);
315
316
}
316
317
 
317
318
cl_object
318
 
lambda_apply(cl_narg narg, cl_object fun)
 
319
ecl_apply_lambda(cl_narg narg, cl_object fun)
319
320
{
320
321
        cl_index args = cl_stack_index() - narg;
321
322
        cl_object name;
337
338
        VALUES(0) = Cnil;
338
339
        NVALUES = 0;
339
340
        name = fun->bytecodes.name;
340
 
        interpret(fun, fun->bytecodes.code);
 
341
        ecl_interpret(fun, fun->bytecodes.code);
341
342
        bds_unwind(old_bds_top);
342
343
        ihs_pop();
343
344
        returnn(VALUES(0));
393
394
        }
394
395
#ifdef CLOS
395
396
        case t_instance:
396
 
                fun = compute_method(narg, fun, args);
 
397
                fun = _ecl_compute_method(narg, fun, args);
397
398
                if (fun == NULL) {
398
399
                        x = VALUES(0);
399
400
                        break;
401
402
                goto AGAIN;
402
403
#endif
403
404
        case t_bytecodes:
404
 
                x = lambda_apply(narg, fun);
 
405
                x = ecl_apply_lambda(narg, fun);
405
406
                break;
406
407
        case t_symbol: {
407
408
                cl_object function = SYM_FUN(fun);
556
557
        cl_object old_lex_env = cl_env.lex_env;
557
558
 
558
559
        /* 2) Add new bindings */
559
 
        while (!endp(vars)) {
 
560
        while (!ecl_endp(vars)) {
560
561
                if (values == Cnil)
561
562
                        bds_bind(CAR(vars), OBJNULL);
562
563
                else {
565
566
                }
566
567
                vars = CDR(vars);
567
568
        }
568
 
        vector = interpret(bytecodes, vector);
 
569
        vector = ecl_interpret(bytecodes, vector);
569
570
 
570
571
        /* 3) Restore environment */
571
572
        cl_env.lex_env = old_lex_env;
574
575
}
575
576
 
576
577
void *
577
 
interpret(cl_object bytecodes, void *pc) {
 
578
ecl_interpret(cl_object bytecodes, void *pc) {
578
579
        cl_opcode *vector = pc;
579
580
        cl_object reg0 = VALUES(0), reg1;
580
581
        static int i = 0;
832
833
        case OP_JEQL: {
833
834
                cl_oparg value = GET_OPARG(vector);
834
835
                cl_oparg jump = GET_OPARG(vector);
835
 
                if (eql(reg0, bytecodes->bytecodes.data[value]))
 
836
                if (ecl_eql(reg0, bytecodes->bytecodes.data[value]))
836
837
                        vector += jump - OPARG_SIZE;
837
838
                break;
838
839
        }
839
840
        case OP_JNEQL: {
840
841
                cl_oparg value = GET_OPARG(vector);
841
842
                cl_oparg jump = GET_OPARG(vector);
842
 
                if (!eql(reg0, bytecodes->bytecodes.data[value]))
 
843
                if (!ecl_eql(reg0, bytecodes->bytecodes.data[value]))
843
844
                        vector += jump - OPARG_SIZE;
844
845
                break;
845
846
        }
1162
1163
                reg0 = VALUES(0);
1163
1164
                n = fix(cl_stack_pop());
1164
1165
                if (n <= 0)
1165
 
                        unwind(cl_env.frs_top + n);
 
1166
                        ecl_unwind(cl_env.frs_top + n);
1166
1167
                break;
1167
1168
        }
1168
1169
        case OP_STEPIN: {