GP-3534 Fixed cpool invalid error, added test for cpool arguments

This commit is contained in:
emteere 2023-06-09 01:40:30 +00:00
parent be86c87cab
commit 720dce335e
8 changed files with 75 additions and 22 deletions

View File

@ -2,7 +2,7 @@
<feature
id="ghidra.xtext.sleigh.feature"
label="Ghidra Sleigh Editor"
version="1.0.1.qualifier"
version="1.0.2.qualifier"
provider-name="Ghidra">
<copyright>

View File

@ -5,9 +5,7 @@ Bundle-Name: ghidra.xtext.sleigh.tests
Bundle-Vendor: Ghidra
Bundle-Version: 1.0.0.qualifier
Bundle-SymbolicName: ghidra.xtext.sleigh.tests; singleton:=true
Bundle-ActivationPolicy: lazy
Require-Bundle: ghidra.xtext.sleigh,
org.junit.jupiter.api;bundle-version="[5.0.0,6.0.0)",
org.eclipse.xtext.testing,
org.eclipse.xtext.xbase.testing,
org.eclipse.xtext.xbase.lib;bundle-version="2.14.0"

View File

@ -16,11 +16,13 @@
package ghidra.xtext.sleigh.tests
import com.google.inject.Inject
import ghidra.xtext.sleigh.sleigh.Model
import ghidra.xtext.sleigh.sleigh.SleighPackage
import org.eclipse.xtext.diagnostics.Diagnostic
import org.eclipse.xtext.testing.InjectWith
import org.eclipse.xtext.testing.extensions.InjectionExtension
import org.eclipse.xtext.testing.util.ParseHelper
import org.eclipse.xtext.testing.validation.ValidationTestHelper
import ghidra.xtext.sleigh.sleigh.Model
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.^extension.ExtendWith
@ -194,5 +196,52 @@ class SleighParsingTest {
''')
model.assertNoErrors
}
@Test def void testCpool() {
var model = parseHelper.parse('''
define space register size=2 type=register_space wordsize=1 default;
define register offset=0 size=1 [ Z C N V ];
define token instr(16)
op = (0,15)
reg = (0,1)
cc = (2,3)
;
attach variables [ reg ] [ Z C N V ];
:mov reg,N,op is op=0 & N & reg & op & op=1 {
tmp:1 = cpool(0:1, 0:2);
tmp1:2 = cpool(0:1, 1:2, 2:2, 3:4);
tmp2:2 = cpool(0:1, 1:2, 2:2, 3:4, 3:4, 4:4, 5:4, 6:4);
}
''')
model.assertNoErrors
model = parseHelper.parse('''
define space register size=2 type=register_space wordsize=1 default;
define register offset=0 size=1 [ Z C N V ];
define token instr(16)
op = (0,15)
reg = (0,1)
cc = (2,3)
;
attach variables [ reg ] [ Z C N V ];
:mov reg,N,op is op=0 & N & reg & op & op=1 {
tmp:1 = cpool(0:1, 0:2);
tmp:2 = cpool(0:1); # too few args
}
''')
assertError(model,
SleighPackage::eINSTANCE.expression,
Diagnostic.SYNTAX_DIAGNOSTIC, 314,1,
"mismatched input ')' expecting ','"
)
}
}

View File

@ -7,13 +7,13 @@ Bundle-Version: 1.0.0.qualifier
Bundle-SymbolicName: ghidra.xtext.sleigh.ui.tests; singleton:=true
Bundle-ActivationPolicy: lazy
Require-Bundle: ghidra.xtext.sleigh.ui,
org.junit.jupiter.api;bundle-version="[5.0.0,6.0.0)",
org.eclipse.xtext.testing,
org.eclipse.xtext.xbase.testing,
org.eclipse.xtext.junit4,
org.eclipse.xtext.xbase.junit,
org.eclipse.core.runtime,
org.eclipse.ui.workbench;resolution:=optional,
org.eclipse.xtext.ui.testing
org.eclipse.xtext.ui.testing,
org.eclipse.xtext.xbase.ui.testing
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: ghidra.xtext.sleigh.ui.tests;x-internal=true

View File

@ -3,7 +3,7 @@ Automatic-Module-Name: ghidra.xtext.sleigh.ui
Bundle-ManifestVersion: 2
Bundle-Name: ghidra.xtext.sleigh.ui
Bundle-Vendor: Ghidra
Bundle-Version: 1.0.1.qualifier
Bundle-Version: 1.0.2.qualifier
Bundle-SymbolicName: ghidra.xtext.sleigh.ui; singleton:=true
Bundle-ActivationPolicy: lazy
Require-Bundle: ghidra.xtext.sleigh,

View File

@ -3,9 +3,8 @@ Automatic-Module-Name: ghidra.xtext.sleigh
Bundle-ManifestVersion: 2
Bundle-Name: ghidra.xtext.sleigh
Bundle-Vendor: Ghidra
Bundle-Version: 1.0.1.qualifier
Bundle-Version: 1.0.2.qualifier
Bundle-SymbolicName: ghidra.xtext.sleigh; singleton:=true
Bundle-ActivationPolicy: lazy
Require-Bundle: org.eclipse.xtext,
org.eclipse.xtext.xbase,
org.eclipse.equinox.common;bundle-version="3.5.0",
@ -16,16 +15,17 @@ Require-Bundle: org.eclipse.xtext,
org.eclipse.xtend.lib;bundle-version="2.14.0",
org.antlr.runtime;bundle-version="[3.2.0,3.2.1)"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: ghidra.xtext.sleigh.formatting2,
ghidra.xtext.sleigh,
ghidra.xtext.sleigh.sleigh.impl,
ghidra.xtext.sleigh.validation,
ghidra.xtext.sleigh.scoping,
ghidra.xtext.sleigh.sleigh,
ghidra.xtext.sleigh.serializer,
ghidra.xtext.sleigh.parser.antlr.internal,
ghidra.xtext.sleigh.services,
ghidra.xtext.sleigh.sleigh.util,
Export-Package: ghidra.xtext.sleigh,
ghidra.xtext.sleigh.converter,
ghidra.xtext.sleigh.formatting2,
ghidra.xtext.sleigh.generator,
ghidra.xtext.sleigh.parser.antlr
ghidra.xtext.sleigh.parser.antlr,
ghidra.xtext.sleigh.parser.antlr.internal;x-internal:=true,
ghidra.xtext.sleigh.scoping,
ghidra.xtext.sleigh.serializer,
ghidra.xtext.sleigh.services,
ghidra.xtext.sleigh.sleigh,
ghidra.xtext.sleigh.sleigh.impl,
ghidra.xtext.sleigh.sleigh.util,
ghidra.xtext.sleigh.validation
Import-Package: org.apache.log4j

View File

@ -77,7 +77,7 @@ Creating an installation zip file to install in Eclipse:
- Export source: UNCHECKED
- Package as individual JAR archives: CHECKED
- Generate p2 repository: CHECKED
- Categorize repository: CHECKED.
- Categorize repository: CHECKED
- Qualifier replacement: CHECKED + clear field so default is used
- Save as Ant script: UNCHECKED
- Allow for binary cycles in target platform: CHECKED

View File

@ -662,15 +662,21 @@ exprSingle returns Expression:
| pcodeop='round' '(' op1=expr ')'
| pcodeop='popcount' '(' op1=expr ')'
| pcodeop='lzcount' '(' op1=expr ')'
| pcodeop='cpool' '(' op1=expr ',' op2=expr ',' op3=expr ')'
| pcodeop='cpool' '(' op1=cpoolParams ')'
| pcodeop='newobject' '(' op1=newObjParams ')'
| op=[macroOrPcode] op1=paramlist
;
newObjParams:
// must have at least 1 parameter
((parameters+=expr) (',' parameters+=expr)*)
;
cpoolParams:
// must have at least 2 parameters
((parameters+=expr) ',' (parameters+=expr) (',' parameters+=expr)*)
;
exprSym:
vnode=[vnoderef]
| vnode=[specificsymbol] sizeOpColon size=integerValue