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); }
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); }
ULCall ExportExp(ThisExpressionSyntax e) { ULCall node = new ULCall(); node.Parent = currentBlock; node.callType = ULCall.ECallType.GetThis; //currentBlock.statements.Add(node); return(node); }
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); }
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); }
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); }
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); }
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); }
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); }
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); } } }
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); }
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); }
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); }
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(); }