callctx

package
v2.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package callctx defines a function call Context for static analysis.

A context is a map between local variables of a function and their instances. An element in the context is abstracted as a key-value store using the Key type and the Value type. The primary use for a context is to propagate local variables to other scopes through different forms of function calls using a substitution operation called Switch. A context Switch transforms context from the perspective of a caller to that of a callee.

This package is inspired by the builtin context package but for context-sensitive variable propagation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Deref

func Deref(ctx Context, ptr, val store.Key) (store.Value, error)

Types

type Callee

type Callee interface {
	CallerCtx() Context
	Call() *funcs.Instance
}

A Callee is a context created by a call, Call() returns the call instance.

type Context

type Context interface {
	Get(store.Key) store.Value
	Put(store.Key, store.Value)
	// contains filtered or unexported methods
}

A Context is map between local variables and their instances. Get and Put are the main functions to access the contents of the map.

func Switch

func Switch(parent Context, call *funcs.Instance) Context

Switch performs a context switch from parent (caller) to a new callee context. The switch matches up caller arguments in parent in the call ↔ translated in the callee as call parameters.

func Toplevel

func Toplevel() Context

Toplevel returns an empty context.

It is used for representing a top-level context at entry points of analysis.

type Updater

type Updater interface {
	PutObj(k store.Key, v ssa.Value)                 // Add Value.
	PutUniq(k store.Key, v store.ValueWrapper) error // Add pre-initialised Value.
}

Updater is an interface for a context that has the ability to modify the underlying storage which the instances point to.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL