Skip to content

Commit

Permalink
Merge branch 'release'
Browse files Browse the repository at this point in the history
  • Loading branch information
ldcouto committed Feb 26, 2015
2 parents bc1008c + 3e2d2a8 commit fcd85f1
Show file tree
Hide file tree
Showing 265 changed files with 3,934 additions and 1,261 deletions.
2 changes: 1 addition & 1 deletion core/ast/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.overturetool</groupId>
<artifactId>core</artifactId>
<version>2.2.0</version>
<version>2.2.2</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,11 @@ public static APerSyncDefinition newAPerSyncDefinition(

result.setOpname(opname);
result.setGuard(guard);

if(guard != null)
{
guard.parent(result);
}

return result;
}
Expand Down
3 changes: 3 additions & 0 deletions core/ast/src/main/resources/overtureII.astv2.tostring
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ import org.overture.ast.util.ToStringUtil;
%definition->value = [pattern] +$($[type]$ == null ? "" : ":" + $[type]$) + " = " +$ [expression]


%modules->module= "module " [name]$.getName()+ "\n definitions\n" + ToStringUtil.getDefinitionListString($[defs]$)$ +
"end " [name]$.getName()$ + "\n"
//return (_name!=null?_name.toString():this.getClass().getSimpleName())+ (_imports!=null?_imports.toString():this.getClass().getSimpleName())+ (_exports!=null?_exports.toString():this.getClass().getSimpleName())+ (_defs!=null?_defs.toString():this.getClass().getSimpleName())+ (_files!=null?_files.toString():this.getClass().getSimpleName())+ (_importdefs!=null?_importdefs.toString():this.getClass().getSimpleName())+ (_exportdefs!=null?_exportdefs.toString():this.getClass().getSimpleName())+ (_isFlat!=null?_isFlat.toString():this.getClass().getSimpleName())+ (_typeChecked!=null?_typeChecked.toString():this.getClass().getSimpleName())+ (_isDLModule!=null?_isDLModule.toString():this.getClass().getSimpleName());

//%definition->value = [pattern] " : " [expType] " = " [expression]

Expand Down
36 changes: 26 additions & 10 deletions core/codegen-runtime/pom.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.overturetool</groupId>
<artifactId>core</artifactId>
<version>2.2.0<!--Replaceable: Main Version--></version>
<relativePath>../pom.xml</relativePath>
</parent>
<parent>
<groupId>org.overturetool</groupId>
<artifactId>core</artifactId>
<version>2.2.2<!--Replaceable: Main Version--></version>
<relativePath>../pom.xml</relativePath>
</parent>

<groupId>org.overturetool.core</groupId>
<artifactId>codegen-runtime</artifactId>
<name>VDM Code Generator Runtime</name>
<groupId>org.overturetool.core</groupId>
<artifactId>codegen-runtime</artifactId>
<name>VDM Code Generator Runtime</name>

<build>
<plugins>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
2 changes: 1 addition & 1 deletion core/codegen/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.overturetool</groupId>
<artifactId>core</artifactId>
<version>2.2.0<!--Replaceable: Main Version--></version>
<version>2.2.2<!--Replaceable: Main Version--></version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,25 @@
import org.overture.ast.analysis.AnalysisException;
import org.overture.ast.definitions.AClassClassDefinition;
import org.overture.ast.definitions.AEqualsDefinition;
import org.overture.ast.definitions.AExplicitFunctionDefinition;
import org.overture.ast.definitions.AValueDefinition;
import org.overture.ast.definitions.PDefinition;
import org.overture.ast.definitions.SClassDefinition;
import org.overture.ast.definitions.SFunctionDefinition;
import org.overture.ast.definitions.SOperationDefinition;
import org.overture.ast.intf.lex.ILexNameToken;
import org.overture.ast.node.INode;
import org.overture.ast.patterns.APatternListTypePair;
import org.overture.ast.patterns.PPattern;
import org.overture.ast.statements.ASubclassResponsibilityStm;
import org.overture.codegen.cgast.SDeclCG;
import org.overture.codegen.cgast.SExpCG;
import org.overture.codegen.cgast.SPatternCG;
import org.overture.codegen.cgast.SStmCG;
import org.overture.codegen.cgast.STypeCG;
import org.overture.codegen.cgast.declarations.AClassDeclCG;
import org.overture.codegen.cgast.declarations.AFieldDeclCG;
import org.overture.codegen.cgast.declarations.AFormalParamLocalParamCG;
import org.overture.codegen.cgast.declarations.AMethodDeclCG;
import org.overture.codegen.cgast.declarations.ARecordDeclCG;
import org.overture.codegen.cgast.declarations.ATypeDeclCG;
Expand All @@ -51,6 +57,7 @@
import org.overture.codegen.cgast.types.ABoolBasicTypeCG;
import org.overture.codegen.cgast.types.ACharBasicTypeCG;
import org.overture.codegen.cgast.types.AIntNumericBasicTypeCG;
import org.overture.codegen.cgast.types.AMethodTypeCG;
import org.overture.codegen.cgast.types.ANat1NumericBasicTypeCG;
import org.overture.codegen.cgast.types.ANatNumericBasicTypeCG;
import org.overture.codegen.cgast.types.ARealNumericBasicTypeCG;
Expand Down Expand Up @@ -411,6 +418,19 @@ public AFieldDeclCG getFieldDecl(List<AClassDeclCG> classes,

return record.getFields().get(number);
}

public AFieldDeclCG getFieldDecl(AClassDeclCG clazz, String fieldName)
{
for(AFieldDeclCG field : clazz.getFields())
{
if(field.getName().equals(fieldName))
{
return field;
}
}

return null;
}

public AFieldDeclCG getFieldDecl(List<AClassDeclCG> classes,
ARecordTypeCG recordType, String memberName)
Expand Down Expand Up @@ -486,4 +506,74 @@ public AFieldDeclCG getFieldDecl(List<AClassDeclCG> classes,

return field;
}

public AMethodDeclCG initMethod(SOperationDefinition node, IRInfo question) throws AnalysisException
{
String access = node.getAccess().getAccess().toString();
boolean isStatic = question.getTcFactory().createPDefinitionAssistant().isStatic(node);
boolean isAsync = question.getTcFactory().createPAccessSpecifierAssistant().isAsync(node.getAccess());
String operationName = node.getName().getName();
STypeCG type = node.getType().apply(question.getTypeVisitor(), question);

if (!(type instanceof AMethodTypeCG))
{
return null;
}

AMethodTypeCG methodType = (AMethodTypeCG) type;

SStmCG bodyCg = null;
if (node.getBody() != null)
{
bodyCg = node.getBody().apply(question.getStmVisitor(), question);
}

boolean isConstructor = node.getIsConstructor();
boolean isAbstract = node.getBody() instanceof ASubclassResponsibilityStm;

AMethodDeclCG method = new AMethodDeclCG();

method.setAccess(access);
method.setStatic(isStatic);
method.setAsync(isAsync);
method.setMethodType(methodType);
method.setName(operationName);
method.setBody(bodyCg);
method.setIsConstructor(isConstructor);
method.setAbstract(isAbstract);

AExplicitFunctionDefinition preCond = node.getPredef();
SDeclCG preCondCg = preCond != null ? preCond.apply(question.getDeclVisitor(), question) : null;
method.setPreCond(preCondCg);

AExplicitFunctionDefinition postCond = node.getPostdef();
SDeclCG postCondCg = postCond != null ? postCond.apply(question.getDeclVisitor(), question) : null;
method.setPostCond(postCondCg);

return method;
}


public List<AFormalParamLocalParamCG> consFormalParams(
List<APatternListTypePair> params, IRInfo question)
throws AnalysisException
{
List<AFormalParamLocalParamCG> paramsCg = new LinkedList<>();
for(APatternListTypePair patternListPair : params)
{
STypeCG pairTypeCg = patternListPair.getType().apply(question.getTypeVisitor(), question);

for(PPattern p : patternListPair.getPatterns())
{
SPatternCG patternCg = p.apply(question.getPatternVisitor(), question);

AFormalParamLocalParamCG paramCg = new AFormalParamLocalParamCG();
paramCg.setPattern(patternCg);
paramCg.setType(pairTypeCg.clone());

paramsCg.add(paramCg);
}
}
return paramsCg;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,20 @@
*/
package org.overture.codegen.assistant;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;

import org.overture.ast.analysis.AnalysisException;
import org.overture.ast.definitions.AAssignmentDefinition;
import org.overture.ast.definitions.AInstanceVariableDefinition;
import org.overture.ast.definitions.AValueDefinition;
import org.overture.ast.definitions.PDefinition;
import org.overture.ast.definitions.SClassDefinition;
import org.overture.ast.definitions.SFunctionDefinition;
import org.overture.ast.definitions.SOperationDefinition;
import org.overture.ast.expressions.ACaseAlternative;
import org.overture.ast.expressions.ALambdaExp;
import org.overture.ast.expressions.ARealLiteralExp;
import org.overture.ast.expressions.PExp;
import org.overture.ast.expressions.SBinaryExp;
Expand Down Expand Up @@ -299,17 +301,41 @@ public AStringLiteralExpCG getDefaultStringlValue()

public boolean isAssigned(PExp exp)
{
SClassDefinition classDef = exp.getAncestor(SClassDefinition.class);
org.overture.ast.node.INode parent = exp.parent();

if (classDef == null)
if (parent == null)
{
return false;
}

return exp.getAncestor(AInstanceVariableDefinition.class) != null
|| exp.getAncestor(AValueDefinition.class) != null
|| exp.getAncestor(AAssignmentDefinition.class) != null
|| exp.getAncestor(AAssignmentStm.class) != null;
Set<org.overture.ast.node.INode> visitedNodes = new HashSet<>();
visitedNodes.add(parent);

do
{
if (parent instanceof AInstanceVariableDefinition
| parent instanceof AValueDefinition
| parent instanceof AAssignmentDefinition
| parent instanceof AAssignmentStm)
{
return true;
}

if (parent instanceof ALambdaExp)
{
return false;
}

parent = parent.parent();

if (parent != null)
{
visitedNodes.add(parent);
}

} while (parent != null && !visitedNodes.contains(parent));

return false;
}

public AHeaderLetBeStCG consHeader(ASetMultipleBindCG binding,
Expand Down
Loading

0 comments on commit fcd85f1

Please sign in to comment.