protected DefinedType(TypeDefineNode node)
        {
            if (EnumData.GetEnum(node.Name) != null)
            {
                throw SyntaxErrorException.TypeNameConflict(node.Name, node.Location);
            }

            Name        = node.Name;
            DefinedVars = node.DefinedVars;
            MethodNodes = node.Methods;

            ConstructorNodes = node.Constructors;
        }
 public static DefinedType GetDefinedType(TypeDefineNode node)
 {
     if (node.TypeKind == TypeKind.Struct)
     {
         return(new DefinedStruct(node));
     }
     else if (node.TypeKind == TypeKind.Class)
     {
         return(new DefinedClass(node));
     }
     else
     {
         throw new Exception();
     }
 }
 public DefinedClass(TypeDefineNode definedType) : base(definedType)
 {
 }
 public DefinedStruct(TypeDefineNode definedType) : base(definedType)
 {
 }
        public RulesetNode(DeltinScriptParser.RulesetContext context, BuildAstVisitor visitor) : base(new Location(visitor.file, DocRange.GetRange(context)))
        {
            // Get imports
            Imports = new ImportNode[context.import_file().Length];
            for (int i = 0; i < Imports.Length; i++)
            {
                Imports[i] = new ImportNode(context.import_file(i), visitor);
            }

            ObjectImports = new ImportObjectNode[context.import_object().Length];
            for (int i = 0; i < ObjectImports.Length; i++)
            {
                ObjectImports[i] = new ImportObjectNode(context.import_object(i), visitor);
            }

            // Get rules
            Rules = new RuleNode[context.ow_rule().Length];
            for (int i = 0; i < Rules.Length; i++)
            {
                Rules[i] = (RuleNode)visitor.VisitOw_rule(context.ow_rule()[i]);
            }

            // Get defined variables
            DefinedVars = new RuleDefineNode[context.rule_define().Length];
            var reservedGlobalIDs = new List <int>();
            var reservedPlayerIDs = new List <int>();

            for (int i = 0; i < DefinedVars.Length; i++)
            {
                DefinedVars[i] = new RuleDefineNode(context.rule_define(i), visitor);
                if (DefinedVars[i].OverrideID != -1)
                {
                    (DefinedVars[i].IsGlobal ? reservedGlobalIDs : reservedPlayerIDs).Add(DefinedVars[i].OverrideID);
                }
            }
            ReservedGlobalIDs = reservedGlobalIDs.ToArray();
            ReservedPlayerIDs = reservedPlayerIDs.ToArray();

            // Get user methods
            UserMethods = new UserMethodBase[context.user_method().Length + context.macro().Length];
            for (int i = 0; i < context.user_method().Length; i++)
            {
                UserMethods[i] = (UserMethodNode)visitor.VisitUser_method(context.user_method(i));
            }

            // Get macros
            for (int i = 0; i < context.macro().Length; i++)
            {
                UserMethods[i + context.user_method().Length] = new MacroNode(context.macro(i), visitor);
            }

            // Get types
            DefinedTypes = new TypeDefineNode[context.type_define().Length];
            for (int i = 0; i < DefinedTypes.Length; i++)
            {
                DefinedTypes[i] = (TypeDefineNode)visitor.VisitType_define(context.type_define(i));
            }

            // Get reserved global variables
            if (context.reserved_global()?.reserved_list() != null)
            {
                ReservedGlobal = new ReservedNode(context.reserved_global().reserved_list(), visitor);
            }

            // Get reserved player variables
            if (context.reserved_player()?.reserved_list() != null)
            {
                ReservedPlayer = new ReservedNode(context.reserved_player().reserved_list(), visitor);
            }
        }