static BuiltIns() { /* These aren't fully resolved; we need to use Cecil to load the appropriate .NET type defitinions in. * See ClrImporter.LoadBuiltins. */ Variant = new CClass("__Variant", null); Byte = new CClass("Byte", false); String = new CClass("String", true); Int32 = new CClass("Int32", true); Int64 = new CClass("Int64", true); Character = new CClass("Character", false); Boolean = new CClass("Boolean", true); Date = new CClass("Date", true); Double = new CClass("Double", true); Object = Variant; DbNull = new CClass("DbNull", false); Nothing = new CClass("Nothing", false); Nothing.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute"))); Void = new CClass("__Void", false); FunctionPlaceHolder = new CClass("__FunctionPlaceHolder", false); FunctionPlaceHolder.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute"))); SubPlaceHolder = new CClass("__SubPlaceHolder", false); SubPlaceHolder.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute"))); SetupGlobalTypes(); CArgumentList arrArgs = new CArgumentList(); arrArgs.Add(new CArgument(CToken.Keyword(null, "byval"), CToken.Identifer(null, "arglist"), new CTypeRef(null, Variant))); Array = new CFunction(CToken.Identifer(null, "Array"), "Array", "array", TokenTypes.visPublic, FunctionType.Function, arrArgs, new CTypeRef(null, new CArrayType(new CTypeRef(null, Variant), 1))); Array.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute"))); CArgumentList dicArgs = new CArgumentList(); dicArgs.Add(new CArgument(CToken.Keyword(null, "byval"), CToken.Identifer(null, "arglist"), new CTypeRef(null, Variant))); Dictionary = new CFunction(CToken.Identifer(null, "Dictionary"), "Dictionary", "dictionary", TokenTypes.visPublic, FunctionType.Function, dicArgs, new CTypeRef(null, new CDictionaryType(new CTypeRef(null, Variant)))); Dictionary.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute"))); CArgumentList refArgs = new CArgumentList(); refArgs.Add(new CArgument(CToken.Keyword(null, "byval"), CToken.Identifer(null, "func"), new CTypeRef(null, BuiltIns.String))); GetRef = new CFunction(CToken.Identifer(null, "GetRef"), "GetRef", "getref", TokenTypes.visPublic, FunctionType.Function, refArgs, new CTypeRef(null, BuiltIns.FunctionPlaceHolder)); GetRef.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute"))); // add string ienumerator interface CToken ifaceName = CToken.Identifer(null, "System.Collections.Generic.IEnumerable`1<char>"); CInterface iface = new CInterface(ifaceName, ifaceName); iface.GenericParameters.Add(Character); String.AddInterface(new CTypeRef(null, iface)); }
static BuiltIns() { /* These aren't fully resolved; we need to use Cecil to load the appropriate .NET type defitinions in. See ClrImporter.LoadBuiltins. */ Variant = new CClass("__Variant", null); Byte = new CClass("Byte", false); String = new CClass("String", true); Int32 = new CClass("Int32", true); Int64 = new CClass("Int64", true); Character = new CClass("Character", false); Boolean = new CClass("Boolean", true); Date = new CClass("Date", true); Double = new CClass("Double", true); Object = Variant; DbNull = new CClass("DbNull", false); Nothing = new CClass("Nothing", false); Nothing.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute"))); Void = new CClass("__Void", false); FunctionPlaceHolder = new CClass("__FunctionPlaceHolder", false); FunctionPlaceHolder.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute"))); SubPlaceHolder = new CClass("__SubPlaceHolder", false); SubPlaceHolder.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute"))); SetupGlobalTypes(); CArgumentList arrArgs = new CArgumentList(); arrArgs.Add(new CArgument(CToken.Keyword(null, "byval"), CToken.Identifer(null, "arglist"), new CTypeRef(null, Variant))); Array = new CFunction(CToken.Identifer(null, "Array"), "Array", "array", TokenTypes.visPublic, FunctionType.Function, arrArgs, new CTypeRef(null, new CArrayType(new CTypeRef(null, Variant), 1))); Array.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute"))); CArgumentList dicArgs = new CArgumentList(); dicArgs.Add(new CArgument(CToken.Keyword(null, "byval"), CToken.Identifer(null, "arglist"), new CTypeRef(null, Variant))); Dictionary = new CFunction(CToken.Identifer(null, "Dictionary"), "Dictionary", "dictionary", TokenTypes.visPublic, FunctionType.Function, dicArgs, new CTypeRef(null, new CDictionaryType(new CTypeRef(null, Variant)))); Dictionary.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute"))); CArgumentList refArgs = new CArgumentList(); refArgs.Add(new CArgument(CToken.Keyword(null, "byval"), CToken.Identifer(null, "func"), new CTypeRef(null, BuiltIns.String))); GetRef = new CFunction(CToken.Identifer(null, "GetRef"), "GetRef", "getref", TokenTypes.visPublic, FunctionType.Function, refArgs, new CTypeRef(null, BuiltIns.FunctionPlaceHolder)); GetRef.Attributes.Add(CToken.Identifer(null, "ExecuteAnywhere"), new CTypeRef(null, CToken.Identifer(null, "ExecuteAnywhereAttribute"))); // add string ienumerator interface CToken ifaceName = CToken.Identifer(null, "System.Collections.Generic.IEnumerable`1<char>"); CInterface iface = new CInterface(ifaceName, ifaceName); iface.GenericParameters.Add(Character); String.AddInterface(new CTypeRef(null, iface)); }
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; }