Introducing ASML

1 / 20

# Introducing ASML - PowerPoint PPT Presentation

Introducing ASML. Methods, Values, Constraints, Constants, Variables Lecture 10 Software Engineering COMP201. I. Methods. Methods are named operations that may be invoked in various contexts

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about 'Introducing ASML' - saxton

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

### Introducing ASML

Methods, Values, Constraints, Constants, Variables

Lecture 10

Software Engineering COMP201

I. Methods
• Methods are named operations that may be invoked in various contexts
• The definition of a method may include parameters that will be associated with particular values each time the method is invoked
• Methods may also specify a return value that is available after the operation has been performed
The general form for a method definition

The type of the return value, if there is one

name (parameter 1 as Type, … parameter n as Type)as Type

the name of method

the values sent to the method,

if there any

Method IsWord()
• An expression in the form IsWord() is an application of the name IsWord to argument i, which is a long integer.
• IsWord evaluates an argument i and returns the value true if i 0 and i0xFFFF (hexadecimal number).
• If i doesn’t fit these criteria, IsWord returns the value false.

IsWord ( i as Integer ) as Boolean

return (0<= i and i <= 0xFFFF)

Main()

step

if IsWord ( 123 ) then

Writelone (“123 is a word of memory.”)

Functions and update procedures
• Functions have no effect on state variables
• Functions must return a value

IsWord ( i as Integer ) as Boolean

return (0<= i and i <= 0xFFFF)

• Update procedures configure the values of state variables for the next sequential step of the machine
• Update procedures may optionally return a value
Update procedure power()

var x as Integer = 3

var y as Integer = 0

var index as Integer = 3

power (x as Integer, n as Integer) as Integer

var result as Integer = 1

var i as Integer = 1

step while i<=n

result:=result*x

i:=i+1

step return result

Main()

step y := power(5,3)

step

WriteLine (“5 cubed =” +y)

WriteLine(“3 cubed =” + power(3,index))

x:= power(x, power(2,2))

step WriteLine (“x = ” +x)

Output:

5 cubed = 125

3 cubed = 27

x = 81

Main()

mySet = {1, 2, 3}

step

WriteLine(“mySet has” + asString(size(mySet))+ “ elements. ”)

Local names for values

Statement in the form

identifier = expression

introduce identifier as a local name for the value given on the right hand side of the equals sign (“ = ”) by expression.

Local names may be introduced within any block of statement.

Local names could appear after the “then” keyword of an if … then … else statement

Local names in sequences of steps
• A local name can be referenced anywhere in its statement block.
• In a sequence of steps, local namesintroduced within a step block are available within any following step block.

Main()

step

mySet1 = {1, 2, 3}

WriteLine (“mySet has” + asString(size(mySet1))+ “ elements. ”)

step

mySet2 = mySet1 union {4 , 5, 6}

WriteLine(“mySet has” + asString(size(mySet2))+ “ elements. ”)

• to use the same name in different methods
• in each instance to have the compiler choose the correct instance

Must be a clear way for the compiler to decide which method should be called for any particular instance

The KEY for this is

the parameter list

S = { 1, 8, 2, 12, 13, 6}

Max(i as Integer, j as Integer)as Integer

returnif i > j then i else j

Max(s as Set of Integer)as Integer

returnany m | m in S where not (exists n in S where n>m )

run()

stepwriteln(“The largest number in the set is ” + ( Max(S) ) )

stepwriteln(“The largest of the two integers is ” + ( Max(2,3) ) )

A series of methods with the same name but differentiated by their parameter lists are overloaded methods

II.ValuesWhat are values?

The term value has the same meaning as in mathematical sets

Value

A value is an immutable element that supports two operations:

equality testing and set membership.

If x and y are values, then we can ask whether x is equal to y

If the S is a set, then we can ask whether x is an element of S

x in S

x = y

ordered pair

value

( x , y )

Structured values
• Some values are composed of other values
• Some structured values are built into AsmL; others may be defined by you

structure Location

base as Integer

offset as Integer

Location (1,4) is a value of the user-defined structure type Location

Data Type

Meaning

Boolean

A type that can be assigned true and false

Byte

8-bit unsigned integer type

Short

16-bit signed integer type

Integer

32-bit signed integer type

Long

64-bit signed integer type

Float

Single-precision 32-bit floating-point format type as specified in IEEE 754

Double

Double-precision 64-bit floating-point format type as specified in IEEE 754

Built in value types
Built in value types

Data Type

Meaning

Char

Unicode character type

String

Unicode string type

Seq of A

A sequence of elements of type A

Set of A

A set containing elements of type A

Map of A to B

A table whose entries map of elements of type A to type B

Built in value types

Data Type

Meaning

(A1,A2,…)

A tuple consisting of elements of type A1, A2, … Tuple values are written in the same form

For example, (1,2) is of a value of the built-in type (Integer,Integer)

A?

Types in the form t? includes all of the values of type t plus the special value undef.

For example, a variable declared as Boolean? could contain either of the Boolean value true or false or the value undef.

III. Constraints Assertions
• Assertionsrequire and ensure statements document constraints placed upon the model
• Violating a constraint at runtime is called an assertion failure

AllTickets = {1..1024}

IsTicketID (i as Integer) as Boolean

require i > 0

return ( i in AllTickets)

ChooseAnyTicket() as Integer

ensure IsTicketID(result)

return any t | t in AllTickets

• The keyword result denotes the value of the return statement
Type constraints
• Types of constants, variables and method parameters may be specified using the syntax :

nameastype

• Types may be explicitly checked using the “ is” operator :

valueistype

an expression will be either true or false, depending on whether the value given is an element of the type

• Types are not themselves values. For example, you can’t pass a type as an argument
IV. Constants
• Constants are fixed, named values
• Constants can either be global or local
• Global constants are declared in the beginning of the program
• Local constants are declared within a statement block
• The general form of declaring and initialising a constant is:

Name [as Type] = value

MaxInteger = 100

run()

MinInteger = 0

V. Variables
• Variables are names given to memory locations.
• Updating variables is the only way to change a state of a machine.
• Variables can be complex types such as structures or maps as well as simple types.
• Here is the general form for declaring and initialising variables:

varname[asType] = value

Types of variables
• There are three types of variables in AsmL
• Global variables
• Local variables
• Instance-based variables

Instance-based variables are variables that exist for each instance of a class

var x as Integer = 10 // shows explicit typing

var x = 10 // shows implicit typing

var greeting as String = “Hello” // shows a // string variable

var y = [1..6] // shows a sequence of // integers from 1 to 6

var menu = {“ham”, “cheese”, “bit”} // shows a // set