use of org.eclipse.titan.designer.AST.Assignment in project titan.EclipsePlug-ins by eclipse.
the class Embedded_PDV_Type method getTypeRefd.
@Override
public /**
* {@inheritDoc}
*/
IType getTypeRefd(final CompilationTimeStamp timestamp, final IReferenceChain refChain) {
if (null == myScope) {
setIsErroneous(true);
return this;
}
final Identifier identifier = new Identifier(Identifier_type.ID_ASN, EMBEDDED_PDV);
final Assignments assignments = myScope.getAssignmentsScope();
if (!assignments.hasAssignmentWithId(timestamp, identifier)) {
setIsErroneous(true);
return this;
}
final Assignment assignment = assignments.getLocalAssignmentByID(timestamp, identifier);
if (null == assignment || null == assignment.getType(timestamp)) {
setIsErroneous(true);
return this;
}
return assignment.getType(timestamp);
}
use of org.eclipse.titan.designer.AST.Assignment in project titan.EclipsePlug-ins by eclipse.
the class External_Type method getTypeRefd.
@Override
public /**
* {@inheritDoc}
*/
IType getTypeRefd(final CompilationTimeStamp timestamp, final IReferenceChain refChain) {
if (null == myScope) {
setIsErroneous(true);
return this;
}
final Identifier identifier = new Identifier(Identifier_type.ID_ASN, "EXTERNAL");
final Assignments assignments = myScope.getAssignmentsScope();
if (!assignments.hasAssignmentWithId(timestamp, identifier)) {
setIsErroneous(true);
return this;
}
final Assignment assignment = assignments.getLocalAssignmentByID(timestamp, identifier);
if (null == assignment || null == assignment.getType(timestamp)) {
setIsErroneous(true);
return this;
}
return assignment.getType(timestamp);
}
use of org.eclipse.titan.designer.AST.Assignment in project titan.EclipsePlug-ins by eclipse.
the class Referenced_Value method getExpressionGovernor.
@Override
public /**
* {@inheritDoc}
*/
IType getExpressionGovernor(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue) {
if (myGovernor != null) {
return myGovernor;
}
reference.setIsErroneous(false);
final Assignment ass = reference.getRefdAssignment(timestamp, true);
if (ass == null) {
setIsErroneous(true);
return null;
}
IType temporalType = null;
switch(ass.getAssignmentType()) {
case A_CONST:
case A_EXT_CONST:
case A_MODULEPAR:
case A_MODULEPAR_TEMPLATE:
case A_TEMPLATE:
case A_TIMER:
case A_VAR:
case A_VAR_TEMPLATE:
case A_FUNCTION_RVAL:
case A_FUNCTION_RTEMP:
case A_EXT_FUNCTION_RVAL:
case A_EXT_FUNCTION_RTEMP:
case A_PAR_VAL:
case A_PAR_VAL_IN:
case A_PAR_VAL_OUT:
case A_PAR_VAL_INOUT:
case A_PAR_TEMP_IN:
case A_PAR_TEMP_OUT:
case A_PAR_TEMP_INOUT:
temporalType = ass.getType(timestamp);
break;
case A_FUNCTION:
case A_EXT_FUNCTION:
if (Expected_Value_type.EXPECTED_TEMPLATE.equals(expectedValue)) {
getLocation().reportSemanticError(MessageFormat.format(UNEXPECTEDCALL1, ass.getDescription()));
} else {
getLocation().reportSemanticError(MessageFormat.format(UNEXPECTEDCALL2, ass.getDescription()));
}
setIsErroneous(true);
return null;
default:
if (Expected_Value_type.EXPECTED_TEMPLATE.equals(expectedValue)) {
getLocation().reportSemanticError(MessageFormat.format(UNEXPECTEDASSIGNMENT1, ass.getDescription()));
} else {
getLocation().reportSemanticError(MessageFormat.format(UNEXPECTEDASSIGNMENT2, ass.getDescription()));
}
setIsErroneous(true);
return null;
}
if (temporalType == null) {
setIsErroneous(true);
return null;
}
temporalType = temporalType.getFieldType(timestamp, reference, 1, expectedValue, false);
if (temporalType == null || reference.getIsErroneous(timestamp)) {
setIsErroneous(true);
return null;
}
return temporalType;
}
use of org.eclipse.titan.designer.AST.Assignment in project titan.EclipsePlug-ins by eclipse.
the class Referenced_Value method isUnfoldable.
@Override
public /**
* {@inheritDoc}
*/
boolean isUnfoldable(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
final Assignment ass = reference.getRefdAssignment(timestamp, false);
if (ass == null) {
return true;
}
switch(ass.getAssignmentType()) {
case A_OBJECT:
case A_OS:
case A_CONST:
case A_EXT_CONST:
case A_MODULEPAR:
case A_VAR:
case A_FUNCTION_RVAL:
case A_EXT_FUNCTION_RVAL:
case A_PAR_VAL:
case A_PAR_VAL_IN:
case A_PAR_VAL_OUT:
case A_PAR_VAL_INOUT:
break;
default:
return true;
}
final IValue last = getValueRefdLast(timestamp, expectedValue, referenceChain);
if (last == this || last == null) {
return true;
}
return last.isUnfoldable(timestamp, expectedValue, referenceChain);
}
use of org.eclipse.titan.designer.AST.Assignment in project titan.EclipsePlug-ins by eclipse.
the class ComponentCreateExpression method generateCodeExpressionExpression.
@Override
public /**
* {@inheritDoc}
*/
void generateCodeExpressionExpression(final JavaGenData aData, final ExpressionStruct expression) {
aData.addCommonLibraryImport("TTCN_Runtime");
expression.expression.append("TTCN_Runtime.create_component(");
// the type of the component (module name and identifier)
final Assignment assignment = componentReference.getRefdAssignment(CompilationTimeStamp.getBaseTimestamp(), false);
if (assignment == null || !Assignment_type.A_TYPE.equals(assignment.getAssignmentType())) {
ErrorReporter.INTERNAL_ERROR("FATAL ERROR while generating code for expression `" + getFullName() + "''");
return;
}
IType componentType = assignment.getType(CompilationTimeStamp.getBaseTimestamp()).getFieldType(CompilationTimeStamp.getBaseTimestamp(), componentReference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
if (componentType == null) {
ErrorReporter.INTERNAL_ERROR("FATAL ERROR while generating code for expression `" + getFullName() + "''");
return;
}
componentType = componentType.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
if (!Type_type.TYPE_COMPONENT.equals(componentType.getTypetype())) {
ErrorReporter.INTERNAL_ERROR("FATAL ERROR while generating code for expression `" + getFullName() + "''");
return;
}
((Component_Type) componentType).getComponentBody().generateCodeComponentTypeName(expression);
expression.expression.append(", ");
// third argument: component name
if (name != null) {
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last = name.getValueRefdLast(CompilationTimeStamp.getBaseTimestamp(), referenceChain);
referenceChain.release();
if (Value_type.CHARSTRING_VALUE.equals(last.getValuetype())) {
// TODO check why translate
expression.expression.append(MessageFormat.format("\"{0}\"", ((Charstring_Value) last).getValue()));
} else {
name.generateCodeExpressionMandatory(aData, expression, false);
}
} else {
expression.expression.append("null");
}
expression.expression.append(", ");
// fourth argument location
if (location != null) {
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last = location.getValueRefdLast(CompilationTimeStamp.getBaseTimestamp(), referenceChain);
referenceChain.release();
if (Value_type.CHARSTRING_VALUE.equals(last.getValuetype())) {
// TODO check why translate
expression.expression.append(MessageFormat.format("\"{0}\"", ((Charstring_Value) last).getValue()));
} else {
location.generateCodeExpressionMandatory(aData, expression, false);
}
} else {
expression.expression.append("null");
}
// fifth argument: alive flag
expression.expression.append(MessageFormat.format(", {0})", isAlive ? "true" : "false"));
}
Aggregations