Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,82 @@ public function get_descendant_tokens( ?int $token_id = null ): array {
return wp_sqlite_mysql_native_ast_get_descendant_tokens( $this, $token_id );
}

public function get_native_handle(): int {
return wp_sqlite_mysql_native_ast_get_native_handle( $this );
}

public function get_native_child_handles( ?int $handle = null ): array {
return wp_sqlite_mysql_native_ast_get_native_child_handles(
$this,
$handle ?? $this->get_native_handle()
);
}

public function get_native_descendant_handles( ?int $handle = null ): array {
return wp_sqlite_mysql_native_ast_get_native_descendant_handles(
$this,
$handle ?? $this->get_native_handle()
);
}

/**
* Return descendant metadata without materializing PHP node/token objects.
*
* The result is a flat list of `[kind, id, kind, id, ...]` pairs, where
* kind `0` is a parser node and kind `1` is a token. The id is the node's
* rule id or the token id.
*
* @param int|null $handle Optional native node handle. Defaults to this node.
* @return int[]
*/
public function get_native_descendant_id_rows( ?int $handle = null ): array {
return wp_sqlite_mysql_native_ast_get_native_descendant_id_rows(
$this,
$handle ?? $this->get_native_handle()
);
}

public function get_native_descendant_packed_id_rows( ?int $handle = null ): array {
return wp_sqlite_mysql_native_ast_get_native_descendant_packed_id_rows(
$this,
$handle ?? $this->get_native_handle()
);
}

/**
* Return descendant metadata without materializing PHP node/token objects.
*
* The result is a flat list of `[kind, id, start, length, ...]` rows.
* Kind `0` is a parser node and kind `1` is a token. Token rows carry the
* token byte span. Node rows use `start = -1` and `length = 0` because the
* pure-PHP parser nodes do not store spans, and the benchmark uses this API
* for direct PHP/native comparisons.
*
* @param int|null $handle Optional native node handle. Defaults to this node.
* @return int[]
*/
public function get_native_descendant_scalar_rows( ?int $handle = null ): array {
return wp_sqlite_mysql_native_ast_get_native_descendant_scalar_rows(
$this,
$handle ?? $this->get_native_handle()
);
}

public function get_native_descendant_packed_scalar_rows( ?int $handle = null ): array {
return wp_sqlite_mysql_native_ast_get_native_descendant_packed_scalar_rows(
$this,
$handle ?? $this->get_native_handle()
);
}

public function get_native_handle_kind( int $handle ): int {
return wp_sqlite_mysql_native_ast_get_native_handle_kind( $this, $handle );
}

public function get_native_handle_id( int $handle ): int {
return wp_sqlite_mysql_native_ast_get_native_handle_id( $this, $handle );
}

/** @inheritDoc */
public function get_start(): int {
if ( $this->was_mutated() ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,44 @@ public function get_query_ast(): ?WP_Parser_Node {
public function parse() {
return $this->native->parse();
}

public function parse_native_descendant_id_rows(): ?array {
return $this->native->parse_native_descendant_id_rows();
}

public function parse_native_descendant_packed_id_rows(): ?array {
return $this->native->parse_native_descendant_packed_id_rows();
}

public function parse_native_descendant_scalar_rows(): ?array {
return $this->native->parse_native_descendant_scalar_rows();
}

public function parse_native_descendant_packed_scalar_rows(): ?array {
return $this->native->parse_native_descendant_packed_scalar_rows();
}

public function parse_native_descendant_packed_id_stats(): ?array {
return $this->native->parse_native_descendant_packed_id_stats();
}

public function parse_native_descendant_packed_scalar_stats( bool $consume_token_bytes = false ): ?array {
return $this->native->parse_native_descendant_packed_scalar_stats( $consume_token_bytes );
}

public function parse_sql_native_descendant_packed_id_stats( string $sql ): ?array {
return $this->native->parse_sql_native_descendant_packed_id_stats( $sql );
}

public function parse_sql_native_descendant_packed_scalar_stats( string $sql, bool $consume_token_bytes = false ): ?array {
return $this->native->parse_sql_native_descendant_packed_scalar_stats( $sql, $consume_token_bytes );
}

public function parse_sql_batch_native_descendant_packed_id_stats( array $queries ): array {
return $this->native->parse_sql_batch_native_descendant_packed_id_stats( $queries );
}

public function parse_sql_batch_native_descendant_packed_scalar_stats( array $queries, bool $consume_token_bytes = false ): array {
return $this->native->parse_sql_batch_native_descendant_packed_scalar_stats( $queries, $consume_token_bytes );
}
}
Loading
Loading