Aztec® Programming Language

Version 1.0 Alpha

Copyright © 2010-2013

Cold Spring® Development Group

All Rights Reserved

Download Aztec

Site Help

An enumeration is a primitive data type which has a list of discrete values which the enumeration class can be assigned. A new enumeration class is defined using the 'enum' statement. The Aztec compiler automatically creates a number of methods and constants which are associated with this new enumeration. Instance methods, global methods and compiler methods are all created with data types specific to the new enumeration class. In addition, class constants are created specifically for the enumeration class, and reflect the contents of the enumeration value list.

 

The enumeration instance methods, VM global methods and Compiler Methods can be used to perform useful operations on each enumeration data type. Each type of method has a separate column in the following method table with a link to the appropriate method description.

 

To simplify the description of the enumeration methods and constants, an example will be used as a demonstration. The methods and constants in the following tables will be described using a dummy enumeration named "MyEnum" which is defined with the following syntax.

    public enum MyEnum { val1, val2, val3, val4 }

This 'MyEnum' enumeration type does not actually exist, and is used strictly as an example of how the methods and constants are defined for every enumeration class which is created. When these methods and constants are created for a specific enumeration, each reference to "MyEnum" is replaced with the new enumeration name. For the data, the "NumValue" constant will reflect the actual number of discrete values in the enumeration value list, "MinValue" will be the first value in the list and "MaxValue" will be the last value in the list.

MyEnum Methods

Compiler
Global
Instance
Description
-
-
MyEnum()
Constructor for the 'MyEnum' class to initialize with a MyEnum value
Returns a string representation of the MyEnum value ('val1', 'val2', ... )
CompilerEnumIndex() EnumIndex() Index() Returns the one based internal index for the enumeration value (val1=1,val2=2, val3=3,val4=4)
CompilerInc() Inc() Inc() Increments the enumeration value based on internal index and returns new enum value
CompilerDec() Dec() Dec() Decrements the enumeration value based on internal index and returns new enum value

MyEnum Constants

Constant Data Item Data Type Value
MyEnum.MaxValue MyEnum val4
MyEnum.MinValue MyEnum val1
MyEnum.NumValues int 4

Derived Classes

See Also

 


MyEnum()

public method MyEnum(MyEnum InitValue = val1)

Parameters

InitValue

Initial value for the MyEnum object, with a default of val1 (first value in list)

Return Value

None

Description

This is the constructor for the 'MyEnum' class, invoked automatically by the VM during dynamic allocation of a MyEnum object or for initialization of local, global or shared data items, if a constructor was used in the data definition.

 

This constructor takes a MyEnum value as a parameter to initialize the object. A default of 'val1' is used if the parameter is not provided, which is the first value in the list.

 

MyEnum Class


Str()

public method<string> Str()

Parameters

None

Return Value

Returns the string representation of the MyEnum value

Description

This instance method returns the string representation of the internal MyEnum value. If the value is val1, the method returns "val1" and if val2, it returns "val2" and so on.

 

MyEnum Class


EnumStr

public method<string> EnumStr(MyEnum Value)

Parameters

Value

MyEnum value to be converted to a string

Return Value

Returns the string representation of the MyEnum value

Description

This global method returns the string representation of the MyEnum value. If the value is val1, the method returns "val1" and if val2, it returns "val2" and so on.

 

Global Method


CompilerEnumStr()

public method<string> compiler CompilerEnumStr(MyEnum Value)

Parameters

Value

MyEnum value to be converted to a string

Return Value

Returns the string representation of the MyEnum value

Description

This compiler method returns the string representation of the MyEnum value. If the value is val1, the method returns "val1" and if val2, it returns "val2" and so on.

 

This method can be used dynamically during the compile process at the module level, class level and inside compiler methods. It can also be used within expressions in non-compiler methods. When the expression is processed by the compiler, the compiler method is invoked and the result is treated as a constant within the expression.

 

Compiler Method


Index()

public method<int> Index()

Parameters

None

Return Value

Returns the one based index of the MyEnum value

Description

This instance method returns the one based index of the internal MyEnum value. If the value is val1, the index is one, if val2, the index is two and so on. The max index is four and is associated with the last value in the list, val4

 

MyEnum Class


EnumIndex()

public method<int> EnumIndex(MyEnum Value)

Parameters

Value

MyEnum value to get index of

Return Value

Returns the one based index of the MyEnum value

Description

This global method returns the one based index of the internal MyEnum value. If the value is val1, the index is one, if val2, the index is two and so on. The max index is four and is associated with the last value in the list, val4

 

Global Method


CompilerEnumIndex()

public method<int> compiler CompilerEnumIndex(MyEnum Value)

Parameters

Value

MyEnum value to get index of

Return Value

Returns the one based index of the MyEnum value

Description

This global method returns the one based index of the internal MyEnum value. If the value is val1, the index is one, if val2, the index is two and so on. The max index is four and is associated with the last value in the list, val4.

 

This method can be used dynamically during the compile process at the module level, class level and inside compiler methods. It can also be used within expressions in non-compiler methods. When the expression is processed by the compiler, the compiler method is invoked and the result is treated as a constant within the expression.

 

Compiler Method


Inc()

public method<MyEnum> Inc()

Parameters

None

Return Value

Returns the incremented MyEnum value

Description

This instance method increments the internal MyEnum value based on index and returns the result. If the internal bool value is val1, the incremented value becomes val2, and so on. If the MyEnum value is the highest value in the list (val4), the increment operation will cause an OverflowException to be fired.

 

This method modifies the internal MyEnumm object.

 

MyEnum Class


Inc()

public method<MyEnum> Inc(MyEnum Value)

Parameters

Value

MyEnum value to be incremented

Return Value

Returns the incremented MyEnum value

Description

This global method increments the specified MyEnum value based on index and returns the result. If the MyEnum value is val1, the incremented value becomes val2, and so on. If the MyEnum value is the highest value in the list (val4), the increment operation will cause an OverflowException to be fired.

 

This method does not modify the source MyEnum object.

 

Global Method


CompilerInc()

public method<MyEnum> compiler CompilerInc(MyEnum ref Value)

Parameters

Value

Reference to MyEnum value to be incremented

Return Value

Returns the incremented MyEnum value

Description

This global method increments the specified MyEnum value based on index and returns the result. If the MyEnum value is val1, the incremented value becomes val2, and so on. If the MyEnum value is the highest value in the list (val4), the increment operation will not be performed and a value of true will be returned.

 

This method modifies the source bool object.

 

This method can be used dynamically during the compile process at the module level, class level and inside compiler methods. It can also be used within expressions in non-compiler methods. When the expression is processed by the compiler, the compiler method is invoked and the result is treated as a constant within the expression.

 

Compiler Method


Dec()

public method<MyEnum> Dec()

Parameters

None

Return Value

Returns the decremented MyEnum value

Description

This instance method decrements the internal MyEnum value based on index and returns the result. If the MyEnum value is val4, the decremented value becomes val3, and so on. If the MyEnum value is already at the min value (first value in list), the decrement operation will cause an OverflowException to be fired.

 

This method modifies the internal MyEnum object.

 

MyEnum Class


Dec()

public method<MyEnum> Dec(MyEnum Value)

Parameters

Value

MyEnum value to be decremented

Return Value

Returns the decremented MyEnum value

Description

This global method decrements the specified MyEnum value based on index and returns the result. If the MyEnum value is val4, the decremented value becomes val3, and so on. If the MyEnum value is already at the min value (first value in list), the decrement operation will cause an OverflowException to be fired.

 

This method does not modify the source MyEnum object.

 

Global Method


CompilerDec()

public method<MyEnum> compiler CompilerDec(MyEnum ref Value)

Parameters

Value

MyEnum value to be decremented

Return Value

Returns the decremented MyEnum value

Description

This global method decrements the specified MyEnum value based on index and returns the result. If the MyEnum value is val4, the decremented value becomes val3, and so on. If the MyEnum value is already at the min value (first value in list), the decrement operation will cause an OverflowException to be fired.

 

This method modifies the source MyEnum object.

 

This method can be used dynamically during the compile process at the module level, class level and inside compiler methods. It can also be used within expressions in non-compiler methods. When the expression is processed by the compiler, the compiler method is invoked and the result is treated as a constant within the expression.

 

Compiler Method

 

Copyright © 2010-2013

Cold Spring Development Group

All Rights Reserved

Download Aztec