本文整理汇总了C#中Boo.Lang.Compiler.Ast.Field类的典型用法代码示例。如果您正苦于以下问题:C# Field类的具体用法?C# Field怎么用?C# Field使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Field类属于Boo.Lang.Compiler.Ast命名空间,在下文中一共展示了Field类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CreateViewStateSlice
Expression CreateViewStateSlice(Field f)
{
// ViewState["<f.Name>"]
return new SlicingExpression(
new ReferenceExpression("ViewState"),
new StringLiteralExpression(f.Name));
}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:7,代码来源:ViewStateAttribute.cs
示例2: LeaveField
public override void LeaveField(Field node)
{
if (!node.IsVisibilitySet)
{
node.Modifiers |= TypeMemberModifiers.Protected;
}
}
开发者ID:w4x,项目名称:boolangstudio,代码行数:7,代码来源:NormalizeTypeAndMemberDefinitions.cs
示例3: CreateGetter
Method CreateGetter(Field f)
{
Method m = new Method();
m.Name = "get";
// value = ViewState["<f.Name>"]
m.Body.Statements.Add(
new ExpressionStatement(
new BinaryExpression(
BinaryOperatorType.Assign,
new ReferenceExpression("value"),
CreateViewStateSlice(f)
)
)
);
if (null != _default)
{
// return <_default> unless value
ReturnStatement rs = new ReturnStatement(_default);
rs.Modifier = new StatementModifier(StatementModifierType.Unless, new ReferenceExpression("value"));
m.Body.Statements.Add(rs);
}
// return value
m.Body.Statements.Add(
new ReturnStatement(
new ReferenceExpression("value")
)
);
return m;
}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:33,代码来源:ViewStateAttribute.cs
示例4: OnField
public override void OnField(Field node)
{
if (this.LookingFor(node))
{
this.Found(node.Type);
}
}
开发者ID:paveltimofeev,项目名称:documentation,代码行数:7,代码来源:FieldTypeFinder.cs
示例5: OnField
public override void OnField(Field node)
{
if (node.Type != null) {
TypeReference initializerType = GetInferredType(node.Initializer);
if (node.Type.Matches(initializerType)) {
node.Type = null;
}
}
base.OnField(node);
}
开发者ID:kingjiang,项目名称:SharpDevelopLite,代码行数:10,代码来源:RemoveRedundantTypeReferencesVisitor.cs
示例6: OnField
override public void OnField(Field node)
{
if (null == node.Entity)
{
node.Entity = new InternalField(node);
if (!node.IsVisible && !node.IsSynthetic)
{
node.Annotate(PrivateMemberNeverUsed, null);
}
}
}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:11,代码来源:BindTypeMembers.cs
示例7: CreateSetter
Method CreateSetter(Field f)
{
Method m = new Method();
m.Name = "set";
m.Body.Statements.Add(
new ExpressionStatement(
new BinaryExpression(
BinaryOperatorType.Assign,
CreateViewStateSlice(f),
new ReferenceExpression("value")
)
)
);
return m;
}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:15,代码来源:ViewStateAttribute.cs
示例8: LeaveField
public override void LeaveField(Field node)
{
if (!node.IsVisibilitySet)
{
node.Visibility = Context.Parameters.DefaultFieldVisibility;
//protected field in a sealed type == private,
//so let the compiler mark them private automatically in order to get
//unused members warnings for free (and to make IL analysis tools happy as a bonus)
if (node.IsProtected && node.DeclaringType.IsFinal)
node.Visibility = TypeMemberModifiers.Private;
}
LeaveMember(node);
}
开发者ID:elfrostie,项目名称:boo,代码行数:15,代码来源:NormalizeTypeAndMemberDefinitions.cs
示例9: ExtendBaseClass
/// <summary>
/// Extends the base class by placing the blocks of macros into methods on the base class
/// of the same name.
/// </summary>
/// <example>
/// MyMethod:
/// PerformActions
///
/// If an overridable method called MyMethod exists on <see cref="BaseClassCompilerStep.BaseClass"/>, then
/// it is overridden as follows:
/// <code>
/// public override void MyMethod() { PerformActions(); }
/// </code>
/// </example>
protected override void ExtendBaseClass(Module module, ClassDefinition definition)
{
List<MethodInfo> methodsThatAreOverridable = new List<MethodInfo>();
MethodInfo[] baseClassMethods =
BaseClass.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public |
BindingFlags.InvokeMethod);
foreach (MethodInfo method in baseClassMethods)
{
if(method.DeclaringType==typeof(object))
continue;
if (method.IsVirtual || method.IsAbstract)
methodsThatAreOverridable.Add(method);
}
MethodSubstitutionTransformer mst = new MethodSubstitutionTransformer(methodsThatAreOverridable.ToArray(), definition);
mst.Visit(module);
foreach (Statement statement in module.Globals.Statements)
{
ExpressionStatement es = statement as ExpressionStatement;
if (es != null)
{
BinaryExpression be = es.Expression as BinaryExpression;
if (be != null)
{
if (be.Left.NodeType == NodeType.ReferenceExpression && be.Operator == BinaryOperatorType.Assign)
{
ReferenceExpression refExp = be.Left as ReferenceExpression;
Field field = new Field(refExp.LexicalInfo);
field.Name = refExp.Name;
field.Initializer = be.Right;
definition.Members.Add(field);
}
}
}
}
if (transformers != null)
{
foreach (DepthFirstTransformer transformer in transformers)
transformer.Visit(module);
}
}
开发者ID:JackWangCUMT,项目名称:rhino-dsl,代码行数:60,代码来源:MethodSubstitutionBaseClassCompilerStep.cs
示例10: ConvertField
void ConvertField(TypeReference typeRef, VariableDeclaration variable, FieldDeclaration fieldDeclaration)
{
B.TypeMember m;
if (currentType is B.EnumDefinition) {
if (variable.Initializer.IsNull) {
m = new B.EnumMember(GetLexicalInfo(fieldDeclaration));
} else {
PrimitiveExpression p = variable.Initializer as PrimitiveExpression;
if (p == null || !(p.Value is int)) {
AddError(fieldDeclaration, "enum member initializer must be integer value");
return;
}
m = new B.EnumMember(GetLexicalInfo(fieldDeclaration), new B.IntegerLiteralExpression((int)p.Value));
}
} else {
m = new B.Field(GetLexicalInfo(fieldDeclaration), ConvertTypeReference(typeRef), ConvertExpression(variable.Initializer));
m.Modifiers = ConvertModifier(fieldDeclaration, B.TypeMemberModifiers.Private);
}
m.Name = variable.Name;
ConvertAttributes(fieldDeclaration.Attributes, m.Attributes);
if (currentType != null) currentType.Members.Add(m);
}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:22,代码来源:ConvertVisitorTypeMembers.cs
示例11: ProcessLiteralField
void ProcessLiteralField(Field node)
{
Visit(node.Initializer);
ProcessFieldInitializerType(node, node.Initializer.ExpressionType);
((InternalField)node.Entity).StaticValue = node.Initializer;
node.Initializer = null;
}
开发者ID:stuman08,项目名称:boo,代码行数:7,代码来源:ProcessMethodBodies.cs
示例12: ProcessFieldInitializerType
void ProcessFieldInitializerType(Field node, IType initializerType)
{
if (null == node.Type)
node.Type = CreateTypeReference(node.LexicalInfo, MapNullToObject(initializerType));
else
AssertTypeCompatibility(node.Initializer, GetType(node.Type), initializerType);
}
开发者ID:stuman08,项目名称:boo,代码行数:7,代码来源:ProcessMethodBodies.cs
示例13: ProcessFieldInitializer
void ProcessFieldInitializer(Field node)
{
Expression initializer = node.Initializer;
if (null == initializer) return;
//do not unnecessarily assign fields to default values
switch (initializer.NodeType)
{
case NodeType.NullLiteralExpression:
node.Initializer = null;
return;
case NodeType.IntegerLiteralExpression:
if (0 == ((IntegerLiteralExpression) initializer).Value) {
node.Initializer = null;
return;
}
break;
case NodeType.BoolLiteralExpression:
if (false == ((BoolLiteralExpression) initializer).Value) {
node.Initializer = null;
return;
}
break;
case NodeType.DoubleLiteralExpression:
if (0.0f == ((DoubleLiteralExpression) initializer).Value) {
node.Initializer = null;
return;
}
break;
}
Method method = GetInitializerMethod(node);
method.Body.Add(
CodeBuilder.CreateAssignment(
initializer.LexicalInfo,
CodeBuilder.CreateReference(node),
initializer));
node.Initializer = null;
}
开发者ID:stuman08,项目名称:boo,代码行数:39,代码来源:ProcessMethodBodies.cs
示例14: PreProcessFieldInitializer
private void PreProcessFieldInitializer(Field node)
{
Expression initializer = node.Initializer;
if (node.IsFinal && node.IsStatic)
{
if (IsValidLiteralInitializer(initializer))
{
ProcessLiteralField(node);
return;
}
}
BlockExpression closure = node.Initializer as BlockExpression;
if (closure != null)
{
InferClosureSignature(closure);
}
Method method = GetInitializerMethod(node);
InternalMethod entity = (InternalMethod)method.Entity;
ReferenceExpression temp = new ReferenceExpression(TempInitializerName);
BinaryExpression assignment = new BinaryExpression(
node.LexicalInfo,
BinaryOperatorType.Assign,
temp,
initializer);
ProcessNodeInMethodContext(entity, entity, assignment);
method.Locals.RemoveByEntity(temp.Entity);
IType initializerType = GetExpressionType(assignment.Right);
ProcessFieldInitializerType(node, initializerType);
node.Initializer = assignment.Right;
}
开发者ID:stuman08,项目名称:boo,代码行数:36,代码来源:ProcessMethodBodies.cs
示例15: GetInitializerMethod
Method GetInitializerMethod(Field node)
{
return GetInitializerFor(node.DeclaringType, node.IsStatic);
}
开发者ID:stuman08,项目名称:boo,代码行数:4,代码来源:ProcessMethodBodies.cs
示例16: LeaveField
public override void LeaveField(Field node)
{
CheckName(node,node.Name);
}
开发者ID:w4x,项目名称:boolangstudio,代码行数:4,代码来源:CheckIdentifiers.cs
示例17: OnField
public override void OnField(Field node)
{
_emitter.EmitFieldAttributes(node);
}
开发者ID:Bombadil77,项目名称:boo,代码行数:4,代码来源:EmitAssembly.cs
示例18: field_or_property
protected void field_or_property(
TypeMemberCollection container
) //throws RecognitionException, TokenStreamException
{
IToken id1 = null;
IToken begin1 = null;
IToken s = null;
IToken lparen = null;
IToken id2 = null;
IToken begin2 = null;
IToken id = null;
TypeMember tm = null;
TypeReference tr = null;
Property p = null;
Field field = null;
ExplicitMemberInfo emi = null;
Expression initializer = null;
ParameterDeclarationCollection parameters = null;
Expression nameSplice = null;
try { // for error handling
{
bool synPredMatched156 = false;
if (((LA(1)==SELF||LA(1)==ID||LA(1)==SPLICE_BEGIN) && (tokenSet_34_.member(LA(2)))))
{
int _m156 = mark();
synPredMatched156 = true;
inputState.guessing++;
try {
{
property_header();
}
}
catch (RecognitionException)
{
synPredMatched156 = false;
}
rewind(_m156);
inputState.guessing--;
}
if ( synPredMatched156 )
{
{
{
if ((LA(1)==ID) && (LA(2)==DOT))
{
emi=explicit_member_info();
}
else if ((LA(1)==SELF||LA(1)==ID||LA(1)==SPLICE_BEGIN) && (tokenSet_34_.member(LA(2)))) {
}
else
{
throw new NoViableAltException(LT(1), getFilename());
}
}
{
switch ( LA(1) )
{
case ID:
{
id1 = LT(1);
match(ID);
if (0==inputState.guessing)
{
id=id1;
}
break;
}
case SPLICE_BEGIN:
{
begin1 = LT(1);
match(SPLICE_BEGIN);
nameSplice=atom();
if (0==inputState.guessing)
{
id=begin1;
}
break;
}
case SELF:
{
s = LT(1);
match(SELF);
if (0==inputState.guessing)
{
id=s;
}
break;
}
default:
{
throw new NoViableAltException(LT(1), getFilename());
}
}
}
{
//.........这里部分代码省略.........
开发者ID:hlizard,项目名称:boo,代码行数:101,代码来源:BooParserBase.cs
示例19: CreateReference
public MemberReferenceExpression CreateReference(LexicalInfo li, Field field)
{
MemberReferenceExpression e = CreateReference(field);
e.LexicalInfo = li;
return e;
}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:6,代码来源:BooCodeBuilder.cs
示例20: CreateField
public Field CreateField(string name, IType type)
{
Field field = new Field();
field.Modifiers = TypeMemberModifiers.Protected;
field.Name = name;
field.Type = CreateTypeReference(type);
field.Entity = new InternalField(field);
field.IsSynthetic = true;
return field;
}
开发者ID:0xb1dd1e,项目名称:boo,代码行数:10,代码来源:BooCodeBuilder.cs
注:本文中的Boo.Lang.Compiler.Ast.Field类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论