~ubuntu-branches/ubuntu/raring/parrot/raring-proposed

« back to all changes in this revision

Viewing changes to src/interp/inter_misc.c

  • Committer: Bazaar Package Importer
  • Author(s): Allison Randal
  • Date: 2011-07-30 18:45:03 UTC
  • mfrom: (1.1.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20110730184503-34d4mprtfx6pt5h3
Tags: 3.6.0-1
* New upstream release
* debian/watch:
  - Modified regular expression to capture numbered directory name
    (patch from Dominique Dumont).
* debian/rules:
  - Split build-arch and build-indep, resolving lintian warning.
  - Update path to pbc_disassemble for manpage generation (patch
    from Dominique Dumont).
* debian/patches:
  - Added patch 02_fix_perl_interpreter_path.patch, resolving
    lintian warnings.
* debian/control:
  - Added DM-Upload-Allowed field.

Show diffs side-by-side

added added

removed removed

Lines of Context:
213
213
 
214
214
Compile code file.
215
215
 
 
216
TODO: This should take a PMC* option for the compiler to use. Do not assume
 
217
we have PIR/PASM compilers installed, and do not assume that the user is
 
218
going to want to use either of these. TT #2135.
 
219
 
216
220
=cut
217
221
 
218
222
*/
251
255
 
252
256
/*
253
257
 
 
258
=item C<Parrot_PMC Parrot_compile_string(PARROT_INTERP, Parrot_String type,
 
259
const char *code, Parrot_String *error)>
 
260
 
 
261
Compiles a code string.
 
262
 
 
263
DEPRECATED: Use Parrot_compile_file (or whatever replaces it, TT #2135).
 
264
 
 
265
=cut
 
266
 
 
267
*/
 
268
 
 
269
PARROT_EXPORT
 
270
PARROT_CAN_RETURN_NULL
 
271
PARROT_WARN_UNUSED_RESULT
 
272
Parrot_PMC
 
273
Parrot_compile_string(PARROT_INTERP, Parrot_String type, ARGIN(const char *code),
 
274
        ARGOUT(Parrot_String *error))
 
275
{
 
276
    ASSERT_ARGS(Parrot_compile_string)
 
277
    PMC * const compiler = Parrot_get_compiler(interp, type);
 
278
 
 
279
    /* XXX error is not being set */
 
280
    if (PMC_IS_NULL(compiler)) {
 
281
        Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNEXPECTED_NULL,
 
282
            "Could not find compiler %Ss", type);
 
283
    }
 
284
    else {
 
285
        PMC *result;
 
286
        STRING * const code_s = Parrot_str_new(interp, code, 0);
 
287
        imc_info_t * imcc     = (imc_info_t*) VTABLE_get_pointer(interp, compiler);
 
288
        const INTVAL is_pasm  = VTABLE_get_integer(interp, compiler);
 
289
 
 
290
        Parrot_block_GC_mark(interp);
 
291
        result = imcc_compile_string(imcc, code_s, is_pasm);
 
292
        if (PMC_IS_NULL(result)) {
 
293
            STRING * const msg = imcc_last_error_message(imcc);
 
294
            const INTVAL code  = imcc_last_error_code(imcc);
 
295
 
 
296
            Parrot_unblock_GC_mark(interp);
 
297
            Parrot_ex_throw_from_c_args(interp, NULL, code, "%Ss", msg);
 
298
        }
 
299
        Parrot_unblock_GC_mark(interp);
 
300
        return result;
 
301
    }
 
302
}
 
303
 
 
304
/*
 
305
 
254
306
=item C<INTVAL interpinfo(PARROT_INTERP, INTVAL what)>
255
307
 
256
308
C<what> specifies the type of information you want about the interpreter.
454
506
    return ((Parrot_ParrotInterpreter_attributes*)interp_pmc->data)->interp;
455
507
}
456
508
 
 
509
/*
 
510
 
 
511
=item C<void Parrot_set_flag(PARROT_INTERP, INTVAL flag)>
 
512
 
 
513
Sets on any of the following flags, specified by C<flag>, in the interpreter:
 
514
 
 
515
Flag                    Effect
 
516
C<PARROT_BOUNDS_FLAG>   enable bounds checking
 
517
C<PARROT_PROFILE_FLAG>  enable profiling,
 
518
 
 
519
=cut
 
520
 
 
521
*/
 
522
 
 
523
PARROT_EXPORT
 
524
void
 
525
Parrot_set_flag(PARROT_INTERP, INTVAL flag)
 
526
{
 
527
    ASSERT_ARGS(Parrot_set_flag)
 
528
    /* These two macros (from interpreter.h) do exactly what they look like. */
 
529
 
 
530
    Interp_flags_SET(interp, flag);
 
531
    switch (flag) {
 
532
      case PARROT_BOUNDS_FLAG:
 
533
      case PARROT_PROFILE_FLAG:
 
534
        Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
 
535
        break;
 
536
      default:
 
537
        break;
 
538
    }
 
539
}
 
540
 
 
541
 
 
542
/*
 
543
 
 
544
=item C<void Parrot_set_debug(PARROT_INTERP, UINTVAL flag)>
 
545
 
 
546
Set a debug flag: C<PARROT_DEBUG_FLAG>.
 
547
 
 
548
=cut
 
549
 
 
550
*/
 
551
 
 
552
PARROT_EXPORT
 
553
void
 
554
Parrot_set_debug(PARROT_INTERP, UINTVAL flag)
 
555
{
 
556
    ASSERT_ARGS(Parrot_set_debug)
 
557
    interp->debug_flags |= flag;
 
558
}
 
559
 
 
560
 
 
561
/*
 
562
 
 
563
=item C<void Parrot_set_executable_name(PARROT_INTERP, STRING * const name)>
 
564
 
 
565
Sets the name of the executable launching Parrot (see C<pbc_to_exe> and the
 
566
C<parrot> binary).
 
567
 
 
568
=cut
 
569
 
 
570
*/
 
571
 
 
572
PARROT_EXPORT
 
573
void
 
574
Parrot_set_executable_name(PARROT_INTERP, ARGIN(STRING * const name))
 
575
{
 
576
    ASSERT_ARGS(Parrot_set_executable_name)
 
577
    PMC * const name_pmc = Parrot_pmc_new(interp, enum_class_String);
 
578
    VTABLE_set_string_native(interp, name_pmc, name);
 
579
    VTABLE_set_pmc_keyed_int(interp, interp->iglobals, IGLOBALS_EXECUTABLE,
 
580
        name_pmc);
 
581
}
 
582
 
 
583
 
 
584
/*
 
585
 
 
586
=item C<void Parrot_set_trace(PARROT_INTERP, UINTVAL flag)>
 
587
 
 
588
Set a trace flag: C<PARROT_TRACE_FLAG>
 
589
 
 
590
=cut
 
591
 
 
592
*/
 
593
 
 
594
PARROT_EXPORT
 
595
void
 
596
Parrot_set_trace(PARROT_INTERP, UINTVAL flag)
 
597
{
 
598
    ASSERT_ARGS(Parrot_set_trace)
 
599
    Parrot_pcc_trace_flags_on(interp, interp->ctx, flag);
 
600
    Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
 
601
}
 
602
 
 
603
 
 
604
/*
 
605
 
 
606
=item C<void Parrot_clear_flag(PARROT_INTERP, INTVAL flag)>
 
607
 
 
608
Clears a flag in the interpreter.
 
609
 
 
610
=cut
 
611
 
 
612
*/
 
613
 
 
614
PARROT_EXPORT
 
615
void
 
616
Parrot_clear_flag(PARROT_INTERP, INTVAL flag)
 
617
{
 
618
    ASSERT_ARGS(Parrot_clear_flag)
 
619
    Interp_flags_CLEAR(interp, flag);
 
620
}
 
621
 
 
622
 
 
623
/*
 
624
 
 
625
=item C<void Parrot_clear_debug(PARROT_INTERP, UINTVAL flag)>
 
626
 
 
627
Clears a flag in the interpreter.
 
628
 
 
629
=cut
 
630
 
 
631
*/
 
632
 
 
633
PARROT_EXPORT
 
634
void
 
635
Parrot_clear_debug(PARROT_INTERP, UINTVAL flag)
 
636
{
 
637
    ASSERT_ARGS(Parrot_clear_debug)
 
638
    interp->debug_flags &= ~flag;
 
639
}
 
640
 
 
641
 
 
642
/*
 
643
 
 
644
=item C<void Parrot_clear_trace(PARROT_INTERP, UINTVAL flag)>
 
645
 
 
646
Clears a flag in the interpreter.
 
647
 
 
648
=cut
 
649
 
 
650
*/
 
651
 
 
652
PARROT_EXPORT
 
653
void
 
654
Parrot_clear_trace(PARROT_INTERP, UINTVAL flag)
 
655
{
 
656
    ASSERT_ARGS(Parrot_clear_trace)
 
657
    Parrot_pcc_trace_flags_off(interp, interp->ctx, flag);
 
658
}
 
659
 
 
660
 
 
661
/*
 
662
 
 
663
=item C<Parrot_Int Parrot_test_flag(PARROT_INTERP, INTVAL flag)>
 
664
 
 
665
Test the interpreter flags specified in C<flag>.
 
666
 
 
667
=cut
 
668
 
 
669
*/
 
670
 
 
671
PARROT_EXPORT
 
672
PARROT_PURE_FUNCTION
 
673
Parrot_Int
 
674
Parrot_test_flag(PARROT_INTERP, INTVAL flag)
 
675
{
 
676
    ASSERT_ARGS(Parrot_test_flag)
 
677
    return Interp_flags_TEST(interp, flag);
 
678
}
 
679
 
 
680
 
 
681
/*
 
682
 
 
683
=item C<Parrot_UInt Parrot_test_debug(PARROT_INTERP, UINTVAL flag)>
 
684
 
 
685
Test the interpreter flags specified in C<flag>.
 
686
 
 
687
=cut
 
688
 
 
689
*/
 
690
 
 
691
PARROT_EXPORT
 
692
PARROT_PURE_FUNCTION
 
693
Parrot_UInt
 
694
Parrot_test_debug(PARROT_INTERP, UINTVAL flag)
 
695
{
 
696
    ASSERT_ARGS(Parrot_test_debug)
 
697
    return interp->debug_flags & flag;
 
698
}
 
699
 
 
700
 
 
701
/*
 
702
 
 
703
=item C<Parrot_UInt Parrot_test_trace(PARROT_INTERP, UINTVAL flag)>
 
704
 
 
705
Test the interpreter flags specified in C<flag>.
 
706
 
 
707
=cut
 
708
 
 
709
*/
 
710
 
 
711
PARROT_EXPORT
 
712
PARROT_PURE_FUNCTION
 
713
Parrot_UInt
 
714
Parrot_test_trace(PARROT_INTERP, UINTVAL flag)
 
715
{
 
716
    ASSERT_ARGS(Parrot_test_trace)
 
717
    return Parrot_pcc_trace_flags_test(interp, interp->ctx, flag);
 
718
}
 
719
 
 
720
 
 
721
/*
 
722
 
 
723
=item C<void Parrot_set_run_core(PARROT_INTERP, Parrot_Run_core_t core)>
 
724
 
 
725
Sets the specified run core.
 
726
 
 
727
=cut
 
728
 
 
729
*/
 
730
 
 
731
PARROT_EXPORT
 
732
void
 
733
Parrot_set_run_core(PARROT_INTERP, Parrot_Run_core_t core)
 
734
{
 
735
    ASSERT_ARGS(Parrot_set_run_core)
 
736
    switch (core) {
 
737
      case PARROT_SLOW_CORE:
 
738
        Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "slow"));
 
739
        break;
 
740
      case PARROT_FAST_CORE:
 
741
        Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "fast"));
 
742
        break;
 
743
      case PARROT_EXEC_CORE:
 
744
        Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "exec"));
 
745
        break;
 
746
      case PARROT_GC_DEBUG_CORE:
 
747
        Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "gc_debug"));
 
748
        break;
 
749
      case PARROT_DEBUGGER_CORE:
 
750
        Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "debugger"));
 
751
        break;
 
752
      case PARROT_PROFILING_CORE:
 
753
        Parrot_runcore_switch(interp, Parrot_str_new_constant(interp, "profiling"));
 
754
        break;
 
755
      default:
 
756
        Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_UNIMPLEMENTED,
 
757
                "Invalid runcore requested\n");
 
758
    }
 
759
}
 
760
 
 
761
 
 
762
/*
 
763
 
 
764
=item C<void Parrot_setwarnings(PARROT_INTERP, Parrot_warnclass wc)>
 
765
 
 
766
Activates the given warnings.
 
767
 
 
768
=cut
 
769
 
 
770
*/
 
771
 
 
772
PARROT_EXPORT
 
773
void
 
774
Parrot_setwarnings(PARROT_INTERP, Parrot_warnclass wc)
 
775
{
 
776
    ASSERT_ARGS(Parrot_setwarnings)
 
777
    /* Activates the given warnings.  (Macro from warnings.h.) */
 
778
    PARROT_WARNINGS_on(interp, wc);
 
779
}
 
780
 
 
781
/*
 
782
 
 
783
=back
 
784
 
 
785
=cut
 
786
 
 
787
*/
457
788
 
458
789
/*
459
790
 * Local variables: