Esempio n. 1
0
        //private IValue internalVisit_BoolBinaryExpression(BinaryExpressionSyntax node, string _operator)
        //{
        //    var symbolInfo = state.Context.RoslynModel.GetSymbolInfo(node);
        //    if (symbolInfo.Symbol != null)
        //        throw new NotSupportedException();

        //    var tmp = internalVisit_BinaryExpressionSyntax(node, _operator);
        //    var l = Visit(node.Left);
        //    var r = Visit(node.Right);
        //    var g = new BinaryOperatorExpression(l, r, _operator, typeof(bool), null);
        //    return g;
        //}
        private IValue InternalVisitTextIdentifier(string identifier)
        {
            var t = context.MatchTypes(identifier, 0);

            if (t.Length > 2)
            {
                throw new NotSupportedException();
            }
            if (t.Length == 1)
            {
                return(new TypeValue(t.First()));
            }

            var lv = context.Arguments.Where(i => i.Name == identifier).ToArray();

            if (lv.Length == 1)
            {
                return(new ArgumentExpression(lv.First().Name, lv.First().Type));
            }

            var lv1 = context.LocalVariables.Where(i => i.Name == identifier).ToArray();

            if (lv1.Length == 1)
            {
                return(new LocalVariableExpression(lv1.First().Name, lv1.First().Type));
            }

            if ((object)_state.CurrentType != null)
            {
                var fi = TypesUtil.ListFields(_state.CurrentType, identifier);
                if (fi.Length == 1)
                {
                    var tmp = fi[0];
                    if (tmp.IsStatic)
                    {
                        throw new NotSupportedException();
                    }
                    var a = new InstanceFieldAccessExpression(fi[0], new ThisExpression(_state.CurrentType));
                    return(Simplify(a));
                }
            }

            {
                var aaaa = _state.Context.MatchTypes(identifier, 0);
                if (aaaa.Length == 1)
                {
                    return(new TypeValue(aaaa[0]));
                }
            }
            return(new UnknownIdentifierValue(identifier, new IValue[0]));
        }