本文整理汇总了C#中IdentifierExpression类的典型用法代码示例。如果您正苦于以下问题:C# IdentifierExpression类的具体用法?C# IdentifierExpression怎么用?C# IdentifierExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IdentifierExpression类属于命名空间,在下文中一共展示了IdentifierExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ArgumentReferenceEmitter
internal ArgumentReferenceEmitter(IdentifierExpression identifierExpression, ParameterDefinition parameterDefinition, ILGenerator ilGenerator, IOpCodeIndexer instructionsIndexer)
: base(ilGenerator, instructionsIndexer) {
_parameterDefinition = parameterDefinition;
_identifierExpression = identifierExpression;
Type = parameterDefinition.ParameterType.GetActualType();
}
示例2: VisitIdentifierExpression
public override object VisitIdentifierExpression(IdentifierExpression identifierExpression, object data)
{
if (nameComparer.Equals(identifierExpression.Identifier, from)) {
identifierExpression.Identifier = to;
}
return base.VisitIdentifierExpression(identifierExpression, data);
}
示例3: BuildExpression
public string BuildExpression(Dictionary<string, Expression> selectExpressions)
{
var anonymousTypeCreateExpression = new AnonymousTypeCreateExpression();
var crrv = new ChangeRootReferenceVisitor(FromIdentifier);
foreach (var curExpr in selectExpressions.OrderBy(x => x.Key))
{
curExpr.Value.AcceptVisitor(crrv);
anonymousTypeCreateExpression.Initializers.Add(
new AssignmentExpression(new IdentifierExpression(curExpr.Key), curExpr.Value.Clone()));
}
if (FromExpression == null)
FromExpression = new IdentifierExpression();
var queryExpr = new QueryExpression
{
Clauses =
{
new QueryFromClause
{
Identifier = "doc",
Expression = FromExpression.Clone()
},
new QuerySelectClause
{
Expression = anonymousTypeCreateExpression.Clone()
}
}
};
FromIdentifier = "doc";
var printer = new StringWriter();
var printerVisitor = new CSharpOutputVisitor(printer, FormattingOptionsFactory.CreateSharpDevelop());
queryExpr.AcceptVisitor(printerVisitor);
return printer.GetStringBuilder().ToString();
}
示例4: GenerateFieldDeclaration
static AstNode GenerateFieldDeclaration (RefactoringContext context, IdentifierExpression identifier)
{
return new FieldDeclaration () {
ReturnType = GuessType (context, identifier),
Variables = { new VariableInitializer (identifier.Identifier) }
};
}
示例5: GetLocal
public override DVariable GetLocal(string LocalName, IdentifierExpression id = null)
{
foreach (var kv in Locals)
if (kv.Key.Name == LocalName)
return kv.Key;
return null;
}
示例6: IdentifierExpressionProducesIdentifier
public void IdentifierExpressionProducesIdentifier()
{
var id = new IdentifierExpression("test");
Assert.AreEqual("test", id.Name);
Assert.AreEqual("test", id.ToString(false));
}
示例7: E
ISemantic E(IdentifierExpression id, bool ImplicitlyExecute = true)
{
if (id.IsIdentifier)
{
var o = GetOverloads(id, ctxt);
if (eval)
{
if (o == null || o.Length == 0)
{
EvalError(id, "Symbol could not be found");
return null;
}
return TryDoCTFEOrGetValueRefs(o, id, ImplicitlyExecute);
}
else
{
ctxt.CheckForSingleResult(o, id);
if (o != null)
if (o.Length == 1)
return o[0];
else if (o.Length > 1)
return new InternalOverloadValue(o);
return null;
}
}
else
return EvaluateLiteral(id);
}
示例8: ReplaceStringLiteralsWithVariables
public static string ReplaceStringLiteralsWithVariables(string text, IEnumerable<string> macros, Func<int, int, string, string, string> onReplace)
{
var setting = new CompilerSettings();
foreach (var macro in macros) setting.ConditionalSymbols.Add(macro);
var tree = SyntaxTree.Parse(text, string.Empty, setting);
tree.Freeze();
var doc = new StringBuilderDocument(text);
using (var editor = new DocumentScript(doc, FormattingOptionsFactory.CreateAllman(), TextEditorOptions.Default)) {
var originDoc = editor.OriginalDocument;
foreach (var node in tree.Descendants.OfType<PrimitiveExpression>().Where(e => e.Value is string)) {
var line = originDoc.GetLineByNumber(node.StartLocation.Line);
var result = onReplace(node.StartLocation.Line, node.StartLocation.Column, originDoc.GetText(line), node.Value as string);
if (result != null) {
var names = result.Split('.');
Expression exp = new IdentifierExpression(names.First());
foreach (var name in names.Skip(1)) exp = exp.Member(name);
editor.Replace(node, exp);
}
}
}
return doc.Text;
}
示例9: Run
public void Run (RefactoringContext context)
{
var foreachStatement = GetForeachStatement (context);
var result = context.ResolveType (foreachStatement.InExpression);
var countProperty = GetCountProperty (result);
var initializer = new VariableDeclarationStatement (new PrimitiveType ("int"), "i", new PrimitiveExpression (0));
var id1 = new IdentifierExpression ("i");
var id2 = id1.Clone ();
var id3 = id1.Clone ();
var forStatement = new ForStatement () {
Initializers = { initializer },
Condition = new BinaryOperatorExpression (id1, BinaryOperatorType.LessThan, new MemberReferenceExpression (foreachStatement.InExpression.Clone (), countProperty)),
Iterators = { new ExpressionStatement (new UnaryOperatorExpression (UnaryOperatorType.PostIncrement, id2)) },
EmbeddedStatement = new BlockStatement {
new VariableDeclarationStatement (foreachStatement.VariableType.Clone (), foreachStatement.VariableName, new IndexerExpression (foreachStatement.InExpression.Clone (), id3))
}
};
if (foreachStatement.EmbeddedStatement is BlockStatement) {
foreach (var child in ((BlockStatement)foreachStatement.EmbeddedStatement).Statements) {
forStatement.EmbeddedStatement.AddChild (child.Clone (), BlockStatement.StatementRole);
}
} else {
forStatement.EmbeddedStatement.AddChild (foreachStatement.EmbeddedStatement.Clone (), BlockStatement.StatementRole);
}
using (var script = context.StartScript ()) {
script.Replace (foreachStatement, forStatement);
script.Link (initializer.Variables.First ().NameToken, id1, id2, id3);
}
}
示例10: CreateFromExpression
CodeAction CreateFromExpression(RefactoringContext context, Expression expression)
{
var resolveResult = context.Resolve(expression);
if (resolveResult.IsError)
return null;
return new CodeAction(context.TranslateString("Extract method"), script => {
string methodName = "NewMethod";
var method = new MethodDeclaration() {
ReturnType = context.CreateShortType(resolveResult.Type),
Name = methodName,
Body = new BlockStatement() {
new ReturnStatement(expression.Clone())
}
};
if (!StaticVisitor.UsesNotStaticMember(context, expression))
method.Modifiers |= Modifiers.Static;
var task = script.InsertWithCursor(context.TranslateString("Extract method"), Script.InsertPosition.Before, method);
Action<Task> replaceStatements = delegate {
var target = new IdentifierExpression(methodName);
script.Replace(expression, new InvocationExpression(target));
script.Link(target, method.NameToken);
};
if (task.IsCompleted) {
replaceStatements (null);
} else {
task.ContinueWith (replaceStatements, TaskScheduler.FromCurrentSynchronizationContext ());
}
});
}
示例11: PPPragmaNode
public PPPragmaNode(IdentifierExpression identifier, NodeCollection<ConstantExpression> value, PragmaAction action)
: base(identifier.RelatedToken)
{
this.identifier = identifier;
this.value = value;
this.Action = action;
}
示例12: LocalDeclarationStatement
public LocalDeclarationStatement(IType type, IdentifierExpression identifier, ExpressionNode rightSide)
: base(identifier.RelatedToken)
{
this.type = type;
this.identifiers.Expressions.Add(identifier);
this.rightSide = rightSide;
}
示例13: Run
public void Run (RefactoringContext context)
{
var property = context.GetNode<PropertyDeclaration> ();
string backingStoreName = context.GetNameProposal (property.Name);
// create field
var backingStore = new FieldDeclaration ();
backingStore.ReturnType = property.ReturnType.Clone ();
var initializer = new VariableInitializer (backingStoreName);
backingStore.Variables.Add (initializer);
// create new property & implement the get/set bodies
var newProperty = (PropertyDeclaration)property.Clone ();
var id1 = new IdentifierExpression (backingStoreName);
var id2 = new IdentifierExpression (backingStoreName);
newProperty.Getter.Body = new BlockStatement () {
new ReturnStatement (id1)
};
newProperty.Setter.Body = new BlockStatement () {
new ExpressionStatement (new AssignmentExpression (id2, AssignmentOperatorType.Assign, new IdentifierExpression ("value")))
};
using (var script = context.StartScript ()) {
script.Replace (property, newProperty);
script.InsertBefore (property, backingStore);
script.Link (initializer, id1, id2);
}
}
示例14: Visit
public ISymbolValue Visit(IdentifierExpression id)
{
var ImplicitlyExecute = this.ImplicitlyExecute;
this.ImplicitlyExecute = true;
if (id.IsIdentifier)
{
var o = ExpressionTypeEvaluation.EvaluateTypes(id, ctxt);
if (o == null || o.Length == 0)
{
EvalError(id, "Symbol could not be found");
return null;
}
return TryDoCTFEOrGetValueRefs(o, id, ImplicitlyExecute);
}
byte tt;
switch (id.Format)
{
case Parser.LiteralFormat.CharLiteral:
var tk = id.Subformat == LiteralSubformat.Utf32 ? DTokens.Dchar :
id.Subformat == LiteralSubformat.Utf16 ? DTokens.Wchar :
DTokens.Char;
return new PrimitiveValue(tk, Convert.ToDecimal((int)(char)id.Value), id);
case LiteralFormat.FloatingPoint | LiteralFormat.Scalar:
var im = id.Subformat.HasFlag(LiteralSubformat.Imaginary);
tt = im ? DTokens.Idouble : DTokens.Double;
if (id.Subformat.HasFlag(LiteralSubformat.Float))
tt = im ? DTokens.Ifloat : DTokens.Float;
else if (id.Subformat.HasFlag(LiteralSubformat.Real))
tt = im ? DTokens.Ireal : DTokens.Real;
var v = Convert.ToDecimal(id.Value);
return new PrimitiveValue(tt, im ? 0 : v, id, im ? v : 0);
case LiteralFormat.Scalar:
var unsigned = id.Subformat.HasFlag(LiteralSubformat.Unsigned);
if (id.Subformat.HasFlag(LiteralSubformat.Long))
tt = unsigned ? DTokens.Ulong : DTokens.Long;
else
tt = unsigned ? DTokens.Uint : DTokens.Int;
return new PrimitiveValue(tt, Convert.ToDecimal(id.Value), id);
case Parser.LiteralFormat.StringLiteral:
case Parser.LiteralFormat.VerbatimStringLiteral:
return new ArrayValue(GetStringType(id.Subformat), id);
default:
return null;
}
}
示例15: ArrayValue
/// <summary>
/// String constructor.
/// Given result stores both type and idenfitierexpression whose Value is used as content
/// </summary>
public ArrayValue(ArrayType stringLiteralResult, IdentifierExpression stringLiteral=null)
: base(ExpressionValueType.Array, stringLiteralResult, stringLiteral)
{
if (stringLiteralResult.DeclarationOrExpressionBase is IdentifierExpression)
StringValue = ((IdentifierExpression)stringLiteralResult.DeclarationOrExpressionBase).Value as string;
else
StringValue = stringLiteral.Value as string;
}