/// <summary>Creates a new instance of CFunction /// this one is for funcs and subs that are parts of classes. this means /// that they can be public or private. also, we track if they are subs or funcs as this has /// implications with how exit/return is used /// </summary> public CFunction(CToken token, string rawname, string name, TokenTypes visibility, FunctionType subFuncFlag, CArgumentList args, CTypeRef tref) : base(token) { funcName = name; rawFuncName = rawname; this.visibility = visibility; functionType = subFuncFlag; LoadType(tref); if (args != null) { arguments = args; } switch (functionType) { case vbPropertyGet: alias = "get_" + rawname; break; case vbPropertySet: alias = "set_" + rawname; break; case vbSub: case vbFunction: default: alias = rawname; break; } }
public CArgumentList GetRange(int index, int count) { CArgumentList newlist = new CArgumentList(); newlist.args = args.GetRange(index, count); return(newlist); }
public CLambdaFunction(CToken token, CFunction containingFunction, CFile containingFile, String name, CTypeRef tref, CArgumentList args) : base(token, name, name, TokenTypes.visInternal, FunctionType.Function, args, tref) { this.containingFunction = containingFunction; this.containingFile = containingFile; if (this.containingFunction != null) { this.containingFunction.Lambdas.Add(this); } else { this.containingFile.Lambdas.Add(this); } CallCount++; Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute"))); }
internal CStatementBlock StartInitialize(CFunction containingFunction, CFile containingFile, CTypeRef tref, CArgumentList args) { if (lambdaFunction != null) { throw new InvalidOperationException("Lambdas can only be initalized once"); } CClass @class = null; string extra = ""; if (containingFunction != null) { @class = containingFunction.Class; extra += containingFunction.RawName; } lambdaFunction = new CLambdaFunction(Token, containingFunction, containingFile, "Lambda_" + extra + "_" + lambdaId, tref, args); base.LoadType(lambdaType = new CFunctionType(Token, lambdaFunction, false)); lambdaFunction.Class = @class; return(lambdaFunction.Statements); }