public ScopeGroup GetRootScope(IndexedVar var, ParsingData parseData)
        {
            ScopeGroup typeScope = new ScopeGroup(parseData.VarCollection);

            typeScope.This = var;

            for (int i = 0; i < DefinedVars.Length; i++)
            {
                IndexedVar newVar = var.CreateChild(typeScope, DefinedVars[i].VariableName, new int[] { i }, DefinedVars[i]);
                if (DefinedVars[i].Type != null)
                {
                    newVar.Type = parseData.GetDefinedType(DefinedVars[i].Type, DefinedVars[i].Location);
                }
                newVar.AccessLevel = DefinedVars[i].AccessLevel;
            }

            for (int i = 0; i < MethodNodes.Length; i++)
            {
                UserMethod method = new UserMethod(typeScope, MethodNodes[i]);
                method.RegisterParameters(parseData);
                method.AccessLevel = MethodNodes[i].AccessLevel;
            }

            return(typeScope);
        }
        public Constructor(ParsingData parser, ConstructorNode constructorNode)
        {
            AccessLevel = constructorNode.AccessLevel;
            BlockNode   = constructorNode.BlockNode;

            Parameters = ParameterDefineNode.GetParameters(parser, constructorNode.Parameters);
        }
        public static ParameterBase[] GetParameters(ParsingData parser, ParameterDefineNode[] defineNodes)
        {
            ParameterBase[] parameters = new ParameterBase[defineNodes.Length];
            for (int i = 0; i < parameters.Length; i++)
            {
                EnumData    enumData = null;
                DefinedType type     = null;
                if (defineNodes[i].Type != null)
                {
                    enumData = EnumData.GetEnum(defineNodes[i].Type);
                    type     = parser.GetDefinedType(defineNodes[i].Type, null);

                    if (enumData == null && type == null)
                    {
                        throw SyntaxErrorException.NonexistentType(defineNodes[i].Type, defineNodes[i].Location);
                    }
                }

                if (enumData != null)
                {
                    parameters[i] = new EnumParameter(defineNodes[i].VariableName, enumData.Type);
                }

                else if (type != null)
                {
                    parameters[i] = new TypeParameter(defineNodes[i].VariableName, type);
                }

                else
                {
                    parameters[i] = new Parameter(defineNodes[i].VariableName, Elements.ValueType.Any, null);
                }
            }
            return(parameters);
        }
        public ScopeGroup GetRootScope(IndexedVar var, ParsingData parseData, Element target = null)
        {
            if (target == null)
            {
                target = new V_EventPlayer();
            }

            IndexedVar root = GetRoot(var, parseData, target);

            root.DefaultTarget = target;

            ScopeGroup typeScope = new ScopeGroup(parseData.VarCollection);

            typeScope.This = root;

            for (int i = 0; i < DefinedVars.Length; i++)
            {
                IndexedVar newVar = root.CreateChild(typeScope, DefinedVars[i].VariableName, Element.IntToElement(i), DefinedVars[i]);
                newVar.DefaultTarget = target;
                if (DefinedVars[i].Type != null)
                {
                    newVar.Type = parseData.GetDefinedType(DefinedVars[i].Type, DefinedVars[i].Location);
                }
                newVar.AccessLevel = DefinedVars[i].AccessLevel;
            }

            for (int i = 0; i < MethodNodes.Length; i++)
            {
                UserMethod method = new UserMethod(typeScope, MethodNodes[i]);
                method.RegisterParameters(parseData);
                method.AccessLevel = MethodNodes[i].AccessLevel;
            }

            return(typeScope);
        }
 public void RegisterParameters(ParsingData parser)
 {
     if (TypeString != null)
     {
         Type = parser.GetDefinedType(TypeString, Node.Location);
     }
     Parameters = ParameterDefineNode.GetParameters(parser, ParameterNodes);
 }
Example #6
0
 override protected IndexedVar GetRoot(IndexedVar req, ParsingData context, Element target)
 {
     if (req.Name == Name + " root")
     {
         return(req);
     }
     return(context.ClassArray.CreateChild(null, Name + " root", new Element[] { req.GetVariable(target) }, null));
 }
        public TranslateRule(Rule rule, ScopeGroup root, ParsingData parserData)
        {
            VarCollection = parserData.VarCollection;
            ParserData    = parserData;

            Rule     = rule;
            IsGlobal = Rule.IsGlobal;

            ContinueSkip = new ContinueSkip(IsGlobal, Actions, VarCollection);
        }
 public void RegisterParameters(ParsingData parser)
 {
     Constructors = new Constructor[ConstructorNodes.Length];
     for (int i = 0; i < Constructors.Length; i++)
     {
         if (ConstructorNodes[i].Name != Name)
         {
             throw SyntaxErrorException.ConstructorName(ConstructorNodes[i].Location);
         }
         Constructors[i] = new Constructor(parser, ConstructorNodes[i]);
     }
 }
 override protected IndexedVar GetRoot(IndexedVar req, ParsingData context, Element target)
 {
     if (req.Name == Name + " root")
     {
         return(req);
     }
     return(new IndexedVar(
                null,
                Name + " root",
                true,
                Variable.C,
                new Element[] { req.GetVariable(target) },
                context.VarCollection.WorkshopArrayBuilder,
                null
                ));
 }
Example #10
0
 public void RegisterParameters(ParsingData parser)
 {
     if (ConstructorNodes.Length != 0)
     {
         Constructors = new Constructor[ConstructorNodes.Length];
         for (int i = 0; i < Constructors.Length; i++)
         {
             if (ConstructorNodes[i].Name != Name)
             {
                 throw SyntaxErrorException.ConstructorName(ConstructorNodes[i].Location);
             }
             Constructors[i] = new Constructor(parser, ConstructorNodes[i]);
         }
     }
     else
     {
         Constructors = new Constructor[]
         {
             new Constructor(AccessLevel.Public, new Parameter[0], null)
         };
     }
 }
        private TranslateRule(RuleNode ruleNode, ScopeGroup root, ParsingData parserData)
        {
            VarCollection = parserData.VarCollection;
            ParserData    = parserData;

            Rule          = new Rule(ruleNode.Name, ruleNode.Event, ruleNode.Team, ruleNode.Player);
            Rule.Disabled = ruleNode.Disabled;
            IsGlobal      = Rule.IsGlobal;

            ContinueSkip = new ContinueSkip(IsGlobal, Actions, VarCollection);

            ParseConditions(root, ruleNode.Conditions);

            // Parse the block of the rule.
            ScopeGroup ruleScope = root.Child();

            ParseBlock(ruleScope, ruleScope, ruleNode.Block, false, null);

            // Fulfill remaining returns.
            FulfillReturns(0);

            Finish();
        }
 override protected IndexedVar GetRoot(IndexedVar req, ParsingData context, Element target)
 {
     return(req);
 }
 abstract protected IndexedVar GetRoot(IndexedVar req, ParsingData context, Element target);
        public static Rule GetRule(RuleNode ruleNode, ScopeGroup root, ParsingData parserData)
        {
            var result = new TranslateRule(ruleNode, root, parserData);

            return(result.Rule);
        }