コード例 #1
0
ファイル: CSToUL.cs プロジェクト: xiongfang/UL
        ULCall ExportExp(InvocationExpressionSyntax es)
        {
            ULCall node = new ULCall();

            node.Parent   = currentBlock;
            node.callType = ULCall.ECallType.Method;


            //if (es.Expression is MemberAccessExpressionSyntax)
            //{
            //    MemberAccessExpressionSyntax maes = es.Expression as MemberAccessExpressionSyntax;
            //    db_les.Name = (maes).Name.Identifier.Text;
            //    db_les.Caller = ExportExp(maes.Expression);
            //}
            //else if (es.Expression is IdentifierNameSyntax)
            //{
            //    IdentifierNameSyntax nameSyntax = es.Expression as IdentifierNameSyntax;
            //    db_les.Name = nameSyntax.Identifier.Text;
            //    db_les.Caller = new Metadata.Expression.ThisExp();
            //}
            //else
            //{
            //    Console.Error.WriteLine("不支持的方法调用表达式 " + es.ToString());
            //}

            node.Name = ExportExp(es.Expression).GetOutputName(0);

            foreach (var a in es.ArgumentList.Arguments)
            {
                node.Args.Add(ExportExp(a.Expression).GetOutputName(0));
            }
            //currentBlock.statements.Add(node);
            return(node);
        }
コード例 #2
0
ファイル: CSToUL.cs プロジェクト: xiongfang/UL
        ULCall ExportExp(BaseExpressionSyntax es)
        {
            var db_les = new ULCall();

            db_les.Parent   = currentBlock;
            db_les.callType = ULCall.ECallType.GetBase;
            //currentBlock.statements.Add(db_les);
            return(db_les);
        }
コード例 #3
0
ファイル: CSToUL.cs プロジェクト: xiongfang/UL
        ULCall ExportExp(ThisExpressionSyntax e)
        {
            ULCall node = new ULCall();

            node.Parent   = currentBlock;
            node.callType = ULCall.ECallType.GetThis;
            //currentBlock.statements.Add(node);
            return(node);
        }
コード例 #4
0
ファイル: CSToUL.cs プロジェクト: xiongfang/UL
        ULCall ExportExp(LiteralExpressionSyntax e)
        {
            ULCall node = new ULCall();

            node.Parent   = currentBlock;
            node.callType = ULCall.ECallType.Const;
            //currentBlock.statements.Add(node);
            node.Args.Add(e.Token.Text);
            return(node);
        }
コード例 #5
0
ファイル: CSToUL.cs プロジェクト: xiongfang/UL
        ULCall ExportExp(AssignmentExpressionSyntax es)
        {
            ULCall node = new ULCall();

            node.Parent   = currentBlock;
            node.callType = ULCall.ECallType.Assign;
            node.Args.Add(ExportExp(es.Left).GetOutputName(0));
            node.Args.Add(ExportExp(es.Right).GetOutputName(0));
            //currentBlock.statements.Add(node);
            return(node);
        }
コード例 #6
0
ファイル: CSToUL.cs プロジェクト: xiongfang/UL
        ULCall ExportExp(IdentifierNameSyntax es)
        {
            ULCall node = new ULCall();

            node.Parent   = currentBlock;
            node.callType = ULCall.ECallType.Identifier;

            node.Name = es.Identifier.Text;

            //currentBlock.statements.Add(node);
            return(node);
        }
コード例 #7
0
ファイル: CSToUL.cs プロジェクト: xiongfang/UL
        ULCall ExportExp(MemberAccessExpressionSyntax es)
        {
            ULCall node = new ULCall();

            node.Parent   = currentBlock;
            node.callType = ULCall.ECallType.GetField;

            node.Args.Add(ExportExp(es.Expression).GetOutputName(0));
            node.Name = es.Name.Identifier.Text;
            //currentBlock.statements.Add(node);
            return(node);
        }
コード例 #8
0
ファイル: CSToUL.cs プロジェクト: xiongfang/UL
        ULCall ExportExp(ElementAccessExpressionSyntax es)
        {
            ULCall node = new ULCall();

            node.Parent   = currentBlock;
            node.callType = ULCall.ECallType.ElementAccess;

            var exp = ExportExp(es.Expression);

            node.Args.Add(exp.GetOutputName(0));
            foreach (var a in es.ArgumentList.Arguments)
            {
                node.Args.Add(ExportExp(a.Expression).GetOutputName(0));
            }

            return(node);
        }
コード例 #9
0
ファイル: CSToUL.cs プロジェクト: xiongfang/UL
        ULCall ExportExp(PrefixUnaryExpressionSyntax es)
        {
            ULCall node = new ULCall();

            node.Parent   = currentBlock;
            node.callType = ULCall.ECallType.Method;

            node.Name = GetPrefixOperatorTokenMethodName(es.OperatorToken.Text);

            var Left = ExportExp(es.Operand);

            node.Args.Add(Left.GetOutputName(0));


            //currentBlock.statements.Add(node);


            return(node);
        }
コード例 #10
0
ファイル: CSToUL.cs プロジェクト: xiongfang/UL
        void ExportStatement(LocalDeclarationStatementSyntax ss)
        {
            var Type = GetType(ss.Declaration.Type);

            foreach (var v in ss.Declaration.Variables)
            {
                var vName = v.Identifier.Text;
                frames.Peek().variables[vName] = Type.FullName;
                if (v.Initializer != null)
                {
                    ULCall node = new ULCall();
                    node.Parent   = currentBlock;
                    node.callType = ULCall.ECallType.Assign;
                    node.Args.Add("local." + vName);
                    node.Args.Add(ExportExp(v.Initializer.Value).GetOutputName(0));
                    currentBlock.statements.Add(node);
                }
            }
        }
コード例 #11
0
ファイル: CSToUL.cs プロジェクト: xiongfang/UL
        ULCall ExportExp(ArrayCreationExpressionSyntax es)
        {
            var db_les = new ULCall();

            db_les.Parent   = currentBlock;
            db_les.callType = ULCall.ECallType.CreateArray;

            db_les.Args.Add(GetType(es.Type).FullName);
            foreach (var p in es.Type.RankSpecifiers)
            {
                foreach (var s in p.Sizes)
                {
                    db_les.Args.Add(ExportExp(s).GetOutputName(0));
                }
            }

            //currentBlock.statements.Add(db_les);

            return(db_les);
        }
コード例 #12
0
ファイル: CSToUL.cs プロジェクト: xiongfang/UL
        ULCall ExportExp(VariableDeclarationSyntax es)
        {
            var    typeName = GetType(es.Type).FullName;
            ULCall node     = null;

            foreach (var v in es.Variables)
            {
                node          = new ULCall();
                node.Parent   = currentBlock;
                node.callType = ULCall.ECallType.DeclarationLocal;
                node.Args.Add(typeName);
                node.Args.Add(v.Identifier.Text);
                if (v.Initializer != null)
                {
                    node.Args.Add(ExportExp(v.Initializer.Value).GetOutputName(0));
                }
            }

            return(node);
        }
コード例 #13
0
ファイル: CSToUL.cs プロジェクト: xiongfang/UL
        ULCall ExportExp(ObjectCreationExpressionSyntax es)
        {
            ULCall node = new ULCall();

            node.Parent   = currentBlock;
            node.callType = ULCall.ECallType.Constructor;


            if (es.ArgumentList != null)
            {
                foreach (var a in es.ArgumentList.Arguments)
                {
                    node.Args.Add(ExportExp(a.Expression).GetOutputName(0));
                }
            }

            node.Name = GetType(es.Type).FullName;

            //currentBlock.statements.Add(node);
            return(node);
        }
コード例 #14
0
ファイル: ULToCS.cs プロジェクト: xiongfang/UL
        void ToStatement(ULCall s)
        {
            BeginAppendLine();
            if (s.callType == ULCall.ECallType.Assign)
            {
                Append(s.Args[0] + " = " + s.Args[1] + ";");
            }
            else
            {
                //Append(s.Name);
                //Append("(");
                //for (int i = 0; i < s.Args.Count; i++)
                //{
                //    Append(s.Args[i]);
                //    if (i != s.Args.Count - 1)
                //    {
                //        Append(",");
                //    }
                //}
                //Append(");");
            }

            EndAppendLine();
        }