本文整理汇总了C#中Boo.Lang.Compiler.Ast.ReferenceExpression类的典型用法代码示例。如果您正苦于以下问题:C# ReferenceExpression类的具体用法?C# ReferenceExpression怎么用?C# ReferenceExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ReferenceExpression类属于Boo.Lang.Compiler.Ast命名空间,在下文中一共展示了ReferenceExpression类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LiftReferenceExpression
public void LiftReferenceExpression()
{
var referenceExpression = new ReferenceExpression("foo");
var parameter = ParameterDeclaration.Lift(referenceExpression);
Assert.AreEqual(referenceExpression.Name, parameter.Name);
Assert.IsNull(parameter.Type);
}
示例2: OnMethodInvocationExpression
/// <summary>
/// This turn a call to TryGetParemeter('item') where item is a local variable
/// into a WrapIfNull(item) method call.
/// </summary>
/// <param name="node">The node.</param>
public override void OnMethodInvocationExpression(MethodInvocationExpression node)
{
var expression = node.Target as ReferenceExpression;
if (expression == null || expression.Name != "TryGetParameter")
{
base.OnMethodInvocationExpression(node);
return;
}
var name = ((StringLiteralExpression)node.Arguments[0]).Value;
var entity = NameResolutionService.Resolve(name);
if (entity == null)
{
base.OnMethodInvocationExpression(node);
return;
}
var parentNode = node.ParentNode;
var mie = CodeBuilder.CreateMethodInvocation(
CodeBuilder.CreateSelfReference(_currentMethod.DeclaringType),
wrapNullValue);
var item = new ReferenceExpression(node.LexicalInfo, name);
TypeSystemServices.Bind(item, entity);
mie.Arguments.Add(item);
parentNode.Replace(node, mie);
}
示例3: OnReferenceExpression
public override void OnReferenceExpression(ReferenceExpression node)
{
if (LookingFor(node))
{
Found(node);
}
}
示例4: GeneratorExpressionTrees
public GeneratorExpressionTrees(string parameter, ReferenceExpression parameterRef, NameResolutionService nameResolutionService, BooCodeBuilder codeBuilder)
{
_parameter = parameter;
_parameterRef = parameterRef;
_nameResolutionService = nameResolutionService;
_codeBuilder = codeBuilder;
}
示例5: my
public static Expression my(ReferenceExpression typeReference)
{
var myReference = new GenericReferenceExpression(typeReference.LexicalInfo);
myReference.Target = AstUtil.CreateReferenceExpression(typeReference.LexicalInfo, "Boo.Lang.Environments.My");
myReference.GenericArguments.Add(TypeReference.Lift(typeReference));
return new MemberReferenceExpression(typeReference.LexicalInfo, myReference, "Instance");
}
示例6: OnReferenceExpression
public override void OnReferenceExpression(ReferenceExpression node)
{
var entity = NameResolutionService.Resolve(node.Name);
if (entity != null)
{
base.OnReferenceExpression(node);
return;
}
if (node.Name.StartsWith("@"))
{
ReplaceWithComponentReference(node, node.Name);
return;
}
else if (node.ParentNode is ExpressionPair)
{
var pair = (ExpressionPair) node.ParentNode;
var literal = CodeBuilder.CreateStringLiteral(node.Name);
pair.Replace(node, literal);
return;
}
else if (
//search for the left side of a key in a hash literal expression
node.ParentNode is ExpressionPair
&& ((ExpressionPair) node.ParentNode).First == node
&& node.ParentNode.ParentNode is HashLiteralExpression)
{
var parent = (ExpressionPair) node.ParentNode;
var literal = CodeBuilder.CreateStringLiteral(node.Name);
parent.First = literal;
parent.Replace(node, literal);
return;
}
base.OnReferenceExpression(node);
}
示例7: TransformNodeName
/// <summary>
/// Sets the node name to pascal case.
/// </summary>
/// <param name="node">The node.</param>
protected virtual void TransformNodeName(ReferenceExpression node)
{
var nameCharacters = node.Name.ToCharArray();
nameCharacters[0] = char.ToUpperInvariant(nameCharacters[0]);
node.Name = new string(nameCharacters);
}
示例8: OnReferenceExpression
public override void OnReferenceExpression(ReferenceExpression node)
{
IAccessibleMember member = node.Entity as IAccessibleMember;
if (null == member) return;
if (_checker.IsAccessible(member)) return;
Error(CompilerErrorFactory.UnaccessibleMember(node, member.FullName));
}
示例9: AmbiguousReference
public static CompilerError AmbiguousReference(ReferenceExpression reference, System.Reflection.MemberInfo[] members)
{
return new CompilerError("BCE0004",
SafeLexicalInfo(reference),
reference.Name,
ToNameList(members)
);
}
示例10: MakeReferenceExpression
B.ReferenceExpression MakeReferenceExpression(string fullName)
{
string[] parts = fullName.Split('.');
B.ReferenceExpression r = new B.ReferenceExpression(lastLexicalInfo, parts[0]);
for (int i = 1; i < parts.Length; i++)
r = new B.MemberReferenceExpression(lastLexicalInfo, r, parts[i]);
return r;
}
示例11: OnMethodInvocationExpression
public override void OnMethodInvocationExpression(MethodInvocationExpression node)
{
if (node is MethodInvocationExpression && node.Target is GenericReferenceExpression)
{
var genericReferenceExpression = (GenericReferenceExpression)node.Target;
if (genericReferenceExpression.Target is MemberReferenceExpression)
{
var memberReferenceExpression = (MemberReferenceExpression)genericReferenceExpression.Target;
if (memberReferenceExpression.Target is MemberReferenceExpression)
{
var memberReferenceExpression2 = (MemberReferenceExpression)memberReferenceExpression.Target;
if (memberReferenceExpression2.Target is MemberReferenceExpression)
{
var memberReferenceExpression3 = (MemberReferenceExpression)memberReferenceExpression2.Target;
if (memberReferenceExpression3.Target is ReferenceExpression)
{
var referenceExpression = (ReferenceExpression)memberReferenceExpression3.Target;
if (referenceExpression.Name == "Boo" && memberReferenceExpression3.Name == "Lang" && memberReferenceExpression2.Name == "Builtins" && memberReferenceExpression.Name == "array" && 1 == ((ICollection)genericReferenceExpression.GenericArguments).Count)
{
TypeReference node2 = genericReferenceExpression.GenericArguments[0];
if (1 == ((ICollection)node.Arguments).Count && node.Arguments[0] is CastExpression)
{
var castExpression = (CastExpression)node.Arguments[0];
Expression target = castExpression.Target;
if (castExpression.Type is SimpleTypeReference)
{
var simpleTypeReference = (SimpleTypeReference)castExpression.Type;
if (simpleTypeReference.Name == "int")
{
var methodInvocationExpression = new MethodInvocationExpression(LexicalInfo.Empty);
var arg_255_0 = methodInvocationExpression;
var genericReferenceExpression2 = new GenericReferenceExpression(LexicalInfo.Empty);
GenericReferenceExpression arg_226_0 = genericReferenceExpression2;
var referenceExpression2 = new ReferenceExpression(LexicalInfo.Empty);
string text = referenceExpression2.Name = "array";
Expression expression = arg_226_0.Target = referenceExpression2;
TypeReferenceCollection typeReferenceCollection = genericReferenceExpression2.GenericArguments = TypeReferenceCollection.FromArray(new TypeReference[]
{
TypeReference.Lift(node2)
});
Expression expression2 = arg_255_0.Target = genericReferenceExpression2;
ExpressionCollection expressionCollection = methodInvocationExpression.Arguments = ExpressionCollection.FromArray(new Expression[]
{
Expression.Lift(target)
});
ReplaceCurrentNode(methodInvocationExpression);
}
}
}
}
}
}
}
}
}
}
示例12: OnReferenceExpression
/// <summary>
/// Called when we encounter a reference expression
/// </summary>
/// <param name="node">The node.</param>
public override void OnReferenceExpression(ReferenceExpression node)
{
if (this.ShouldTransformNodeName(node))
{
this.TransformNodeName(node);
}
base.OnReferenceExpression(node);
}
示例13: WithExpander
public WithExpander(ReferenceExpression instance)
{
this.instance = instance;
/*
foreach (var method in members.Where(m => m.EntityType == EntityType.Method))
{
keywords.Add(method.Name);
}*/
}
示例14: OnReferenceExpression
public override void OnReferenceExpression(ReferenceExpression node) {
if (node.Name[0] == '_')
{
var result = new MemberReferenceExpression(node.LexicalInfo);
result.Name = node.Name.Substring(1);
result.Target = instance.CloneNode();
ReplaceCurrentNode(result);
}
}
示例15: OnReferenceExpression
public override void OnReferenceExpression(ReferenceExpression node)
{
if (TypeInference.IsTypeLiteral(node))
{
TypeofExpression typeofExpression = new TypeofExpression(LexicalInfo.Empty);
TypeReference typeReference = typeofExpression.Type = TypeReference.Lift(node);
this.ReplaceCurrentNode(typeofExpression);
}
}