Aztec® Programming Language
Version 1.1 Alpha 2

Copyright © 2010-2017, Aztec Development Group, All Rights Reserved

Download Aztec

Search        Contact Us

You folks are crazy.

- Lowell George

 

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/Shared
Description
-
-
Constructor for the 'MyEnum' class to initialize with a MyEnum value
- - MyEnum() Constructor for the 'MyEnum' class to initialize with an int value
- - MyEnum() Constructor for the 'MyEnum' class to initialize with a string value
- - Enum() Shared method to return the enumeration value that matches the specified index
- - Enum() Shared method to return the enumeration value that matches the specified name
CompilerEnumStr()
-
Str() Returns a string representation of the MyEnum value ('val1', 'val2', ... )
CompilerEnumIndex() - Index() Returns the one based internal index for the enumeration value (val1=1,val2=2, val3=3,val4=4)
CompilerInc() - Inc() Increments the enumeration value based on internal index and returns new enum value
CompilerDec() - 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 one of the constructors for the MyEnum class, invoked automatically by the VM during dynamic allocation of a MyEnum object, if the constructor arguments match this method. It is only available for dynamic allocation and not for initialization of bool variables.

 

This constructor takes a MyEnum enumeration value as a parameter to initialize the object. The default value is the first enumeration in the list ('val1' in this case) if nothing is passed in.

 

MyEnum Class


MyEnum()

public method MyEnum(int InitIndex)

Parameters

InitIndex

Initial index value for the bool object

Return Value

None

Description

This is one of the constructors for the MyEnum class, invoked automatically by the VM during dynamic allocation of a MyEnum object, if the constructor arguments match this method. It is only available for dynamic allocation and not for initialization of bool variables.

 

This constructor takes an integer value as a parameter to initialize the object, which represents the index of the enumeration value. For the fictional MyEnum class, the index must be between 1 (val1) and 4 (val4). If the index value is not valid, the enumeration object is set with the first enumeration value (val1 in this case).

 

MyEnum Class


MyEnum()

public method MyEnum(string InitEnumText)

Parameters

InitEnumText

String representing one of the enumeration values

Return Value

None

Description

This is one of the constructors for the MyEnum class, invoked automatically by the VM during dynamic allocation of a MyEnum object, if the constructor arguments match this method. It is only available for dynamic allocation and not for initialization of bool variables.

 

This constructor takes a string value as a parameter to initialize the object, which represents the text/name of the enumeration value. For the fictional MyEnum class, the text must be 'val1, 'val2, 'val3' or 'val4'. If the string is not valid, the enumeration object is set with the first enumeration value (val1 in this case).

 

MyEnum Class


Enum()

public method<MyEnum> shared Enum(int EnumIndex)

Parameters

EnumIndex

Enumeration index value

Return Value

Returns enumeration value that matches the specified index

Description

This shared method takes a one based enumeration index and returns the corresponding enumeration value corresponding to the index. For the MyEnum class, the index must be between 1 (val1) and 4 (val4). If the index is not valid, it returns the first enumeration value (val1 in this case)..

 

MyEnum Class


Enum()

public method<MyEnum> shared Enum(string EnumText)

Parameters

EnumText

String representing one of the enumeration values

Return Value

Returns enumeration value that matches the specified enumeration text

Description

This shared method takes an enumeration name and returns the corresponding enumeration value corresponding to the text. For the MyEnum class, the valid names are 'val1', 'val2', 'val3' and 'val4'. If the text does not match any of the valid items for the enumeration, the first enumeration value is returned (val1 in this case).

 

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


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


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


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


CompilerDec()

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

Parameters

Value

MyEnum value to be decremented

Return Value

Returns the decremented MyEnum valu

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-2017

Aztec Development Group

All Rights Reserved

Download Aztec