final ImmutableList<FieldName> ordered = t.getFieldsInDeclarationOrder(); for (int index = 0; index < ordered.size(); ++index) { final FieldName f = ordered.get(index);
@Override public Unit matchBooleanSet(final TBooleanSet t) { /* Construct a meta type field, and assign a value to it. */ final Class<JPRATypeModel.JPRABooleanSet> c = JPRATypeModel.JPRABooleanSet.class; final FieldName f_name = this.field.getName(); final String meta_field_name = JPRAGeneratedNames.getMetaTypeFieldName(f_name); this.class_builder.addField( c, meta_field_name, Modifier.FINAL, Modifier.PRIVATE); this.constructor_builder.addStatement( "this.$N = $T.of($L)", meta_field_name, c, t.getSizeInOctets().getValue()); return Unit.unit(); }
private TypeExprBooleanSet<IdentifierType, TType> checkTypeExprBooleanSet( final TypeExprBooleanSet<IdentifierType, Untyped> e) throws JPRACompilerCheckerException { final SizeExprType<IdentifierType, TType> size_expr = this.checkSizeExpr(e.getSizeExpression()); final Size<SizeUnitOctetsType> size_octets = this.evaluateSize(size_expr); if (!JPRAChecker.BOOLEAN_SET_SIZES.includesValue(size_octets.getValue())) { throw JPRACompilerCheckerException.booleanSetSizeInvalid( e, JPRAChecker.BOOLEAN_SET_SIZES, size_octets.getValue()); } final BigInteger required = BigInteger.valueOf((long) e.getFieldsInDeclarationOrder().size()); final Size<SizeUnitBitsType> bits = Size.toBits(size_octets); if (bits.getValue().compareTo(required) < 0) { throw JPRACompilerCheckerException.booleanSetSizeLessThanRequired( e, required, bits.getValue()); } final TBooleanSet type = new TBooleanSet( e.getLexicalInformation(), e.getFieldsInDeclarationOrder(), size_octets); return new TypeExprBooleanSet<>( type, e.getLexicalInformation(), e.getFieldsInDeclarationOrder(), size_expr); }
@Test public final void testRecordTypeExprBooleanSet_1() throws Exception { final JPRAParserType p = this.newParser(); final GlobalContextType c = GlobalContexts.newContext(new AlwaysEmptyLoader()); final JPRAResolverType r = this.newResolver(c); final JPRACheckerType ch = this.newChecker( c, JPRACheckerStandardCapabilities.newCapabilities()); final TypeExprType<IdentifierType, Untyped> te = r.resolveTypeExpression( p.parseTypeExpression( this.newStringSExpr("(boolean-set 8 [x y z])"))); final TypeExprBooleanSet<IdentifierType, TType> e = TypeExprBooleanSet.class.cast(ch.checkTypeExpression(te)); final TBooleanSet ta = TBooleanSet.class.cast(e.getType()); Assert.assertEquals(BigInteger.valueOf(64L), ta.getSizeInBits().getValue()); }
private TypeExprBooleanSet<IdentifierType, TType> checkTypeExprBooleanSet( final TypeExprBooleanSet<IdentifierType, Untyped> e) throws JPRACompilerCheckerException { final SizeExprType<IdentifierType, TType> size_expr = this.checkSizeExpr(e.getSizeExpression()); final Size<SizeUnitOctetsType> size_octets = JPRAChecker.evaluateSize( size_expr); if (!BOOLEAN_SET_SIZES.includesValue(size_octets.getValue())) { throw JPRACompilerCheckerException.booleanSetSizeInvalid( e, BOOLEAN_SET_SIZES, size_octets.getValue()); } final BigInteger required = BigInteger.valueOf((long) e.getFieldsInDeclarationOrder().size()); final Size<SizeUnitBitsType> bits = Size.toBits(size_octets); if (bits.getValue().compareTo(required) < 0) { throw JPRACompilerCheckerException.booleanSetSizeLessThanRequired( e, required, bits.getValue()); } final TBooleanSet type = new TBooleanSet( e.getLexicalInformation(), e.getFieldsInDeclarationOrder(), size_octets); return new TypeExprBooleanSet<>( type, e.getLexicalInformation(), e.getFieldsInDeclarationOrder(), size_expr); }
@Test public final void testRecordTypeExprBooleanSet_0() throws Exception { final JPRAParserType p = this.newParser(); final GlobalContextType c = GlobalContexts.newContext(new AlwaysEmptyLoader()); final JPRAResolverType r = this.newResolver(c); final JPRACheckerType ch = this.newChecker( c, JPRACheckerStandardCapabilities.newCapabilities()); final TypeExprType<IdentifierType, Untyped> te = r.resolveTypeExpression( p.parseTypeExpression( this.newStringSExpr("(boolean-set 1 [x y z])"))); final TypeExprBooleanSet<IdentifierType, TType> e = TypeExprBooleanSet.class.cast(ch.checkTypeExpression(te)); final TBooleanSet ta = TBooleanSet.class.cast(e.getType()); Assert.assertEquals(BigInteger.valueOf(8L), ta.getSizeInBits().getValue()); }
new FieldName(no_lex, "bool"), gc.getFreshIdentifier(), new TBooleanSet( no_lex, Lists.immutable.of( new FieldName(no_lex, "flag_a"),
@Override public Unit matchBooleanSet(final TBooleanSet t) final ImmutableList<FieldName> ordered = t.getFieldsInDeclarationOrder(); for (final FieldName f : ordered) { if (this.methods.wantGetters()) {