Beispiel #1
0
        public bool VisitNode(Enumeration node)
        {
            // enum enumname { \n contents \n };
            Write("enum {0} {1}", node.Name, "{");
            NestingLevel++;

            foreach (VariableIdentifier value in node.Values)
                Write("{0},", value.Name);

            NestingLevel--;
            Write("{0};", "}");

            return true;
        }
        public bool VisitNode(Enumeration node)
        {
            if (Symbols.SymbolExistsInCurrentScope(node.Name))
                return Error("A member named '" + node.Name + "' already exists in this class!", node.StartPos, node.EndPos);

            Symbols.AddSymbol(node.Name, node);
            // TODO: add in package / global namespace.
            // If a symbol with that name exists, overwrite it with this symbol from now on.
            // damn this language...
            Symbols.PushScope(node.Name);

            foreach (VariableIdentifier enumVal in node.Values)
            {
                enumVal.Outer = node;
                if (enumVal.Type != ASTNodeType.VariableIdentifier)
                    Error("An enumeration member must be a simple(name only) variable.", enumVal.StartPos, enumVal.EndPos);
                Symbols.AddSymbol(enumVal.Name, enumVal);
            }

            Symbols.PopScope();

            // Add enum values at the class scope so they can be used without being explicitly qualified.
            foreach (VariableIdentifier enumVal in node.Values)
                Symbols.AddSymbol(enumVal.Name, enumVal);

            node.Declaration = node;

            return Success;
        }
Beispiel #3
0
        public Enumeration ConvertEnum(ME3Enum obj)
        {
            var vals = new List<VariableIdentifier>();
            foreach (var val in obj.Names)
                vals.Add(new VariableIdentifier(val, null, null));

            var node = new Enumeration(obj.Name, vals, null, null);

            foreach (var member in vals)
                member.Outer = node;

            return node;
        }