コード例 #1
0
        public IndexerExpression(Expression objectReference, IndexerSymbol indexer)
            : base(ExpressionType.Indexer, indexer.AssociatedType, SymbolFilter.Public | SymbolFilter.InstanceMembers) {
            _indexer = indexer;
            _objectReference = objectReference;

            _indices = new Collection<Expression>();
        }
コード例 #2
0
 public ConditionalExpression(Expression condition, Expression trueValue, Expression falseValue)
     : base(ExpressionType.Conditional, trueValue.EvaluatedType, trueValue.MemberMask)
 {
     _condition = condition;
     _trueValue = trueValue;
     _falseValue = falseValue;
 }
コード例 #3
0
 public MemberExpression(Expression objectReference, MemberSymbol member)
     : base(ExpressionType.Member, (member.AssociatedType.Type == SymbolType.GenericParameter ? objectReference.EvaluatedType : member.AssociatedType),
            SymbolFilter.Public | SymbolFilter.InstanceMembers)
 {
     _member = member;
     _objectReference = objectReference;
 }
コード例 #4
0
 public NewDelegateExpression(Expression typeExpression, TypeSymbol associatedType)
     : base(ExpressionType.NewDelegate, associatedType, SymbolFilter.Public | SymbolFilter.InstanceMembers)
 {
     Debug.Assert(associatedType.Type == SymbolType.Delegate);
     _typeExpression = typeExpression;
     _associatedType = associatedType;
 }
コード例 #5
0
 public BinaryExpression(Operator operatorType, Expression leftOperand, Expression rightOperand, TypeSymbol evaluatedType)
     : base(ExpressionType.Binary, evaluatedType, SymbolFilter.Public | SymbolFilter.InstanceMembers)
 {
     _operator = operatorType;
     _leftOperand = leftOperand;
     _rightOperand = rightOperand;
 }
コード例 #6
0
 protected MethodExpression(ExpressionType type, Expression objectReference, MethodSymbol method, Collection<Expression> parameters) :
     base(type, (method.AssociatedType.Type == SymbolType.GenericParameter ? objectReference.EvaluatedType : method.AssociatedType),
          SymbolFilter.Public | SymbolFilter.InstanceMembers) {
     _method = method;
     _objectReference = objectReference;
     _parameters = (parameters == null) ? new Collection<Expression>() : parameters;
 }
コード例 #7
0
        public void SetHandler(Expression handler)
        {
            Debug.Assert(handler != null);
            Debug.Assert(_handler == null);

            _handler = handler;
        }
コード例 #8
0
ファイル: SwitchGroup.cs プロジェクト: mobilligy/scriptsharp
 public void AddCase(Expression caseValue)
 {
     if (_cases == null) {
         _cases = new List<Expression>();
     }
     _cases.Add(caseValue);
 }
コード例 #9
0
 public void AddParameterValue(Expression expression)
 {
     if (_parameters == null) {
         _parameters = new Collection<Expression>();
     }
     _parameters.Add(expression);
 }
コード例 #10
0
 public WhileStatement(Expression condition, Statement body, bool preCondition)
     : base(StatementType.While)
 {
     _condition = condition;
     _body = body;
     _preCondition = preCondition;
 }
コード例 #11
0
 public IfElseStatement(Expression condition, Statement ifStatement, Statement elseStatement)
     : base(StatementType.IfElse)
 {
     _condition = condition;
     _ifStatement = ifStatement;
     _elseStatement = elseStatement;
 }
コード例 #12
0
        public LateBoundExpression(Expression objectReference, Expression nameExpression, LateBoundOperation operation, TypeSymbol evaluatedType)
            : base(ExpressionType.LateBound, evaluatedType, SymbolFilter.Public | SymbolFilter.InstanceMembers) {
            _objectReference = objectReference;
            _nameExpression = nameExpression;
            _operation = operation;

            _parameters = new Collection<Expression>();
        }
コード例 #13
0
ファイル: ThrowStatement.cs プロジェクト: fugaku/scriptsharp
 public ThrowStatement(Expression value)
     : base(StatementType.Throw) {
     _value = value;
 }
コード例 #14
0
 public PropertyExpression(Expression objectReference, PropertySymbol property, bool getter)
     : base((getter ? ExpressionType.PropertyGet : ExpressionType.PropertySet), property.AssociatedType, SymbolFilter.Public | SymbolFilter.InstanceMembers)
 {
     _property = property;
     _objectReference = objectReference;
 }
コード例 #15
0
ファイル: NewExpression.cs プロジェクト: fugaku/scriptsharp
 public NewExpression(Expression typeExpression, TypeSymbol associatedType)
     : base(ExpressionType.New, associatedType, SymbolFilter.Public | SymbolFilter.InstanceMembers) {
     _typeExpression = typeExpression;
     _associatedType = associatedType;
 }
コード例 #16
0
 public ExpressionStatement(Expression expression, bool isFragment)
     : base(StatementType.Expression)
 {
     _expression = expression;
     _fragment = isFragment;
 }
コード例 #17
0
 public UnaryExpression(Operator operatorType, Expression operand)
     : this(operatorType, operand, operand.EvaluatedType, operand.MemberMask)
 {
 }
コード例 #18
0
 public MethodExpression(Expression objectReference, MethodSymbol method)
     : this(ExpressionType.MethodInvoke, objectReference, method, null) {
 }
コード例 #19
0
 public void AddParameterValue(Expression expression) {
     _parameters.Add(expression);
 }
コード例 #20
0
ファイル: SwitchStatement.cs プロジェクト: fugaku/scriptsharp
 public SwitchStatement(Expression condition)
     : base(StatementType.Switch) {
     _condition = condition;
     _groups = new List<SwitchGroup>();
 }
コード例 #21
0
 public EnumerationFieldExpression(Expression objectReference, EnumerationFieldSymbol field)
     : base(ExpressionType.EnumerationField, objectReference, field) {
 }
コード例 #22
0
 public UnaryExpression(Operator operatorType, Expression operand, TypeSymbol evaluatedType, SymbolFilter memberMask)
     : base(ExpressionType.Unary, evaluatedType, memberMask)
 {
     _operator = operatorType;
     _operand = operand;
 }
コード例 #23
0
ファイル: VariableSymbol.cs プロジェクト: fugaku/scriptsharp
 public void SetValue(Expression value) {
     _value = value;
 }
コード例 #24
0
 public ExpressionStatement(Expression expression)
     : this(expression, false)
 {
 }
コード例 #25
0
ファイル: ForStatement.cs プロジェクト: mobilligy/scriptsharp
 public void AddCondition(Expression expression)
 {
     Debug.Assert(_condition == null);
     _condition = expression;
 }
コード例 #26
0
        private Expression ProcessArrayNewNode(ArrayNewNode node) {
            TypeSymbol itemTypeSymbol = _symbolSet.ResolveType(node.TypeReference, _symbolTable, _symbolContext);
            Debug.Assert(itemTypeSymbol != null);

            TypeSymbol arrayTypeSymbol = _symbolSet.CreateArrayTypeSymbol(itemTypeSymbol);

            if (node.InitializerExpression == null) {
                if (node.ExpressionList == null) {
                    return new LiteralExpression(arrayTypeSymbol, new Expression[0]);
                }
                else {
                    Debug.Assert(node.ExpressionList.NodeType == ParseNodeType.ExpressionList);
                    ExpressionListNode argsList = (ExpressionListNode)node.ExpressionList;

                    Debug.Assert(argsList.Expressions.Count == 1);
                    Expression sizeExpression = BuildExpression(argsList.Expressions[0]);
                    if (sizeExpression is MemberExpression) {
                        sizeExpression = TransformMemberExpression((MemberExpression)sizeExpression);
                    }

                    NewExpression newExpr = new NewExpression(arrayTypeSymbol);
                    newExpr.AddParameterValue(sizeExpression);

                    return newExpr;
                }
            }
            else {
                ArrayInitializerNode initializerNode = (ArrayInitializerNode)node.InitializerExpression;
                Expression[] values = new Expression[initializerNode.Values.Count];

                int i = 0;
                foreach (ParseNode valueNode in initializerNode.Values) {
                    values[i] = BuildExpression(valueNode);
                    if (values[i] is MemberExpression) {
                        values[i] = TransformMemberExpression((MemberExpression)values[i]);
                    }
                    i++;
                }

                return new LiteralExpression(arrayTypeSymbol, values);
            }
        }
コード例 #27
0
        public static void GenerateExpression(ScriptGenerator generator, MemberSymbol symbol, Expression expression)
        {
            ScriptTextWriter writer = generator.Writer;

            if (expression.Parenthesized) {
                writer.Write("(");
            }

            switch (expression.Type) {
                case ExpressionType.Literal:
                    GenerateLiteralExpression(generator, symbol, (LiteralExpression)expression);
                    break;
                case ExpressionType.Local:
                    GenerateLocalExpression(generator, symbol, (LocalExpression)expression);
                    break;
                case ExpressionType.Member:
                    Debug.Fail("MemberExpression missed from conversion to higher level expression.");
                    break;
                case ExpressionType.Field:
                    GenerateFieldExpression(generator, symbol, (FieldExpression)expression);
                    break;
                case ExpressionType.EnumerationField:
                    GenerateEnumerationFieldExpression(generator, symbol, (EnumerationFieldExpression)expression);
                    break;
                case ExpressionType.PropertyGet:
                    GeneratePropertyExpression(generator, symbol, (PropertyExpression)expression);
                    break;
                case ExpressionType.PropertySet:
                    Debug.Fail("PropertyExpression(set) should be covered as part of BinaryExpression logic.");
                    break;
                case ExpressionType.MethodInvoke:
                case ExpressionType.DelegateInvoke:
                    GenerateMethodExpression(generator, symbol, (MethodExpression)expression);
                    break;
                case ExpressionType.BaseInitializer:
                    GenerateBaseInitializerExpression(generator, symbol, (BaseInitializerExpression)expression);
                    break;
                case ExpressionType.EventAdd:
                case ExpressionType.EventRemove:
                    GenerateEventExpression(generator, symbol, (EventExpression)expression);
                    break;
                case ExpressionType.Indexer:
                    GenerateIndexerExpression(generator, symbol, (IndexerExpression)expression);
                    break;
                case ExpressionType.This:
                    GenerateThisExpression(generator, symbol, (ThisExpression)expression);
                    break;
                case ExpressionType.Base:
                    Debug.Fail("BaseExpression not handled by container expression.");
                    break;
                case ExpressionType.New:
                    GenerateNewExpression(generator, symbol, (NewExpression)expression);
                    break;
                case ExpressionType.Unary:
                    GenerateUnaryExpression(generator, symbol, (UnaryExpression)expression);
                    break;
                case ExpressionType.Binary:
                    GenerateBinaryExpression(generator, symbol, (BinaryExpression)expression);
                    break;
                case ExpressionType.Conditional:
                    GenerateConditionalExpression(generator, symbol, (ConditionalExpression)expression);
                    break;
                case ExpressionType.Type:
                    GenerateTypeExpression(generator, symbol, (TypeExpression)expression);
                    break;
                case ExpressionType.Delegate:
                    GenerateDelegateExpression(generator, symbol, (DelegateExpression)expression);
                    break;
                case ExpressionType.LateBound:
                    GenerateLateBoundExpression(generator, symbol, (LateBoundExpression)expression);
                    break;
                case ExpressionType.InlineScript:
                    GenerateInlineScriptExpression(generator, symbol, (InlineScriptExpression)expression);
                    break;
                default:
                    Debug.Fail("Unexpected expression type: " + expression.Type);
                    break;
            }

            if (expression.Parenthesized) {
                writer.Write(")");
            }
        }
コード例 #28
0
ファイル: ForStatement.cs プロジェクト: mobilligy/scriptsharp
 public void AddIncrement(Expression expression)
 {
     if (_increments == null) {
         _increments = new List<Expression>();
     }
     _increments.Add(expression);
 }
コード例 #29
0
 public DelegateExpression(Expression objectReference, MethodSymbol method)
     : base(ExpressionType.Delegate, method.AssociatedType, SymbolFilter.Public | SymbolFilter.InstanceMembers)
 {
     _method = method;
     _objectReference = objectReference;
 }
コード例 #30
0
ファイル: ForStatement.cs プロジェクト: mobilligy/scriptsharp
 public void AddInitializer(Expression expression)
 {
     Debug.Assert(_variables == null);
     if (_initializers == null) {
         _initializers = new List<Expression>();
     }
     _initializers.Add(expression);
 }