Skip to main content

crashtest.hxsmith.features.classes

Classes: fields, properties, constructors, statics, inheritance, an interface and virtual dispatch.

Method bodies call each other through g.fns (the call sites are built by the functions feature, which consults g.state["calls"]). Virtual dispatch could turn the registration-order DAG into a cycle (Base.m calls x.n() which lands in Derived.n which calls Base.m), so a method that can be dispatched to virtually only calls functions that never reach a virtual call themselves.

class Classes(Feature)​

name​

name = 'classes'

summary​

summary = 'classes: fields, properties, statics, ctors, inheritance, interface, virtual calls'

covers​

covers = ('EClass', 'HInterface', 'HExtends', 'HImplements', 'APublic', 'APrivate', 'AStatic', 'AOverride', 'AInline', 'AFinal', 'FVar', 'FFun', 'FProp', 'ENew', 'EFNormal')

requires​

requires = ('variables', 'functions')

order​

order = 40

declare​

def declare(g: Gen) -> None

types​

def types(g: Gen, depth: int)

show​

def show(g: Gen, ty: Ty, expr: str)

exprs​

def exprs(g: Gen, ty: Ty)

stmts​

def stmts(g: Gen)

class Cls​

name: str​

base: Optional[str]​

fields: List[Field]​

fields = field(default_factory=list)

methods: List[Method]​

methods = field(default_factory=list)

ctor: List[Ty]​

ctor = field(default_factory=list)

descendants: List[Ty]​

descendants = field(default_factory=list)

init​

def __init__(name: str, base: Optional[str], fields: List[Field] = list(), methods: List[Method] = list(), ctor: List[Ty] = list(), descendants: List[Ty] = list()) -> None

class Field​

name: str​

ty: Ty​

owner: str​

static: bool​

static = False

final: bool​

final = False

public: bool​

public = True

kind: str​

kind = 'var'

ctor_init: bool​

ctor_init = False

readable: bool​

writable: bool​

init​

def __init__(name: str, ty: Ty, owner: str, static: bool = False, final: bool = False, public: bool = True, kind: str = 'var', ctor_init: bool = False) -> None

class Method​

name: str​

params: List[Tuple[str, Ty]]​

ret: Ty​

static: bool​

static = False

inline: bool​

inline = False

override: bool​

override = False

init​

def __init__(name: str, params: List[Tuple[str, Ty]], ret: Ty, static: bool = False, inline: bool = False, override: bool = False) -> None