partial revert
This commit is contained in:
parent
c0caa7ce01
commit
bbe0d86670
@ -43,6 +43,7 @@ data Operation = Opiadd
|
|||||||
| Opreturn
|
| Opreturn
|
||||||
| Opireturn
|
| Opireturn
|
||||||
| Opareturn
|
| Opareturn
|
||||||
|
| Opdup_x1
|
||||||
| Opinvokespecial Word16
|
| Opinvokespecial Word16
|
||||||
| Opgoto Word16
|
| Opgoto Word16
|
||||||
| Opsipush Word16
|
| Opsipush Word16
|
||||||
@ -111,6 +112,7 @@ opcodeEncodingLength Opaconst_null = 1
|
|||||||
opcodeEncodingLength Opreturn = 1
|
opcodeEncodingLength Opreturn = 1
|
||||||
opcodeEncodingLength Opireturn = 1
|
opcodeEncodingLength Opireturn = 1
|
||||||
opcodeEncodingLength Opareturn = 1
|
opcodeEncodingLength Opareturn = 1
|
||||||
|
opcodeEncodingLength Opdup_x1 = 1
|
||||||
opcodeEncodingLength (Opinvokespecial _) = 3
|
opcodeEncodingLength (Opinvokespecial _) = 3
|
||||||
opcodeEncodingLength (Opgoto _) = 3
|
opcodeEncodingLength (Opgoto _) = 3
|
||||||
opcodeEncodingLength (Opsipush _) = 3
|
opcodeEncodingLength (Opsipush _) = 3
|
||||||
@ -162,6 +164,7 @@ instance Serializable Operation where
|
|||||||
serialize Opreturn = [0xB1]
|
serialize Opreturn = [0xB1]
|
||||||
serialize Opireturn = [0xAC]
|
serialize Opireturn = [0xAC]
|
||||||
serialize Opareturn = [0xB0]
|
serialize Opareturn = [0xB0]
|
||||||
|
serialize Opdup_x1 = [0x5A]
|
||||||
serialize (Opinvokespecial index) = 0xB7 : unpackWord16 index
|
serialize (Opinvokespecial index) = 0xB7 : unpackWord16 index
|
||||||
serialize (Opgoto index) = 0xA7 : unpackWord16 index
|
serialize (Opgoto index) = 0xA7 : unpackWord16 index
|
||||||
serialize (Opsipush index) = 0x11 : unpackWord16 index
|
serialize (Opsipush index) = 0x11 : unpackWord16 index
|
||||||
|
@ -7,6 +7,7 @@ import Data.List
|
|||||||
import Data.Char
|
import Data.Char
|
||||||
import ByteCode.Generation.Builder.Field
|
import ByteCode.Generation.Builder.Field
|
||||||
|
|
||||||
|
|
||||||
assembleExpression :: Assembler Expression
|
assembleExpression :: Assembler Expression
|
||||||
assembleExpression (constants, ops, lvars) (TypedExpression _ (BinaryOperation op a b))
|
assembleExpression (constants, ops, lvars) (TypedExpression _ (BinaryOperation op a b))
|
||||||
| elem op [Addition, Subtraction, Multiplication, Division, BitwiseAnd, BitwiseOr, BitwiseXor] = let
|
| elem op [Addition, Subtraction, Multiplication, Division, BitwiseAnd, BitwiseOr, BitwiseXor] = let
|
||||||
@ -97,7 +98,7 @@ assembleStatementExpression
|
|||||||
localIndex = findIndex ((==) name) lvars
|
localIndex = findIndex ((==) name) lvars
|
||||||
expr = (TypedExpression dtype (LocalVariable name))
|
expr = (TypedExpression dtype (LocalVariable name))
|
||||||
(exprConstants, exprOps, _) = assembleExpression (constants, ops, lvars) expr
|
(exprConstants, exprOps, _) = assembleExpression (constants, ops, lvars) expr
|
||||||
incrOps = exprOps ++ [Opsipush 1, Opiadd, Opdup]
|
incrOps = exprOps ++ [Opsipush 1, Opiadd, Opdup_x1]
|
||||||
in case localIndex of
|
in case localIndex of
|
||||||
Just index -> (exprConstants, incrOps ++ [Opistore (fromIntegral index)], lvars)
|
Just index -> (exprConstants, incrOps ++ [Opistore (fromIntegral index)], lvars)
|
||||||
Nothing -> error("No such local variable found in local variable pool: " ++ name)
|
Nothing -> error("No such local variable found in local variable pool: " ++ name)
|
||||||
@ -119,7 +120,7 @@ assembleStatementExpression
|
|||||||
localIndex = findIndex ((==) name) lvars
|
localIndex = findIndex ((==) name) lvars
|
||||||
expr = (TypedExpression dtype (LocalVariable name))
|
expr = (TypedExpression dtype (LocalVariable name))
|
||||||
(exprConstants, exprOps, _) = assembleExpression (constants, ops, lvars) expr
|
(exprConstants, exprOps, _) = assembleExpression (constants, ops, lvars) expr
|
||||||
incrOps = exprOps ++ [Opsipush 1, Opiadd, Opisub]
|
incrOps = exprOps ++ [Opsipush 1, Opisub, Opdup_x1]
|
||||||
in case localIndex of
|
in case localIndex of
|
||||||
Just index -> (exprConstants, incrOps ++ [Opistore (fromIntegral index)], lvars)
|
Just index -> (exprConstants, incrOps ++ [Opistore (fromIntegral index)], lvars)
|
||||||
Nothing -> error("No such local variable found in local variable pool: " ++ name)
|
Nothing -> error("No such local variable found in local variable pool: " ++ name)
|
||||||
@ -141,7 +142,7 @@ assembleStatementExpression
|
|||||||
fieldIndex = findFieldIndex constants name
|
fieldIndex = findFieldIndex constants name
|
||||||
expr = (TypedExpression dtype (FieldVariable name))
|
expr = (TypedExpression dtype (FieldVariable name))
|
||||||
(exprConstants, exprOps, _) = assembleExpression (constants, ops ++ [Opaload 0], lvars) expr
|
(exprConstants, exprOps, _) = assembleExpression (constants, ops ++ [Opaload 0], lvars) expr
|
||||||
incrOps = exprOps ++ [Opsipush 1, Opiadd, Opdup]
|
incrOps = exprOps ++ [Opsipush 1, Opiadd, Opdup_x1]
|
||||||
in case fieldIndex of
|
in case fieldIndex of
|
||||||
Just index -> (exprConstants, incrOps ++ [Opputfield (fromIntegral index)], lvars)
|
Just index -> (exprConstants, incrOps ++ [Opputfield (fromIntegral index)], lvars)
|
||||||
Nothing -> error("No such field variable found in field variable pool: " ++ name)
|
Nothing -> error("No such field variable found in field variable pool: " ++ name)
|
||||||
@ -163,7 +164,7 @@ assembleStatementExpression
|
|||||||
fieldIndex = findFieldIndex constants name
|
fieldIndex = findFieldIndex constants name
|
||||||
expr = (TypedExpression dtype (FieldVariable name))
|
expr = (TypedExpression dtype (FieldVariable name))
|
||||||
(exprConstants, exprOps, _) = assembleExpression (constants, ops ++ [Opaload 0], lvars) expr
|
(exprConstants, exprOps, _) = assembleExpression (constants, ops ++ [Opaload 0], lvars) expr
|
||||||
incrOps = exprOps ++ [Opsipush 1, Opiadd, Opisub]
|
incrOps = exprOps ++ [Opsipush 1, Opisub, Opdup_x1]
|
||||||
in case fieldIndex of
|
in case fieldIndex of
|
||||||
Just index -> (exprConstants, incrOps ++ [Opputfield (fromIntegral index)], lvars)
|
Just index -> (exprConstants, incrOps ++ [Opputfield (fromIntegral index)], lvars)
|
||||||
Nothing -> error("No such field variable found in field variable pool: " ++ name)
|
Nothing -> error("No such field variable found in field variable pool: " ++ name)
|
||||||
|
Loading…
Reference in New Issue
Block a user