Skip to content

Commit

Permalink
Improve coverage of native configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Thihup committed May 27, 2024
1 parent 9e1d410 commit 263f984
Show file tree
Hide file tree
Showing 9 changed files with 469 additions and 33 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ jobs:
mvn --no-transfer-progress -Pnative package
- name: Compress
run: |
mkdir dev.thihup.jvisualg.ide/target/lib
copy $env:JAVA_HOME/lib/fontconfig.bfc dev.thihup.jvisualg.ide/target/lib
Get-ChildItem -Path dev.thihup.jvisualg.ide/target/*.dll, dev.thihup.jvisualg.ide/target/JVisualG.exe |
Compress-Archive -DestinationPath dev.thihup.jvisualg.ide/target/JVisualG.zip
Compress-Archive -Path dev.thihup.jvisualg.ide/target/lib -DestinationPath dev.thihup.jvisualg.ide/target/JVisualG.zip -Update
- name: Release
uses: ncipollo/release-action@v1
with:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
algoritmo "semnome"

CONST
MAX = 2

tipo

UDT1 = registro
x: inteiro
fimregistro

UDT2 = registro
x: inteiro
z: UDT1
fimregistro

procedimento referencia(var x: logico)
inicio
x <- verdadeiro
fimprocedimento

funcao narrowArguments(x: inteiro): inteiro
inicio
retorne x
fimfuncao

funcao widenArguments(x: real): real
inicio
retorne x
fimfuncao

VAR
A: UDT1
B: UDT2
C: vetor[0..MAX] de UDT1
D: vetor[0..MAX] de UDT2

arrayInteiro: vetor[1..10] de inteiro
matrizInteiro: vetor[1..2,1..2] de inteiro

arrayReal: vetor[1..10] de real
matrizReal: vetor[1..2,1..2] de real


arrayLogico: vetor[1..10] de logico
matrizLogico: vetor[1..2,1..2] de logico


arrayCaracter: vetor[1..10] de caracter
matrizCaracter: vetor[1..2,1..2] de caracter


flutuante: real

meuInteiro: inteiro
meuReal: real
meuCaracter: caracter
meuLogico: logico

x, y, resultado: real
texto1, texto2, resultadoStr: caracter
i: inteiro

inicio

aleatorio on

leia(A.x)
leia(B.x)
leia(C[0].x)
leia(D[0].x)

escreval(A.x)

escreval(B.x)

escreval(C[0].x)

escreval(D[0].x)

A.x <- 4
B.x <- 1
C[0].x <- 3
D[0].x <- 8

escreval(A.x)

escreval(B.x)

escreval(C[0].x)

escreval(D[0].x)

// *** Fun��es Matem�ticas ***

x := 5.0
y := 10.0

resultado := ABS(x)
resultado := ARCCOS(x)
resultado := ARCSEN(x)
resultado := ARCTAN(x)
resultado := COS(x)
resultado := COTAN(x)
resultado := EXP(x, y)
resultado := GRAUPRAD(x)
resultado := INT(x)
resultado := LOG(x)
resultado := LOGN(x)
resultado := PI()
resultado := QUAD(x)
resultado := RADPGRAU(x)
resultado := RAIZQ(x)
resultado := RAND()
i := RANDI(100)
resultado := SEN(x)
resultado := TAN(x)

// *** Fun��es de Strings ***

texto1 := "1000"
texto2 := "1"

i := ASC(texto1)
resultadoStr := CARAC(65)
i := CARACPNUM(texto1)
i := COMPR(texto1)
resultadoStr := COPIA(texto1, 2, 3)
resultadoStr := MAIUSC(texto1)
resultadoStr := MINUSC(texto1)
resultadoStr := NUMPCARAC(65)
i := POS(texto2, texto1)


aleatorio on

mudaCor("VERMELHO", "FRENTE")
mudaCor("Amarelo", "FUNDOS")
mudaCor("azul", "FRENTE")
mudaCor("branco", "FUNDOS")
mudaCor("preto", "FUNDOS")
mudaCor("verde", "FUNDOS")

flutuante <- pi
meuInteiro <- narrowArguments(flutuante)
escreval(meuInteiro)

meuReal <- widenArguments(12)
escreval(meuReal)
meuReal <- widenArguments(meuInteiro)

leia(arrayInteiro[1])
leia(matrizInteiro[1,2])

escreval(arrayInteiro[1])
escreval(matrizInteiro[1,2])

arrayInteiro[1] <- 5
matrizInteiro[1,2] <- 10

arrayReal[1] <- arrayInteiro[1]
matrizReal[1, 2] <- arrayInteiro[1]

meuReal <- 2 ^ 5

debug 1 < 1

referencia(meuLogico)

escreval(+meuInteiro)
escreval(+meuReal)

escolha arrayInteiro[1] faca
caso 4
escreval("Nao aparecer")
caso 5
escreval("Apareci")
fimescolha

escolha matrizInteiro[1,2] faca
caso 1 ate 3
escreval("Nao aparecer")
caso 4 ate 10
escreval("Apareci")
fimescolha

leia(meuCaracter)
leia(meuLogico)
leia(meuInteiro)
leia(meuReal)

fimalgoritmo
24 changes: 6 additions & 18 deletions dev.thihup.jvisualg.ide/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,13 @@
<name>JVisualG</name>

<properties>
<mainClass>dev.thihup.jvisualg.ide.SwingIDE</mainClass>
<native.maven.plugin.version>0.9.12</native.maven.plugin.version>
<mainClass>dev.thihup.jvisualg.ide.Main</mainClass>
<imageName>JVisualG</imageName>
<autoClose>false</autoClose>
<graalvm.version>24.0.1</graalvm.version>
</properties>

<dependencies>
<dependency>
<groupId>dev.thihup.jvisualg</groupId>
<artifactId>dev.thihup.jvisualg.lsp</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>dev.thihup.jvisualg</groupId>
<artifactId>dev.thihup.jvisualg.interpreter</artifactId>
Expand All @@ -52,17 +46,6 @@
<artifactId>rsyntaxtextarea-antlr4-extension</artifactId>
<version>0.0.3</version>
</dependency>
<dependency>
<groupId>org.graalvm.sdk</groupId>
<artifactId>graal-sdk</artifactId>
<version>${graalvm.version}</version>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<artifactId>svm</artifactId>
<version>${graalvm.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -96,6 +79,9 @@
<buildArg>--no-fallback</buildArg>
<buildArg>-H:+ForeignAPISupport</buildArg>
<buildArg>-Dsun.font.layout.ffm=false</buildArg>
<argument>-Duser.language=pt</argument>
<argument>-Duser.country=BR</argument>
<argument>-H:IncludeLocales=pt,en</argument>
</buildArgs>
</configuration>
<executions>
Expand All @@ -117,6 +103,8 @@
<workingDirectory>${project.build.directory}</workingDirectory>
<arguments>
<argument>-Dsun.font.layout.ffm=false</argument>
<argument>-Duser.language=pt</argument>
<argument>-Duser.country=BR</argument>
<argument>-classpath</argument>
<classpath/>
<argument>${mainClass}</argument>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package dev.thihup.jvisualg.ide;

import javax.swing.*;
import java.awt.*;

public class Main {

public static void main(String[] args) throws AWTException {
// Native image by default does not set the java.home
if (System.getProperty("java.home") == null) {
System.setProperty("java.home", ".");
}
// Native image does not support the new implementation based on FFM
System.setProperty("sun.font.layout.ffm", "false");

SwingUtilities.invokeLater(() -> new SwingIDE().setVisible(true));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -591,10 +591,6 @@ private void updateDebugArea(ProgramState programState) {
.forEach(debugTable::addRow);
}

public static void main(String[] args) {
SwingUtilities.invokeLater(() -> new SwingIDE().setVisible(true));
}

private static class TypeChecker extends AbstractParser {
@Override
public ParseResult parse(RSyntaxDocument doc, String style) {
Expand Down
9 changes: 5 additions & 4 deletions dev.thihup.jvisualg.ide/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
module dev.thihup.jvisualg.ide {
requires dev.thihup.jvisualg.lsp;
requires java.desktop;

requires dev.thihup.jvisualg.frontend;
requires dev.thihup.jvisualg.interpreter;

requires org.fife.RSyntaxTextArea;
requires com.formdev.flatlaf;
requires dev.thihup.jvisualg.frontend;

requires org.antlr.antlr4.runtime;
requires rsyntaxtextarea.antlr4.extension;
requires java.desktop;
requires org.graalvm.nativeimage;

exports dev.thihup.jvisualg.ide to org.fife.RSyntaxTextArea;
}
Loading

0 comments on commit 263f984

Please sign in to comment.