-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into highprecision
- Loading branch information
Showing
14 changed files
with
371 additions
and
33 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
annotations/src/main/java/annotations/ast/ASTDocLinkAnnotation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/******************************************************************************* | ||
* | ||
* Copyright (c) 2019 Nick Battle. | ||
* | ||
* Author: Nick Battle | ||
* | ||
* This file is part of VDMJ. | ||
* | ||
* VDMJ is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* VDMJ is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with VDMJ. If not, see <http://www.gnu.org/licenses/>. | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
* | ||
******************************************************************************/ | ||
|
||
package annotations.ast; | ||
|
||
import com.fujitsu.vdmj.ast.annotations.ASTAnnotation; | ||
import com.fujitsu.vdmj.ast.lex.LexIdentifierToken; | ||
|
||
public class ASTDocLinkAnnotation extends ASTAnnotation | ||
{ | ||
private static final long serialVersionUID = 1L; | ||
|
||
public ASTDocLinkAnnotation(LexIdentifierToken name) | ||
{ | ||
super(name); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
annotations/src/main/java/annotations/in/INDocLinkAnnotation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/******************************************************************************* | ||
* | ||
* Copyright (c) 2019 Nick Battle. | ||
* | ||
* Author: Nick Battle | ||
* | ||
* This file is part of VDMJ. | ||
* | ||
* VDMJ is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* VDMJ is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with VDMJ. If not, see <http://www.gnu.org/licenses/>. | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
* | ||
******************************************************************************/ | ||
|
||
package annotations.in; | ||
|
||
import com.fujitsu.vdmj.in.annotations.INAnnotation; | ||
import com.fujitsu.vdmj.in.expressions.INExpression; | ||
import com.fujitsu.vdmj.in.expressions.INExpressionList; | ||
import com.fujitsu.vdmj.in.expressions.INStringLiteralExpression; | ||
import com.fujitsu.vdmj.tc.lex.TCIdentifierToken; | ||
|
||
public class INDocLinkAnnotation extends INAnnotation | ||
{ | ||
private static final long serialVersionUID = 1L; | ||
|
||
public INDocLinkAnnotation(TCIdentifierToken name, INExpressionList args) | ||
{ | ||
super(name, args); | ||
} | ||
|
||
@Override | ||
public String toString() | ||
{ | ||
StringBuilder sb = new StringBuilder(); | ||
|
||
for (INExpression arg: args) | ||
{ | ||
INStringLiteralExpression s = (INStringLiteralExpression) arg; | ||
sb.append(s.value.value); | ||
sb.append("\n"); | ||
} | ||
|
||
return sb.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
144 changes: 144 additions & 0 deletions
144
annotations/src/main/java/annotations/tc/TCDocLinkAnnotation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
/******************************************************************************* | ||
* | ||
* Copyright (c) 2019 Nick Battle. | ||
* | ||
* Author: Nick Battle | ||
* | ||
* This file is part of VDMJ. | ||
* | ||
* VDMJ is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* VDMJ is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with VDMJ. If not, see <http://www.gnu.org/licenses/>. | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
* | ||
******************************************************************************/ | ||
|
||
package annotations.tc; | ||
|
||
import java.util.Stack; | ||
|
||
import com.fujitsu.vdmj.tc.annotations.TCAnnotation; | ||
import com.fujitsu.vdmj.tc.definitions.TCClassDefinition; | ||
import com.fujitsu.vdmj.tc.definitions.TCDefinition; | ||
import com.fujitsu.vdmj.tc.expressions.TCExpression; | ||
import com.fujitsu.vdmj.tc.expressions.TCExpressionList; | ||
import com.fujitsu.vdmj.tc.expressions.TCStringLiteralExpression; | ||
import com.fujitsu.vdmj.tc.lex.TCIdentifierToken; | ||
import com.fujitsu.vdmj.tc.modules.TCModule; | ||
import com.fujitsu.vdmj.tc.statements.TCStatement; | ||
import com.fujitsu.vdmj.tc.types.TCType; | ||
import com.fujitsu.vdmj.typechecker.Environment; | ||
import com.fujitsu.vdmj.typechecker.ModuleEnvironment; | ||
import com.fujitsu.vdmj.typechecker.NameScope; | ||
import com.fujitsu.vdmj.typechecker.PrivateClassEnvironment; | ||
|
||
public class TCDocLinkAnnotation extends TCAnnotation | ||
{ | ||
private static final long serialVersionUID = 1L; | ||
|
||
private static Stack<TCDocLinkAnnotation> stack = new Stack<TCDocLinkAnnotation>(); | ||
|
||
public TCDocLinkAnnotation(TCIdentifierToken name, TCExpressionList args) | ||
{ | ||
super(name, args); | ||
} | ||
|
||
@Override | ||
public void tcBefore(TCModule module, ModuleEnvironment env) | ||
{ | ||
stack.clear(); | ||
stack.push(this); | ||
check(); | ||
} | ||
|
||
@Override | ||
public void tcBefore(TCClassDefinition clazz, PrivateClassEnvironment env) | ||
{ | ||
stack.clear(); | ||
stack.push(this); | ||
check(); | ||
} | ||
|
||
@Override | ||
public void tcBefore(TCDefinition def, Environment env, NameScope scope) | ||
{ | ||
stack.push(this); | ||
check(); | ||
} | ||
|
||
@Override | ||
public void tcBefore(TCStatement stmt, Environment env, NameScope scope) | ||
{ | ||
stack.push(this); | ||
check(); | ||
} | ||
|
||
@Override | ||
public void tcBefore(TCExpression exp, Environment env, NameScope scope) | ||
{ | ||
stack.push(this); | ||
check(); | ||
} | ||
|
||
@Override | ||
public void tcAfter(TCClassDefinition m, PrivateClassEnvironment env) | ||
{ | ||
stack.pop(); | ||
} | ||
|
||
@Override | ||
public void tcAfter(TCModule m, ModuleEnvironment e) | ||
{ | ||
stack.pop(); | ||
} | ||
|
||
@Override | ||
public void tcAfter(TCDefinition def, TCType type, Environment env, NameScope scope) | ||
{ | ||
stack.pop(); | ||
} | ||
|
||
@Override | ||
public void tcAfter(TCExpression exp, TCType type, Environment env, NameScope scope) | ||
{ | ||
stack.pop(); | ||
} | ||
|
||
@Override | ||
public void tcAfter(TCStatement stmt, TCType type, Environment env, NameScope scope) | ||
{ | ||
stack.pop(); | ||
} | ||
|
||
public void check() | ||
{ | ||
if (args.isEmpty()) | ||
{ | ||
name.report(6008, "@DocLink(\"arg\"...)"); | ||
} | ||
else | ||
{ | ||
for (TCExpression arg: args) | ||
{ | ||
if (!(arg instanceof TCStringLiteralExpression)) | ||
{ | ||
arg.report(6008, "@DocLink args must be string literals"); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public static Stack<TCDocLinkAnnotation> enclosing() | ||
{ | ||
return stack; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.