add_method()
LIST add_method(LIST code, SYMBOL name)
This function compiles code (passed as a list of strings) and uses the result as the definition of the method named by the symbol name. If there were errors in compiling, a list of strings describing the errors is returned, otherwise an empty list is returned.
add_method(["cwrite(\"foo\");"], 'foo)
=> []
add_method(["cwrite(\"foo\")"], 'foo)
=> ["Line 2: parse error"]
del_method()
INTEGER del_method(SYMBOL name)
This function removes the method named by the symbol name from the current object. This method returns 1 if there was a method named name on the current object; otherwise, a ~methodnf error is thrown.
find_method()
OBJNUM find_method(SYMBOL name)
This function searches for the first occurrence of the method named by the symbol name on an ancestor of the current object. If a method is found, the ancestor is returned. Otherwise the error ~methodnf is thrown.
find_method('all_cached_commands);
=> $has_cached_commands
find_next_method()
OBJNUM find_next_method(SYMBOL name, OBJNUM after)
This function searches for the occurrence of the method named by the symbol name, after the ancestor after. If a method is found, the ancestor is returned. Otherwise the error ~methodnf is thrown.
$player.find_next_method('short_desc, $body)
=> $thing
list_method()
LIST list_method(SYMBOL name[, INTEGER indent[, INTEGER flags]])
This function is used to decompile a method. It accepts a symbol, assuming it to be the name of a method. If the method is defined on the current object it is decompiled and returned as a list of strings. If the method is not found, the error ~methodnf is thrown.
The second argument indent can be given to specify an alternate indentation to use (default is four spaces). The third argument can be specified to change the default formatting behaviour. The argument is an integer which can have three different values:
- 1 - Full Parenthesis
- 2 - Full Braces
- 3 - Full Parenthesis and Braces
method_access()
SYMBOL method_access(SYMBOL name)
This function returns the method access for the method specified with the argument name. See Methods for more information on method access.
method_access('cmd_quit)
=> 'protected
method_bytecode()
LIST method_bytecode(SYMBOL name)
Returns the bytecode for the specified method, defined on the current object. For instance, consider the following method:
public method .trusteds(): nooverride {
return trusteds;
};
This method would return the following bytecode:
method_bytecode('trusteds)
=> ['GET_OBJ_VAR, 'trusteds, 'RETURN_EXPR, 'RETURN]
method_flags()
LIST method_flags(SYMBOL name)
This function finds the method specified with the argument name and returns the list of flags currently set on the method. See Methods for more information on method flags. If the method name cannot be found, the error ~methodnf is thrown.
method_flags('cmd_quit)
=> ['nooverride]
method_info()
LIST method_info(SYMBOL name)
This function returns a list of miscellaneous information on the method named by name. If the method is not found, the error ~methodnf is thrown. Otherwise a list is returned. The elements in the list are (in order):
- STRING - comma-separated list of arguments
- INTEGER - number of arguments
- INTEGER - number of local variables defined
- INTEGER - number of opcodes used
- SYMBOL - method access
- LIST - method flags
methods()
LIST methods()
This function returns a list of symbols naming each method defined on the current object.
rename_method()
INTEGER rename_method(SYMBOL old_name, SYMBOL new_name)
This function changes the name of the method on the current object, specified by the argument old_name, and changes it to the name specified by the argument new_name. If no method can be found by the name old_name, the error ~methodnf is thrown.
set_method_access()
INTEGER set_method_access(SYMBOL name, SYMBOL access)
This function sets the method access for the method name. See Methods for more information on method access.
set_method_flags()
INTEGER set_method_flags(SYMBOL name, LIST flags)
This function sets the method flags for the method specified with the argument name. The flags are specified as a list of symbols in flags. See Methods for more information on method flags.
set_method_flags('spawn, ['nooverride])
=> 1