private RecordFieldDeclType<IdentifierType, TType> checkTypeDeclRecordFieldPaddingOctets( final RecordFieldDeclPaddingOctets<IdentifierType, Untyped> r, final MutableList<RecordFieldDeclType<IdentifierType, TType>> fields_ordered, final TRecordBuilderType b) throws JPRACompilerCheckerException { final RecordFieldDeclPaddingOctets<IdentifierType, TType> rv = this.checkRecordFieldPaddingOctets(r); final Size<SizeUnitOctetsType> size = JPRAChecker.evaluateSize(rv.getSizeExpression()); if (size.getValue().compareTo(BigInteger.ZERO) <= 0) { throw JPRACompilerCheckerException.paddingSizeInvalid( r.getLexicalInformation(), size.getValue()); } fields_ordered.add(rv); b.addPaddingOctets(r.getLexicalInformation(), size); return rv; }
private RecordFieldDeclType<IdentifierType, TType> checkTypeDeclRecordFieldPaddingOctets( final RecordFieldDeclPaddingOctets<IdentifierType, Untyped> r, final MutableList<RecordFieldDeclType<IdentifierType, TType>> fields_ordered, final TRecordBuilderType b) throws JPRACompilerCheckerException { final RecordFieldDeclPaddingOctets<IdentifierType, TType> rv = this.checkRecordFieldPaddingOctets(r); final Size<SizeUnitOctetsType> size = this.evaluateSize(rv.getSizeExpression()); if (size.getValue().compareTo(BigInteger.ZERO) <= 0) { throw JPRACompilerCheckerException.paddingSizeInvalid( r.getLexicalInformation(), size.getValue()); } fields_ordered.add(rv); b.addPaddingOctets(r.getLexicalInformation(), size); return rv; }
@Test public final void testRecordPaddingExhaustive() throws Exception { final JPRAJavaGeneratorType g = this.getJavaGenerator(); final GlobalContextType gc = GlobalContexts.newContext(new AlwaysEmptyLoader()); final PackageContextType pc = gc.loadPackage( new PackageNameQualified( Lists.immutable.of( PackageNameUnqualified.of("x"), PackageNameUnqualified.of("y"), PackageNameUnqualified.of("z")))); final IdentifierType id = gc.getFreshIdentifier(); final Optional<ImmutableLexicalPositionType<Path>> no_lex = Optional.empty(); final TypeName t_name = new TypeName(no_lex, "RecordPadding"); final TRecordBuilderType rb = TRecord.newBuilder(pc, id, t_name); rb.addPaddingOctets(no_lex, Size.valueOf(100L)); final TRecord r = rb.build(); JPRAJavaGeneratorContract.compileRecords( JPRAJavaGeneratorContract.createTemporaryDir(), g, Lists.immutable.of(r)); }