NAME

var.ops - Variable Opcodes

DESCRIPTION

These operations deal with both lexical and global variables, as well as the symbol tables that contain them.

Lexical variable ops

Operations to create, modify and delete lexical variables.

store_lex(in STR, invar PMC)
Store object $2 as lexical symbol $1. The opcode might succeed or throw an exception on unknown lexical names depending on the implementation of the LexPad PMC. Parrot's LexPad throws an exception for unknown names.
store_dynamic_lex(in STR, invar PMC)
Search caller lexpads for lexical symbol $1 and store object $2 there. Throws an exception if no caller lexpad claims the lexical symbol. (To store a value in the current lexpad, use store_lex above.)
find_lex(out PMC, in STR)
Find the lexical variable named $2 and store it in $1. This opcode either throws an exception or returns a Null PMC for the failure case, depending on the implementation of the LexPad PMC. Parrot's standard LexPad throws and exception for non-existing names.
find_dynamic_lex(out PMC, in STR)
Search through caller lexpads for a lexical variable named $2 and store it in $1. Return a Null PMC if the lexical variable is not found. (To search the current lexpad, use find_lex above.)
find_caller_lex(out PMC, in STR)
Like find_dynamic_lex above, but also searches caller's outer scopes in addition to the lexpads.

Namespace opcodes

get_namespace(out PMC)
Set $1 to the current namespace.
get_namespace(out PMC, in PMC)
Set $1 to the namespace denoted by the key constant $2, relative to the current namespace. If the namespace doesn't exist, $1 is set to null.
get_hll_namespace(out PMC)
Set $1 to the current HLL root namespace.
get_hll_namespace(out PMC, in PMC)
Set $1 to the namespace denoted by the key constant $2, relative to the current HLL root namespace. If the namespace doesn't exist, $1 is set to null.
get_root_namespace(out PMC)
Set $1 to the true root namespace.
get_root_namespace(out PMC, in PMC)
Set $1 to the namespace denoted by the key constant $2, relative to the true root namespace. If the namespace doesn't exist, $1 is set to null.

Global variable 'get' opcodes

get_global(out PMC, in STR)
Set $1 to the global named $2 in current namespace. If the global doesn't exist, $1 is set to null.
get_global(out PMC, in PMC, in STR)
Set $1 to the global named $3 in the namespace denoted by the key constant $2, relative to the current namespace. If the namespace or the global doesn't exist, $1 is set to null.
get_hll_global(out PMC, in STR)
Set $1 to the global named $2 in the current HLL root namespace. If the global doesn't exist, $1 is set to null.
get_hll_global(out PMC, in PMC, in STR)
Set $1 to the global named $3 in the namespace denoted by the key constant $2, relative to the current HLL root namespace. If the namespace or the global doesn't exist, $1 is set to null.
get_root_global(out PMC, in STR)
Set $1 to the global named $2 in the true root namespace. If the global doesn't exist, $1 is set to null.
get_root_global(out PMC, in PMC, in STR)
Set $1 to the global named $3 in the namespace denoted by the key constant $2, relative to the true root namespace. If the namespace or the global doesn't exist, $1 is set to null.

Global variable 'set' opcodes

set_global(in STR, invar PMC)
Set the global named $1 in the current namespace to $2.
set_global(in PMC, in STR, invar PMC)
Set the global named $2 in the namespace denoted by the key constant $1, relative to the current namespace, to $3. If the namespace does not exist, it is created.
set_hll_global(in STR, invar PMC)
Set the global named $1 to $2 in the current HLL root namespace.
set_hll_global(in PMC, in STR, invar PMC)
Set the global named $2 in the namespace denoted by the key constant $1 (relative to the current HLL namespace) to $3. If the namespace does not exist, it is created.
set_root_global(in STR, invar PMC)
Set the global named $1 in the true root namespace to $2.
set_root_global(in PMC, in STR, invar PMC)
Set the global named $2 in the namespace denoted by the key constant $1 (relative to the true root namespace) to $3. If the namespace does not exist, it is created.

Global variable ops

Operations to modify global variables

find_name(out PMC, in STR)
Find the name $2 in lexical, current, global, or builtin namespace and store it in $1. If the name doesn't exist either throws an exception or sets $1 to PMCNULL, depending on current errors settings. See errorson.
find_sub_not_null(out PMC, in STR)
inline op find_sub_not_null(out PMC, in STR) :base_core { opcode_t *dest = expr NEXT(); PMC *sub = Parrot_find_name_op(interp, $2, dest);
    if (PMC_IS_NULL(sub)) {
        opcode_t *handler = Parrot_ex_throw_from_op_args(interp, dest,
                       EXCEPTION_GLOBAL_NOT_FOUND,
                       "Could not find non-existent sub %Ss", $2);
        goto ADDRESS(handler);
    }

    $1 = sub;
}

COPYRIGHT

Copyright (C) 2001-2009, Parrot Foundation.

LICENSE

This program is free software. It is subject to the same license as the Parrot interpreter itself.