Fun 0.41.5
The programming language that makes you have fun!
Loading...
Searching...
No Matches
name.c File Reference

VM opcode snippet for XML node name retrieval. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 free_value (vh)
 push_value (vm, make_string(name))

Variables

case OP_XML_NAME
int h = (vh.type == VAL_INT) ? (int)vh.i : 0
xmlNodePtr n = xml_node_get(h)
const char * name = (n && n->name) ? (const char *)n->name : ""
 break

Detailed Description

VM opcode snippet for XML node name retrieval.

This file is included into the main VM dispatch switch in vm.c and implements the OP_XML_NAME instruction.

Opcode: OP_XML_NAME

  • Stack effect: pop (int node_handle) → push (string name)
  • Success: pushes the element/node name as a string. If the node has no name, an empty string is pushed.
  • Errors/edge cases: if the handle is invalid or the node cannot be retrieved, an empty string is pushed. The instruction does not throw.
  • Gating: When FUN_WITH_XML2 is not enabled at build time, the operand is still popped and an empty string is pushed.

Notes

  • Node handles are small positive integers managed by the XML handle registry defined in the xml2 extension (see extensions/xml2.c).
  • The pushed string is a new VM value; ownership is transferred to the VM stack as usual.

Example

  • stack: [ node_handle ]
  • OP_XML_NAME → [ "book" ]

Definition in file name.c.

Function Documentation

◆ free_value()

free_value ( vh )

◆ push_value()

push_value ( vm ,
make_string(name)  )

Variable Documentation

◆ break

break

Definition at line 51 of file name.c.

◆ h

int h = (vh.type == VAL_INT) ? (int)vh.i : 0

Definition at line 41 of file name.c.

◆ n

xmlNodePtr n = xml_node_get(h)

Definition at line 42 of file name.c.

◆ name

const char* name = (n && n->name) ? (const char *)n->name : ""

Definition at line 44 of file name.c.

◆ OP_XML_NAME

case OP_XML_NAME

Definition at line 38 of file name.c.