AddInternalField() public method

public AddInternalField ( string name, IType type ) : Boo.Lang.Compiler.Ast.Field
name string
type IType
return Boo.Lang.Compiler.Ast.Field
Esempio n. 1
0
 Field DeclareFieldInitializedFromConstructorParameter(BooClassBuilder type,
     BooMethodBuilder constructor,
     string parameterName,
     IType parameterType)
 {
     Field field = type.AddInternalField("$" + parameterName + _context.AllocIndex(), parameterType);
     InitializeFieldFromConstructorParameter(constructor, field, parameterName, parameterType);
     return field;
 }
        public void DeclareFieldsAndConstructor(BooClassBuilder builder)
        {
            // referenced entities turn into fields
            foreach (ITypedEntity entity in Builtins.array(_referencedEntities.Keys))
            {
                Field field = builder.AddInternalField("__" + entity.Name + _context.AllocIndex(), entity.Type);
                _referencedEntities[entity] = field.Entity;
            }

            // single constructor taking all referenced entities
            BooMethodBuilder constructor = builder.AddConstructor();
            constructor.Modifiers = TypeMemberModifiers.Public;
            constructor.Body.Add(CodeBuilder.CreateSuperConstructorInvocation(builder.Entity.BaseType));
            foreach (ITypedEntity entity in _referencedEntities.Keys)
            {
                InternalField field = (InternalField)_referencedEntities[entity];
                ParameterDeclaration parameter = constructor.AddParameter(field.Name, entity.Type);
                constructor.Body.Add(
                    CodeBuilder.CreateAssignment(CodeBuilder.CreateReference(field),
                                    CodeBuilder.CreateReference(parameter)));
            }
        }