/* * SPL - The SPL Programming Language * Copyright (C) 2004, 2005, 2006 Clifford Wolf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * mod_webdebug.spl: WebSPL Debugger */ /** * A module that implements an SPL debugger that can be used with a Web * Interface. * * Only load that module when you are in a save test environment do not let * end-users access the debugger frontend! */ load "cgi"; load "task"; load "encode_xml"; var __webdebug_id_counter = 0; var __webdebug_help_message = <:help> : :

This is the WebSPL Debugger

: : : :

: On the left hand side there is a tree-view of the current virtual machine : state. Navigating thru it should be very intuitive. The colored letters next : to the node name have the folowing meaning: :

: : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :
Vhas a value assignedShas child nodes (subs)
Ppointer (reference)Chas context pointer
Ffunction or methodRreturn pointer
Hhosted namespaceOclass (object)
ffunction contextoobject context
llocal contextrroot context
: :

: You can also run SPL code. Just enter the code in the form below. The code is : always executed in the context of the node you have currently selected in the : tree. :

: :
: ; function __webdebug_main() { var show_tasks = 1; var show_mods = 1; var tree_open; var info; while (1) { if (declared cgi.param.c) { write(<:> : : : ); task_kill(); } if (declared cgi.param.s) if (declared tree_open.[cgi.param.s]) delete tree_open.[cgi.param.s]; else tree_open.[cgi.param.s] = undef; if (declared cgi.param.i) info = cgi.param.i; if (declared cgi.param.o) info = cgi.param.o; if (declared cgi.param.r) info = tree_open = undef; if (declared cgi.param.m) show_mods = !show_mods; if (declared cgi.param.t) show_tasks = !show_tasks; if (declared cgi.param.x) { __webdebug_gettree(tree_open, "${cgi.url}?sid=${cgi.sid}", info, show_tasks, show_mods); write(<:> : : WebSPL Debug Window : : : : : :
:

Executed SPL Code:

:
${ xml::cgi.param.x }
: :

 

:

:
: : :
:
: :
:

Output:

); write(<:> : ${ __webdebug_exec(cgi.param.x) } :
: : ); } else write(<:> : : WebSPL Debug Window : : : : : : : : : : :
: : : : :
: :

[ Reset ]

: : ${ __webdebug_gettree(tree_open, "${cgi.url}?sid=${cgi.sid}", info, show_tasks, show_mods) } : : :
: :

: : : : : : :
${ show_tasks ? "ON" : "OFF" } Show Tasks
${ show_mods ? "ON" : "OFF" } Show Modules
: :

: :
: ${ defined info ? __webdebug_getinfo(info, "${cgi.url}?sid=${cgi.sid}") : __webdebug_help_message } :
:
: : :
: : :
:
:
: : ); task_pause(); } } /** * Create a Web Deugger task and return the URI for it. * E.g.: * * */ function webdebug() { var dbg_id = "webdebug_${__webdebug_id_counter}"; task_create(dbg_id, "while (1) { __webdebug_main(); }"); task_public(dbg_id); return "${cgi.url}?sid=${cgi.sid_vm ~ ":" ~ dbg_id}"; }