public ScriptTypeConvertExpr(AstNodeArgs args)
            : base(args)
        {
            if (ChildNodes.Count == 2)
            {
                if (args.ChildNodes[0] is ScriptExpr &&
                    !(args.ChildNodes[1] is ScriptExpr))
                {
                    // ( Expr )
                    _expr     = args.ChildNodes[0] as ScriptExpr;
                    _typeExpr = null;
                }
                else
                {
                    //(Type) Expr
                    _typeExpr = args.ChildNodes[0] as ScriptExpr;
                    _expr     = args.ChildNodes[1] as ScriptExpr;
                }
            }
            else
            {
                throw new ScriptSyntaxErrorException(Strings.GrammarErrorExceptionMessage);
            }

            _operator = RuntimeHost.GetBinaryOperator("+");
            if (_operator == null)
            {
                throw new ScriptRuntimeException(string.Format(Strings.MissingOperatorError, "+"));
            }
        }
    public ScriptTypeConvertExpr(AstNodeArgs args)
        : base(args)
    {
      if (ChildNodes.Count == 2)
      {
        if (args.ChildNodes[0] is ScriptExpr &&
            !(args.ChildNodes[1] is ScriptExpr))
        {
          // ( Expr )
          _expr = args.ChildNodes[0] as ScriptExpr;
          _typeExpr = null;
        }
        else
        {
          //(Type) Expr
          _typeExpr = args.ChildNodes[0] as ScriptExpr;
          _expr = args.ChildNodes[1] as ScriptExpr;         
        }
      }
      else
      {
        throw new ScriptSyntaxErrorException(Strings.GrammarErrorExceptionMessage);
      }

      _operator = RuntimeHost.GetBinaryOperator("+");
      if (_operator == null)
        throw new ScriptRuntimeException(string.Format(Strings.MissingOperatorError, "+"));
    }
Exemple #3
0
 public ScriptForEachStatement(AstNodeArgs args)
     : base(args)
 {
     _name      = (TokenAst)ChildNodes[1];
     _expr      = (ScriptExpr)ChildNodes[3];
     _statement = (ScriptStatement)ChildNodes[4];
 }
 public ScriptForEachStatement(AstNodeArgs args)
   : base(args)
 {
   _name = (TokenAst)ChildNodes[1];
   _expr = (ScriptExpr)ChildNodes[3];
   _statement = (ScriptStatement)ChildNodes[4];
 }
    public ScriptForStatement(AstNodeArgs args)
        : base(args)
    {
      _init = (ScriptExpr)args.ChildNodes[1];
      _cond = (ScriptExpr)args.ChildNodes[2];
      _next = (ScriptExpr)args.ChildNodes[3];
      _statement = (ScriptStatement)args.ChildNodes[4];

      var body = _statement as ScriptCompoundStatement;
      if (body != null)
        body.ShouldCreateScope = false;
    }
    public ScriptAssignExpr(AstNodeArgs args)
        : base(args)
    {
      var varExpr = args.ChildNodes[0] as ScriptVarExpr;
      if (varExpr != null)
      {
        var id = varExpr.ChildNodes[1] as TokenAst;
        _nameExpr = new ScriptQualifiedName(new AstNodeArgs(args.Term, args.Span,
           new AstNodeList { id, new AstNode(new AstNodeArgs(args.Term, new SourceSpan(new SourceLocation(0, 0, 0), 0), new AstNodeList())) })) { IsVar = true };
      }
      else
      {
        _nameExpr = (ScriptQualifiedName)args.ChildNodes[0];
      }

      _oper = ((TokenAst)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 System.InvalidOperationException(string.Format(Strings.AssignmentOperatorNotSupported, _oper));
      }

      _minus = RuntimeHost.GetBinaryOperator(OperatorCodes.Sub);
      _plus = RuntimeHost.GetBinaryOperator(OperatorCodes.Add);

      if (_plus == null || _minus == null)
        throw new ScriptRuntimeException(string.Format(Strings.MissingOperatorError, "+,-"));
    }
 public ScriptUnaryExpr(AstNodeArgs args)
     : base(args)
 {
   if (ChildNodes[0] is ScriptExpr)
   { 
     _expr = (ScriptExpr)ChildNodes[0];
     OperationSymbol = ((TokenAst)ChildNodes[1]).Text;
   }
   else
   {
     _expr = (ScriptExpr)ChildNodes[1];
     OperationSymbol = ((TokenAst)ChildNodes[0]).Text;
   }
 }
Exemple #8
0
 public ScriptUnaryExpr(AstNodeArgs args)
     : base(args)
 {
     if (ChildNodes[0] is ScriptExpr)
     {
         _expr           = (ScriptExpr)ChildNodes[0];
         OperationSymbol = ((TokenAst)ChildNodes[1]).Text;
     }
     else
     {
         _expr           = (ScriptExpr)ChildNodes[1];
         OperationSymbol = ((TokenAst)ChildNodes[0]).Text;
     }
 }
Exemple #9
0
        public ScriptForStatement(AstNodeArgs args)
            : base(args)
        {
            _init      = (ScriptExpr)args.ChildNodes[1];
            _cond      = (ScriptExpr)args.ChildNodes[2];
            _next      = (ScriptExpr)args.ChildNodes[3];
            _statement = (ScriptStatement)args.ChildNodes[4];

            var body = _statement as ScriptCompoundStatement;

            if (body != null)
            {
                body.ShouldCreateScope = false;
            }
        }
Exemple #10
0
    public ScriptBinExpr(AstNodeArgs args)
        : base(args)
    {
      left = (ScriptExpr)ChildNodes[0];
      Oper = ((TokenAst)ChildNodes[1]).Text;
      right = (ScriptExpr)ChildNodes[2];
      
      Value = RuntimeHost.NullValue;
      if (IsConst)
          Evaluation = ConstFirstEvaluate;
      else
          Evaluation = CompleteEvaluate;

      OperatorFunction = RuntimeHost.GetBinaryOperator(Oper);
      if (OperatorFunction == null)
        throw new ScriptRuntimeException(string.Format(Strings.MissingOperatorError, Oper));
    }
Exemple #11
0
        public ScriptBinExpr(AstNodeArgs args)
            : base(args)
        {
            left  = (ScriptExpr)ChildNodes[0];
            Oper  = ((TokenAst)ChildNodes[1]).Text;
            right = (ScriptExpr)ChildNodes[2];

            Value = RuntimeHost.NullValue;
            if (IsConst)
            {
                Evaluation = ConstFirstEvaluate;
            }
            else
            {
                Evaluation = CompleteEvaluate;
            }

            OperatorFunction = RuntimeHost.GetBinaryOperator(Oper);
            if (OperatorFunction == null)
            {
                throw new ScriptRuntimeException(string.Format(Strings.MissingOperatorError, Oper));
            }
        }
 public ScriptSwitchCaseStatement(AstNodeArgs args)
     : base(args)
 {
     _cond      = ChildNodes[1] as ScriptExpr;
     _statement = ChildNodes[3] as ScriptStatement;
 }
Exemple #13
0
 public ScriptMObjectPart(AstNodeArgs args)
     : base(args)
 {
     _name = ((TokenAst)ChildNodes[0]).Text;
     _expr = ChildNodes[2] as ScriptExpr;
 }
 public ScriptSwitchCaseStatement(AstNodeArgs args)
     : base(args)
 {
   _cond = ChildNodes[1] as ScriptExpr;
   _statement = ChildNodes[3] as ScriptStatement;
 }
Exemple #15
0
 public ScriptCondition(AstNodeArgs args)
     : base(args)
 {
     _conditionExpression = (ScriptExpr)ChildNodes[0];
 }
 public ScriptMObjectPart(AstNodeArgs args)
     : base(args)
 {
   _name = ((TokenAst) ChildNodes[0]).Text;
   _expr = ChildNodes[2] as ScriptExpr;
 }
Exemple #17
0
        public ScriptAssignExpr(AstNodeArgs args)
            : base(args)
        {
            var varExpr = args.ChildNodes[0] as ScriptVarExpr;

            if (varExpr != null)
            {
                var id = varExpr.ChildNodes[1] as TokenAst;
                _nameExpr = new ScriptQualifiedName(new AstNodeArgs(args.Term, args.Span,
                                                                    new AstNodeList {
                    id, new AstNode(new AstNodeArgs(args.Term, new SourceSpan(new SourceLocation(0, 0, 0), 0), new AstNodeList()))
                }))
                {
                    IsVar = true
                };
            }
            else
            {
                _nameExpr = (ScriptQualifiedName)args.ChildNodes[0];
            }

            _oper = ((TokenAst)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 System.InvalidOperationException(string.Format(Strings.AssignmentOperatorNotSupported, _oper));
            }

            _minus = RuntimeHost.GetBinaryOperator(OperatorCodes.Sub);
            _plus  = RuntimeHost.GetBinaryOperator(OperatorCodes.Add);

            if (_plus == null || _minus == null)
            {
                throw new ScriptRuntimeException(string.Format(Strings.MissingOperatorError, "+,-"));
            }
        }
Exemple #18
0
 public ScriptCondition(AstNodeArgs args)
     : base(args)
 {
   _conditionExpression = (ScriptExpr)ChildNodes[0];
 }