本文整理汇总了C#中Boo.Lang.Compiler.Ast.Method类的典型用法代码示例。如果您正苦于以下问题:C# Method类的具体用法?C# Method怎么用?C# Method使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Method类属于Boo.Lang.Compiler.Ast命名空间,在下文中一共展示了Method类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Run
public override void Run()
{
var klass = new ClassDefinition { Name = "Foo" };
var baseType = new SimpleTypeReference("object");
klass.BaseTypes.Add(baseType);
var method = new Method { Name = "Bar" };
method.Body.Add(
new ReturnStatement(
new IntegerLiteralExpression(42)));
klass.Members.Add(method);
var module = CompileUnit.Modules[0];
Assert.AreEqual(0, module.Members.Count);
My<CodeReifier>.Instance.ReifyInto(module, klass);
Assert.AreEqual(1, module.Members.Count);
Assert.AreSame(klass, module.Members[0]);
var klassEntity = (IType) klass.Entity;
Assert.IsTrue(klassEntity.IsClass);
Assert.AreSame(TypeSystemServices.ObjectType, klassEntity.BaseType);
var methodEntity = (IMethod)method.Entity;
Assert.AreEqual(method.Name, methodEntity.Name);
Assert.AreSame(TypeSystemServices.IntType, methodEntity.ReturnType);
}
示例2: LeaveMethod
public override void LeaveMethod(Method node)
{
if (node.Body.IsEmpty)
{
RemoveCurrentNode();
}
}
示例3: DoExpand
/// <summary>
/// Perform the actual expansion of the macro
/// </summary>
/// <param name="macro">The macro.</param>
/// <returns></returns>
protected override Statement DoExpand(MacroStatement macro)
{
if (macro.Arguments.Count != 0)
{
Errors.Add(CompilerErrorFactory.CustomError(macro.LexicalInfo,"No arguments allowed for action statement"));
return null;
}
Method mergeRowsMethod = new Method("MergeRows");
mergeRowsMethod.Modifiers = TypeMemberModifiers.Override;
mergeRowsMethod.Parameters.Add(new ParameterDeclaration("left", new SimpleTypeReference(typeof(Row).FullName)));
mergeRowsMethod.Parameters.Add(new ParameterDeclaration("right", new SimpleTypeReference(typeof(Row).FullName)));
CodeBuilder.DeclareLocal(mergeRowsMethod, "row", TypeSystemServices.Map(typeof(Row)));
mergeRowsMethod.Body.Add(
new BinaryExpression(BinaryOperatorType.Assign,
new ReferenceExpression("row"),
new MethodInvocationExpression(
AstUtil.CreateReferenceExpression(typeof(Row).FullName))
)
);
mergeRowsMethod.Body.Add(macro.Body);
mergeRowsMethod.Body.Add(new ReturnStatement(new ReferenceExpression("row")));
ParentMethods.Add(mergeRowsMethod);
return null;
}
示例4: OnMethod
public override void OnMethod(Method node)
{
if (LookingFor(node))
{
Found(node.ReturnType);
}
}
示例5: NormalizeGetter
public void NormalizeGetter(Method getter)
{
if ((getter != null) && (getter.get_Parameters().get_Count() != 0))
{
this.ReportError(UnityScriptCompilerErrors.InvalidPropertyGetter(getter.get_LexicalInfo()));
}
}
示例6: CheckSetterReturnType
public void CheckSetterReturnType(Method setter)
{
if (setter.get_ReturnType() != null)
{
this.ReportError(UnityScriptCompilerErrors.SetterCanNotDeclareReturnType(setter.get_ReturnType().get_LexicalInfo()));
}
}
示例7: 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;
}
示例8: OnMethod
public override void OnMethod(Method node)
{
var old = _currentMethod;
_currentMethod = (IMethod) node.Entity;
base.OnMethod(node);
_currentMethod = old;
}
示例9: VisitMethodDeclaration
public object VisitMethodDeclaration(MethodDeclaration methodDeclaration, object data)
{
B.Method m = new B.Method(GetLexicalInfo(methodDeclaration));
m.Name = methodDeclaration.Name;
m.Modifiers = ConvertModifier(methodDeclaration, B.TypeMemberModifiers.Private);
ConvertAttributes(methodDeclaration.Attributes, m.Attributes);
if (currentType != null) currentType.Members.Add(m);
if (methodDeclaration.HandlesClause.Count > 0) {
// TODO: Convert handles clauses to [Handles] attribute
AddError(methodDeclaration, "Handles-clause is not supported.");
}
m.ExplicitInfo = ConvertInterfaceImplementations(methodDeclaration.InterfaceImplementations, methodDeclaration, m);
if (methodDeclaration.Templates.Count > 0) {
AddError(methodDeclaration, "Declaring generic methods is not supported.");
}
ConvertParameters(methodDeclaration.Parameters, m.Parameters);
m.EndSourceLocation = GetEndLocation((INode)methodDeclaration.Body ?? methodDeclaration);
m.ReturnType = ConvertTypeReference(methodDeclaration.TypeReference);
m.Body = ConvertMethodBlock(methodDeclaration.Body);
if (m.Name == "Main" && m.IsStatic && m.Parameters.Count <= 1 &&
(methodDeclaration.TypeReference.Type == "System.Void" || methodDeclaration.TypeReference.Type == "System.Int32"))
{
entryPointMethod = m;
}
return m;
}
示例10: CheckEntryPoint
public void CheckEntryPoint(Method node)
{
if ((node.get_IsStatic() && node.get_IsPublic()) && ((node.get_Name() == "Main") && (this.GetType(node.get_ReturnType()) == this.get_TypeSystemServices().VoidType)))
{
ContextAnnotations.SetEntryPoint(base._context, node);
}
}
示例11: NormalizeSetter
public void NormalizeSetter(Method setter)
{
if (setter != null)
{
this.NormalizeSetterParameters(setter);
this.CheckSetterReturnType(setter);
}
}
示例12: ExpandGeneratorImpl
protected override IEnumerable<Node> ExpandGeneratorImpl(MacroStatement macro){
var method = new Method("_key"){
ReturnType = new SimpleTypeReference("string"),
Modifiers = TypeMemberModifiers.Public | TypeMemberModifiers.Override,
Body = macro.extractMethodBody()
};
yield return method;
}
示例13: LeaveMethod
public override void LeaveMethod(Method method)
{
InternalMethod entity = (InternalMethod)method.Entity;
if (!entity.IsGenerator) return;
GeneratorMethodProcessor processor = new GeneratorMethodProcessor(Context, entity);
processor.Run();
}
示例14: LeaveMethod
override public void LeaveMethod(Method node)
{
MakeStaticIfNeeded(node);
CantBeMarkedTransient(node);
CantBeMarkedPartial(node);
CheckExplicitImpl(node);
CheckModifierCombination(node);
}
示例15: BooMethodBuilder
public BooMethodBuilder(BooCodeBuilder codeBuilder, Method method)
{
if (null == codeBuilder)
throw new ArgumentNullException("codeBuilder");
if (null == method)
throw new ArgumentNullException("method");
_codeBuilder = codeBuilder;
_method = method;
}