예제 #1
0
        public ScriptQualifiedName(AstNodeArgs args)
            : base(args)
        {
            if (ChildNodes.Count == 2 && ChildNodes[1].ChildNodes.Count == 0)
            {
                Identifier = ((Token)ChildNodes[0]).Text;

                evaluation = EvaluateIdentifier;
                assignment = AssignIdentifier;
            }
            else
            if (ChildNodes[0] is Token && ChildNodes[1].ChildNodes.Count != 0)
            {
                Identifier = (ChildNodes[0] as Token).Text;

                //NOTE: There might be two cases:
                //      1) a()[]...()
                //      2) a<>.(NamePart)
                Modifiers = new List <ScriptAst>();
                foreach (ScriptAst node in ChildNodes[1].ChildNodes)
                {
                    Modifiers.Add(node);
                }

                ScriptGenericsPostfix generic = Modifiers.FirstOrDefault() as ScriptGenericsPostfix;
                if (generic != null && Modifiers.Count == 1)
                {
                    //Case 2
                    evaluation = EvaluateGenericType;
                    assignment = null;
                }
                else
                {
                    //Case 1
                    evaluation = EvaluateFunctionCall;
                    assignment = AssignArray;
                }
            }
            else
            {
                NamePart   = ChildNodes[0] as ScriptQualifiedName;
                Identifier = ((Token)ChildNodes[2]).Text;
                if (ChildNodes.Count == 4 && ChildNodes[3].ChildNodes.Count != 0)
                {
                    Modifiers = new List <ScriptAst>();
                    foreach (ScriptAst node in ChildNodes[3].ChildNodes)
                    {
                        Modifiers.Add(node);
                    }
                }
                evaluation = EvaluateNamePart;
                assignment = AssignNamePart;
            }
        }
예제 #2
0
        public ScriptQualifiedName(AstNodeArgs args)
            : base(args)
        {
            if (ChildNodes.Count == 2 && ChildNodes[1].ChildNodes.Count == 0)
              {
            Identifier = ((Token)ChildNodes[0]).Text;

            evaluation = EvaluateIdentifier;
            assignment = AssignIdentifier;
              }
              else
            if (ChildNodes[0] is Token && ChildNodes[1].ChildNodes.Count != 0)
            {
              Identifier = (ChildNodes[0] as Token).Text;

              //NOTE: There might be two cases:
              //      1) a()[]...()
              //      2) a<>.(NamePart)
              Modifiers = new List<ScriptAst>();
              foreach (ScriptAst node in ChildNodes[1].ChildNodes)
            Modifiers.Add(node);

              ScriptGenericsPostfix generic = Modifiers.FirstOrDefault() as ScriptGenericsPostfix;
              if (generic != null && Modifiers.Count == 1)
              {
            //Case 2
            evaluation = EvaluateGenericType;
            assignment = null;
              }
              else
              {
            //Case 1
            evaluation = EvaluateFunctionCall;
            assignment = AssignArray;
              }
            }
            else
            {
              NamePart = ChildNodes[0] as ScriptQualifiedName;
              Identifier = ((Token)ChildNodes[2]).Text;
              if (ChildNodes.Count == 4 && ChildNodes[3].ChildNodes.Count != 0)
              {
            Modifiers = new List<ScriptAst>();
            foreach (ScriptAst node in ChildNodes[3].ChildNodes)
            {
              Modifiers.Add(node);
            }
              }
              evaluation = EvaluateNamePart;
              assignment = AssignNamePart;
            }
        }
예제 #3
0
        public ScriptAssignExpr(AstNodeArgs args)
            : base(args)
        {
            nameExpr = (ScriptQualifiedName)args.ChildNodes[0];
            oper     = ((Token)args.ChildNodes[1]).Text;
            if (args.ChildNodes.Count == 3)
            {
                rightExpr = (ScriptExpr)args.ChildNodes[2];
            }

            Debug.Assert(oper == "=" || oper == ":=" || oper == "+=" || oper == "-=" || oper == "++" || oper == "--" || oper == ":=");

            switch (oper)
            {
            case "=":
                assignOperation = Assign;
                break;

            case ":=":
                assignOperation = AssignEx;
                break;

            case "++":
                assignOperation = PlusPlus;
                break;

            case "--":
                assignOperation = MinusMinus;
                break;

            case "+=":
                assignOperation = PlusEqual;
                break;

            case "-=":
                assignOperation = MinusEqual;
                break;

            default:
                throw new ScriptException("Assignment operator:" + oper + " is not supported");
            }

            minus = RuntimeHost.GetBinaryOperator("-");
            plus  = RuntimeHost.GetBinaryOperator("+");

            if (plus == null || minus == null)
            {
                throw new ScriptException("RuntimeHost did not initialize property. Can't find binary operators.");
            }
        }
예제 #4
0
        public ScriptAssignExpr(AstNodeArgs args)
            : base(args)
        {
            nameExpr = (ScriptQualifiedName)args.ChildNodes[0];
              oper = ((Token)args.ChildNodes[1]).Text;
              if (args.ChildNodes.Count == 3)
            rightExpr = (ScriptExpr)args.ChildNodes[2];

              Debug.Assert(oper == "=" || oper == ":=" || oper == "+=" || oper == "-=" || oper == "++" || oper == "--" || oper == ":=");

              switch (oper)
              {
            case "=":
              assignOperation = Assign;
              break;
            case ":=":
              assignOperation = AssignEx;
              break;
            case "++":
              assignOperation = PlusPlus;
              break;
            case "--":
              assignOperation = MinusMinus;
              break;
            case "+=":
              assignOperation = PlusEqual;
              break;
            case "-=":
              assignOperation = MinusEqual;
              break;
            default:
              throw new ScriptException("Assignment operator:" + oper + " is not supported");
              }

              minus = RuntimeHost.GetBinaryOperator("-");
              plus = RuntimeHost.GetBinaryOperator("+");

              if (plus == null || minus == null)
            throw new ScriptException("RuntimeHost did not initialize property. Can't find binary operators.");
        }
예제 #5
0
 public ScriptUsingStatement(AstNodeArgs args)
     : base(args)
 {
     name = args.ChildNodes[1] as ScriptQualifiedName;
       statement = args.ChildNodes[2] as ScriptAst;
 }
예제 #6
0
 public ScriptUsingStatement(AstNodeArgs args)
     : base(args)
 {
     name      = args.ChildNodes[1] as ScriptQualifiedName;
     statement = args.ChildNodes[2] as ScriptAst;
 }