use of org.eclipse.titan.designer.AST.TTCN3.types.subtypes.SubType in project titan.EclipsePlug-ins by eclipse.
the class Anytype_Type method generateCode.
@Override
public /**
* {@inheritDoc}
*/
void generateCode(final JavaGenData aData, final StringBuilder source) {
final String genName = getGenNameOwn();
final String displayName = getFullName();
generateCodeTypedescriptor(aData, source);
final List<FieldInfo> fieldInfos = new ArrayList<FieldInfo>();
boolean hasOptional = false;
for (final CompField compField : compFieldMap.fields) {
final IType cfType = compField.getType();
final FieldInfo fi = new FieldInfo(cfType.getGenNameValue(aData, source, getMyScope()), cfType.getGenNameTemplate(aData, source, getMyScope()), compField.getIdentifier().getName(), compField.getIdentifier().getDisplayName(), cfType.getGenNameTypeDescriptor(aData, source, myScope));
hasOptional |= compField.isOptional();
fieldInfos.add(fi);
}
for (final CompField compField : compFieldMap.fields) {
final StringBuilder tempSource = aData.getCodeForType(compField.getType().getGenNameOwn());
compField.getType().generateCode(aData, tempSource);
}
// FIXME can have raw attributes
UnionGenerator.generateValueClass(aData, source, genName, displayName, fieldInfos, hasOptional, getGenerateCoderFunctions(MessageEncoding_type.RAW), null);
UnionGenerator.generateTemplateClass(aData, source, genName, displayName, fieldInfos, hasOptional);
if (hasDoneAttribute()) {
generateCodeDone(aData, source);
}
if (subType != null) {
subType.generateCode(aData, source);
}
generateCodeForCodingHandlers(aData, source);
}
use of org.eclipse.titan.designer.AST.TTCN3.types.subtypes.SubType in project titan.EclipsePlug-ins by eclipse.
the class BitString_Type method checkCodingAttributes.
@Override
public /**
* {@inheritDoc}
*/
void checkCodingAttributes(final CompilationTimeStamp timestamp, final IReferenceChain refChain) {
// check raw attributes
if (subType != null) {
final int restrictionLength = subType.get_length_restriction();
if (restrictionLength != -1) {
if (rawAttribute == null) {
rawAttribute = new RawAST(getDefaultRawFieldLength());
}
if (rawAttribute.fieldlength == 0) {
rawAttribute.fieldlength = restrictionLength;
rawAttribute.length_restriction = -1;
} else {
rawAttribute.length_restriction = restrictionLength;
}
}
}
// TODO add checks for other encodings.
}
use of org.eclipse.titan.designer.AST.TTCN3.types.subtypes.SubType in project titan.EclipsePlug-ins by eclipse.
the class Signature_Type method generateCode.
@Override
public /**
* {@inheritDoc}
*/
void generateCode(final JavaGenData aData, final StringBuilder source) {
final String genName = getGenNameOwn();
final ArrayList<SignatureParameter> parameters = new ArrayList<SignatureParameter>();
for (int i = 0; i < formalParList.getNofParameters(); i++) {
final SignatureFormalParameter formalPar = formalParList.getParameterByIndex(i);
final Type type = formalPar.getType();
SignatureGenerator.signatureParamaterDirection direction;
switch(formalPar.getDirection()) {
case PARAM_OUT:
direction = signatureParamaterDirection.PAR_OUT;
break;
case PARAM_INOUT:
direction = signatureParamaterDirection.PAR_INOUT;
break;
default:
direction = signatureParamaterDirection.PAR_IN;
break;
}
final SignatureParameter temp = new SignatureParameter(direction, type.getGenNameValue(aData, source, myScope), type.getGenNameTemplate(aData, source, myScope), formalPar.getIdentifier().getName());
parameters.add(temp);
}
SignatureReturnType signatueReturnType = null;
if (returnType != null) {
signatueReturnType = new SignatureReturnType(returnType.getGenNameValue(aData, source, myScope), returnType.getGenNameTemplate(aData, source, myScope));
}
final ArrayList<SignatureException> signatureExceptions = new ArrayList<SignatureGenerator.SignatureException>();
if (exceptions != null) {
for (int i = 0; i < exceptions.getNofExceptions(); i++) {
final Type exceptionType = exceptions.getExceptionByIndex(i);
final IType last = exceptionType.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
final SignatureException temp = new SignatureException(last.getGenNameValue(aData, source, myScope), last.getGenNameTemplate(aData, source, myScope), last.getFullName());
signatureExceptions.add(temp);
}
}
final SignatureDefinition def = new SignatureDefinition(genName, getFullName(), parameters, signatueReturnType, noBlock, signatureExceptions);
SignatureGenerator.generateClasses(aData, source, def);
if (hasDoneAttribute()) {
generateCodeDone(aData, source);
}
if (subType != null) {
subType.generateCode(aData, source);
}
generateCodeForCodingHandlers(aData, source);
}
use of org.eclipse.titan.designer.AST.TTCN3.types.subtypes.SubType in project titan.EclipsePlug-ins by eclipse.
the class TTCN3_Choice_Type method checkThisValue.
@Override
public /**
* {@inheritDoc}
*/
boolean checkThisValue(final CompilationTimeStamp timestamp, final IValue value, final Assignment lhs, final ValueCheckingOptions valueCheckingOptions) {
if (getIsErroneous(timestamp)) {
return false;
}
boolean selfReference = super.checkThisValue(timestamp, value, lhs, valueCheckingOptions);
IValue last = value.getValueRefdLast(timestamp, valueCheckingOptions.expected_value, null);
if (last == null || last.getIsErroneous(timestamp)) {
return selfReference;
}
// already handled ones
switch(value.getValuetype()) {
case OMIT_VALUE:
case REFERENCED_VALUE:
return selfReference;
case UNDEFINED_LOWERIDENTIFIER_VALUE:
if (Value_type.REFERENCED_VALUE.equals(last.getValuetype())) {
return selfReference;
}
break;
default:
break;
}
switch(last.getValuetype()) {
case SEQUENCE_VALUE:
if (value.isAsn()) {
value.getLocation().reportSemanticError(MessageFormat.format(CHOICEEXPECTED, getFullName()));
value.setIsErroneous(true);
} else {
last = last.setValuetype(timestamp, Value_type.CHOICE_VALUE);
if (!last.getIsErroneous(timestamp)) {
selfReference = checkThisValueChoice(timestamp, (Choice_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.str_elem);
}
}
break;
case CHOICE_VALUE:
selfReference = checkThisValueChoice(timestamp, (Choice_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.str_elem);
break;
case EXPRESSION_VALUE:
case MACRO_VALUE:
// already checked
break;
default:
if (value.isAsn()) {
value.getLocation().reportSemanticError(MessageFormat.format(CHOICEEXPECTED, getFullName()));
} else {
value.getLocation().reportSemanticError(MessageFormat.format(UNIONEXPECTED, getFullName()));
}
value.setIsErroneous(true);
}
if (valueCheckingOptions.sub_check) {
// there is no parent type to check
if (subType != null) {
subType.checkThisValue(timestamp, last);
}
}
value.setLastTimeChecked(timestamp);
return selfReference;
}
use of org.eclipse.titan.designer.AST.TTCN3.types.subtypes.SubType in project titan.EclipsePlug-ins by eclipse.
the class TTCN3_Sequence_Type method checkThisValue.
@Override
public /**
* {@inheritDoc}
*/
boolean checkThisValue(final CompilationTimeStamp timestamp, final IValue value, final Assignment lhs, final ValueCheckingOptions valueCheckingOptions) {
if (getIsErroneous(timestamp)) {
return false;
}
boolean selfReference = super.checkThisValue(timestamp, value, lhs, valueCheckingOptions);
IValue last = value.getValueRefdLast(timestamp, valueCheckingOptions.expected_value, null);
if (last == null || last.getIsErroneous(timestamp)) {
return selfReference;
}
// already handled ones
switch(value.getValuetype()) {
case OMIT_VALUE:
case REFERENCED_VALUE:
return selfReference;
case UNDEFINED_LOWERIDENTIFIER_VALUE:
if (Value_type.REFERENCED_VALUE.equals(last.getValuetype())) {
return selfReference;
}
break;
default:
break;
}
switch(last.getValuetype()) {
case SEQUENCE_VALUE:
if (last.isAsn()) {
selfReference = checkThisValueSeq(timestamp, (Sequence_Value) last, lhs, valueCheckingOptions.expected_value, false, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
} else {
selfReference = checkThisValueSeq(timestamp, (Sequence_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
}
break;
case SEQUENCEOF_VALUE:
if (((SequenceOf_Value) last).isIndexed()) {
value.getLocation().reportSemanticError(MessageFormat.format("Indexed assignment notation cannot be used for record type `{0}''", getFullName()));
value.setIsErroneous(true);
} else {
last = last.setValuetype(timestamp, Value_type.SEQUENCE_VALUE);
if (last.isAsn()) {
selfReference = checkThisValueSeq(timestamp, (Sequence_Value) last, lhs, valueCheckingOptions.expected_value, false, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
} else {
selfReference = checkThisValueSeq(timestamp, (Sequence_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
}
}
break;
case UNDEFINED_BLOCK:
last = last.setValuetype(timestamp, Value_type.SEQUENCE_VALUE);
selfReference = checkThisValueSeq(timestamp, (Sequence_Value) last, lhs, valueCheckingOptions.expected_value, false, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
break;
case EXPRESSION_VALUE:
case MACRO_VALUE:
// already checked
break;
default:
value.getLocation().reportSemanticError(MessageFormat.format(SEQUANCEEPECTED, getFullName()));
value.setIsErroneous(true);
}
if (valueCheckingOptions.sub_check) {
// there is no parent type to check
if (subType != null) {
subType.checkThisValue(timestamp, last);
}
}
value.setLastTimeChecked(timestamp);
return selfReference;
}
Aggregations