public BooMethodBuilder(BooCodeBuilder codeBuilder, string name, IType returnType) : this(codeBuilder, name, returnType, TypeMemberModifiers.Public) { }
public GeneratorExpressionTrees(string parameter, ReferenceExpression parameterRef, NameResolutionService nameResolutionService, BooCodeBuilder codeBuilder) { _parameter = parameter; _parameterRef = parameterRef; _nameResolutionService = nameResolutionService; _codeBuilder = codeBuilder; }
public TypeSystemServices(CompilerContext context) { if (null == context) { throw new ArgumentNullException("context"); } _context = context; CodeBuilder = new BooCodeBuilder(this); Cache(typeof(Builtins.duck), DuckType = new DuckTypeImpl(this)); Cache(IQuackFuType = new ExternalType(this, typeof(IQuackFu))); Cache(VoidType = new VoidTypeImpl(this)); Cache(ObjectType = new ExternalType(this, Types.Object)); Cache(RegexType = new ExternalType(this, Types.Regex)); Cache(ValueTypeType = new ExternalType(this, typeof(ValueType))); Cache(EnumType = new ExternalType(this, typeof(Enum))); Cache(ArrayType = new ExternalType(this, Types.Array)); Cache(TypeType = new ExternalType(this, Types.Type)); Cache(StringType = new ExternalType(this, Types.String)); Cache(BoolType = new ExternalType(this, Types.Bool)); Cache(SByteType = new ExternalType(this, Types.SByte)); Cache(CharType = new ExternalType(this, Types.Char)); Cache(ShortType = new ExternalType(this, Types.Short)); Cache(IntType = new ExternalType(this, Types.Int)); Cache(LongType = new ExternalType(this, Types.Long)); Cache(ByteType = new ExternalType(this, Types.Byte)); Cache(UShortType = new ExternalType(this, Types.UShort)); Cache(UIntType = new ExternalType(this, Types.UInt)); Cache(ULongType = new ExternalType(this, Types.ULong)); Cache(SingleType = new ExternalType(this, Types.Single)); Cache(DoubleType = new ExternalType(this, Types.Double)); Cache(DecimalType = new ExternalType(this, Types.Decimal)); Cache(TimeSpanType = new ExternalType(this, Types.TimeSpan)); Cache(DateTimeType = new ExternalType(this, Types.DateTime)); Cache(RuntimeServicesType = new ExternalType(this, Types.RuntimeServices)); Cache(BuiltinsType = new ExternalType(this, Types.Builtins)); Cache(ListType = new ExternalType(this, Types.List)); Cache(HashType = new ExternalType(this, Types.Hash)); Cache(ICallableType = new ExternalType(this, Types.ICallable)); Cache(IEnumerableType = new ExternalType(this, Types.IEnumerable)); Cache(IEnumeratorType = new ExternalType(this, typeof(IEnumerator))); Cache(ICollectionType = new ExternalType(this, Types.ICollection)); Cache(IListType = new ExternalType(this, Types.IList)); Cache(IDictionaryType = new ExternalType(this, Types.IDictionary)); Cache(ApplicationExceptionType = new ExternalType(this, Types.ApplicationException)); Cache(ExceptionType = new ExternalType(this, Types.Exception)); Cache(IntPtrType = new ExternalType(this, Types.IntPtr)); Cache(MulticastDelegateType = new ExternalType(this, Types.MulticastDelegate)); Cache(DelegateType = new ExternalType(this, Types.Delegate)); ObjectArrayType = GetArrayType(ObjectType, 1); PreparePrimitives(); PrepareBuiltinFunctions(); }
public BooMethodBuilder(BooCodeBuilder codeBuilder, Method method) { if (null == codeBuilder) { throw new ArgumentNullException("codeBuilder"); } if (null == method) { throw new ArgumentNullException("method"); } _codeBuilder = codeBuilder; _method = method; }
public static Expression CreateCallableFromMacroBody(BooCodeBuilder builder, MacroStatement macro) { // create closure for macro's body or null Expression macroBody = new NullLiteralExpression(); if (macro.Block.Statements.Count > 0) { var callableExpr = new BlockExpression {Body = macro.Block}; callableExpr.Parameters.Add( new ParameterDeclaration("OutputStream", builder.CreateTypeReference(typeof(TextWriter)))); macroBody = callableExpr; } return macroBody; }
public BooClassBuilder(BooCodeBuilder codeBuilder, string name) { if (null == codeBuilder) { throw new ArgumentNullException("codeBuilder"); } if (null == name) { throw new ArgumentNullException("name"); } _codeBuilder = codeBuilder; _cd = new ClassDefinition(); _cd.Name = name; _cd.Entity = new InternalClass(_codeBuilder.TypeSystemServices, _cd); }
public BooClassBuilder(BooCodeBuilder codeBuilder, string name) { if (null == codeBuilder) { throw new ArgumentNullException("codeBuilder"); } if (null == name) { throw new ArgumentNullException("name"); } _codeBuilder = codeBuilder; _cd = new ClassDefinition(); _cd.Name = name; _cd.Entity = new InternalClass(_codeBuilder.TypeSystemServices, _cd); _cd.IsSynthetic = true; }
public BooMethodBuilder(BooCodeBuilder codeBuilder, string name, IType returnType, TypeMemberModifiers modifiers) { if (null == codeBuilder) { throw new ArgumentNullException("codeBuilder"); } if (null == name) { throw new ArgumentNullException("name"); } _codeBuilder = codeBuilder; _method = _codeBuilder.CreateMethod(name, returnType, modifiers); }
public GenericTypeCollector(BooCodeBuilder codeBuilder) { _matches = new List <IGenericParameter>(); _codeBuilder = codeBuilder; }
public TypeSystemServices(CompilerContext context) { if (null == context) throw new ArgumentNullException("context"); _context = context; _anonymousCallablesManager = new AnonymousCallablesManager(this); _genericsServices = new GenericsServices(context); CodeBuilder = new BooCodeBuilder(this); Cache(typeof(Builtins.duck), DuckType = new DuckTypeImpl(this)); Cache(IQuackFuType = new ExternalType(this, typeof(IQuackFu))); Cache(VoidType = new VoidTypeImpl(this)); Cache(ObjectType = new ExternalType(this, Types.Object)); Cache(RegexType = new ExternalType(this, Types.Regex)); Cache(ValueTypeType = new ExternalType(this, typeof(ValueType))); Cache(EnumType = new ExternalType(this, typeof(Enum))); Cache(ArrayType = new ExternalType(this, Types.Array)); Cache(TypeType = new ExternalType(this, Types.Type)); Cache(StringType = new ExternalType(this, Types.String)); Cache(BoolType = new ExternalType(this, Types.Bool)); Cache(SByteType = new ExternalType(this, Types.SByte)); Cache(CharType = new ExternalType(this, Types.Char)); Cache(ShortType = new ExternalType(this, Types.Short)); Cache(IntType = new ExternalType(this, Types.Int)); Cache(LongType = new ExternalType(this, Types.Long)); Cache(ByteType = new ExternalType(this, Types.Byte)); Cache(UShortType = new ExternalType(this, Types.UShort)); Cache(UIntType = new ExternalType(this, Types.UInt)); Cache(ULongType = new ExternalType(this, Types.ULong)); Cache(SingleType = new ExternalType(this, Types.Single)); Cache(DoubleType = new ExternalType(this, Types.Double)); Cache(DecimalType = new ExternalType(this, Types.Decimal)); Cache(TimeSpanType = new ExternalType(this, Types.TimeSpan)); Cache(DateTimeType = new ExternalType(this, Types.DateTime)); Cache(RuntimeServicesType = new ExternalType(this, Types.RuntimeServices)); Cache(BuiltinsType = new ExternalType(this, Types.Builtins)); Cache(ListType = new ExternalType(this, Types.List)); Cache(HashType = new ExternalType(this, Types.Hash)); Cache(ICallableType = new ExternalType(this, Types.ICallable)); Cache(IEnumerableType = new ExternalType(this, Types.IEnumerable)); Cache(IEnumeratorType = new ExternalType(this, typeof(IEnumerator))); Cache(ICollectionType = new ExternalType(this, Types.ICollection)); Cache(IListType = new ExternalType(this, Types.IList)); Cache(IDictionaryType = new ExternalType(this, Types.IDictionary)); Cache(IntPtrType = new ExternalType(this, Types.IntPtr)); Cache(UIntPtrType = new ExternalType(this, Types.UIntPtr)); Cache(MulticastDelegateType = new ExternalType(this, Types.MulticastDelegate)); Cache(DelegateType = new ExternalType(this, Types.Delegate)); Cache(SystemAttribute = new ExternalType(this, typeof(System.Attribute))); Cache(ConditionalAttribute = new ExternalType(this, typeof(System.Diagnostics.ConditionalAttribute))); Cache(IEnumerableGenericType = new ExternalType(this, typeof(System.Collections.Generic.IEnumerable<>))); Cache(IEnumeratorGenericType = new ExternalType(this, typeof(System.Collections.Generic.IEnumerator<>))); ObjectArrayType = GetArrayType(ObjectType, 1); PreparePrimitives(); PrepareBuiltinFunctions(); }
public AnonymousCallablesManager(TypeSystemServices tss) { _tss = tss; _codeBuilder = new BooCodeBuilder(tss); }
public static void UnpackArray(BooCodeBuilder codeBuilder, Method method, Block block, Expression expression, DeclarationCollection declarations) { ILocalEntity local = expression.Entity as ILocalEntity; if (null == local) { local = codeBuilder.DeclareTempLocal(method, expression.ExpressionType); block.Add( codeBuilder.CreateAssignment( codeBuilder.CreateReference(local), expression)); } for (int i=0; i<declarations.Count; ++i) { Declaration declaration = declarations[i]; block.Add( codeBuilder.CreateAssignment( codeBuilder.CreateReference( declaration.Entity), codeBuilder.CreateSlicing( codeBuilder.CreateReference(local), i))); } }
public static void UnpackEnumerable(BooCodeBuilder codeBuilder, Method method, Block block, Expression expression, DeclarationCollection declarations) { TypeSystemServices tss = codeBuilder.TypeSystemServices; InternalLocal local = codeBuilder.DeclareTempLocal(method, tss.IEnumeratorType); IType expressionType = expression.ExpressionType; if (expressionType.IsSubclassOf(codeBuilder.TypeSystemServices.IEnumeratorType)) { block.Add( codeBuilder.CreateAssignment( codeBuilder.CreateReference(local), expression)); } else { if (!expressionType.IsSubclassOf(codeBuilder.TypeSystemServices.IEnumerableType)) { expression = codeBuilder.CreateMethodInvocation( RuntimeServices_GetEnumerable, expression); } block.Add( codeBuilder.CreateAssignment( block.LexicalInfo, codeBuilder.CreateReference(local), codeBuilder.CreateMethodInvocation( expression, IEnumerable_GetEnumerator))); } for (int i=0; i<declarations.Count; ++i) { Declaration declaration = declarations[i]; block.Add( codeBuilder.CreateAssignment( codeBuilder.CreateReference(declaration.Entity), codeBuilder.CreateMethodInvocation(RuntimeServices_MoveNext, codeBuilder.CreateReference(local)))); } }
public static void UnpackExpression(BooCodeBuilder codeBuilder, Method method, Block block, Expression expression, DeclarationCollection declarations) { if (expression.ExpressionType.IsArray) { UnpackArray(codeBuilder, method, block, expression, declarations); } else { UnpackEnumerable(codeBuilder, method, block, expression, declarations); } }