public final class WhileyFile.Method extends WhileyFile.FunctionOrMethodOrProperty
method m(int x) -> (int y)
// Parameter must be positive
requires x > 0
// Return must be negative
ensures $ < 0:
// body
return -x
Here, a method m is defined which accepts only positive
integers and returns only negative integers. The special variable
$ is used to refer to the return value. Unlike functions,
methods in Whiley may have side-effects.
Method declarations may also have modifiers, such as public
and private.
NOTE see WhileyFile.FunctionOrMethodOrProperty for more information.
| Modifier and Type | Field and Description |
|---|---|
Type.Method |
resolvedType |
ensures, lifetimeParameters, parameters, requires, returns, statements| Constructor and Description |
|---|
Method(List<Modifier> modifiers,
String name,
List<WhileyFile.Parameter> returns,
List<WhileyFile.Parameter> parameters,
List<String> lifetimeParameters,
List<Expr> requires,
List<Expr> ensures,
List<Stmt> statements,
wybs.lang.Attribute... attributes) |
| Modifier and Type | Method and Description |
|---|---|
Type.Method |
resolvedType() |
wyal.lang.WyalFile.Type.Method |
unresolvedType() |
hasModifier, modifiers, namepublic Type.Method resolvedType
public wyal.lang.WyalFile.Type.Method unresolvedType()
unresolvedType in class WhileyFile.FunctionOrMethodOrPropertypublic Type.Method resolvedType()
resolvedType in class WhileyFile.FunctionOrMethodOrPropertyCopyright © 2017. All rights reserved.