Beispiel #1
0
        public override AstNode Visit(VariableReference node)
        {
            // Get the node type.
            IChelaType variableType = node.GetNodeType();

            // Ignore type references, namespaces and functions.
            if (variableType.IsMetaType() || variableType.IsNamespace() ||
                variableType.IsFunctionGroup() || variableType.IsFunction())
            {
                return(node);
            }

            // The type must be a reference.
            variableType = DeReferenceType(variableType);

            // Now, it must be a constant.
            if (!variableType.IsConstant())
            {
                Error(node, "constant initialization can't reference no constant variables.");
            }

            // The node value, must be the constant variable.
            FieldVariable constantVar = (FieldVariable)node.GetNodeValue();

            // Find the corresponding constant data.
            ConstantData depData;

            if (constants.TryGetValue(constantVar, out depData))
            {
                currentConstant.AddDependency(depData);
            }

            return(node);
        }