Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "VIATRA2/Examples/VTCL/ASM"

< VIATRA2‎ | Examples‎ | VTCL
(ASM functions)
(ASM functions)
Line 7: Line 7:
 
ASM functions provide a non-persistent map to store values. Each ASM function needs to be declared prior to its first use.
 
ASM functions provide a non-persistent map to store values. Each ASM function needs to be declared prior to its first use.
 
Initial values can also be set when defining an ASM function. The values stored at a certain location of an ASM function  
 
Initial values can also be set when defining an ASM function. The values stored at a certain location of an ASM function  
can be updated using the '''update''' ASM construct.   
+
can be updated using the '''update''' ASM construct (see later).   
  
 
<source lang="text">
 
<source lang="text">
 
machine asmFuns {
 
machine asmFuns {
 
  asmfunction team / 2 {
 
  asmfunction team / 2 {
(1, "real") = "Casillas";
+
(1, "real") = "Casillas";
(7, "real") = "Raul";
+
(7, "real") = "Raul";
 +
// Any values are allowed to be used in the untyped version
 +
(7.1, 6) = 2;
 
  }
 
  }
 
}
 
}
Line 25: Line 27:
 
machine asmFuns {
 
machine asmFuns {
 
  asmfunction team(Integer, datatypes.String) : String / 2 { // FQNs can always be used for defining types
 
  asmfunction team(Integer, datatypes.String) : String / 2 { // FQNs can always be used for defining types
(1, "real") = "Casillas";
+
(1, "real") = "Casillas";
(7, "real") = "Raul";
+
(7, "real") = "Raul";
 +
// The following initialization would be a type error
 +
// (7.1, 6) = 2;
 
  }
 
  }
 
}
 
}

Revision as of 12:38, 17 February 2009

Abstract State Machines

Abstract state machines (ASMs) provide a high-level means for assembling complex transformation programs.

ASM functions

ASM functions provide a non-persistent map to store values. Each ASM function needs to be declared prior to its first use. Initial values can also be set when defining an ASM function. The values stored at a certain location of an ASM function can be updated using the update ASM construct (see later).

machine asmFuns {
 asmfunction team / 2 {
	(1, "real") = "Casillas";
	(7, "real") = "Raul";
	// Any values are allowed to be used in the untyped version
	(7.1, 6) = 2;
 }
}

In the new (upcoming) VIATRA2 version, types can also be defined for ASM functions as follows.

// Import is needed if types are intended to be used by local names
import datatypes;
machine asmFuns {
 asmfunction team(Integer, datatypes.String) : String / 2 { // FQNs can always be used for defining types
	(1, "real") = "Casillas";
	(7, "real") = "Raul";
	// The following initialization would be a type error
	// (7.1, 6) = 2;
 }
}

Simple rules

Back to the top