bytecode #3
@ -432,94 +432,93 @@ assembleStatementExpression
|
|||||||
(constants_a, ops_a ++ [Opdup_x1, Opputfield (fromIntegral fieldIndex)], lvars)
|
(constants_a, ops_a ++ [Opdup_x1, Opputfield (fromIntegral fieldIndex)], lvars)
|
||||||
something_else -> error ("expected TypedExpression, but got: " ++ show something_else)
|
something_else -> error ("expected TypedExpression, but got: " ++ show something_else)
|
||||||
|
|
||||||
|
assembleStatementExpression
|
||||||
|
(constants, ops, lvars)
|
||||||
|
(TypedStatementExpression _ (PreIncrement (TypedExpression dtype receiver))) = let
|
||||||
|
target = resolveNameChain (TypedExpression dtype receiver)
|
||||||
|
in case target of
|
||||||
|
(TypedExpression dtype (LocalVariable name)) -> let
|
||||||
|
localIndex = findIndex ((==) name) lvars
|
||||||
|
expr = (TypedExpression dtype (LocalVariable name))
|
||||||
|
(exprConstants, exprOps, _) = assembleExpression (constants, ops, lvars) expr
|
||||||
|
in case localIndex of
|
||||||
|
Just index -> (exprConstants, exprOps ++ [Opsipush 1, Opiadd, Opdup_x1, Opistore (fromIntegral index)], lvars)
|
||||||
|
Nothing -> error("No such local variable found in local variable pool: " ++ name)
|
||||||
|
(TypedExpression dtype (FieldVariable name)) -> let
|
||||||
|
owner = resolveNameChainOwner (TypedExpression dtype receiver)
|
||||||
|
in case owner of
|
||||||
|
(TypedExpression otype _) -> let
|
||||||
|
(constants_f, fieldIndex) = getFieldIndex constants (otype, name, datatypeDescriptor dtype)
|
||||||
|
(constants_r, ops_r, _) = assembleNameChain (constants_f, ops, lvars) (TypedExpression dtype receiver)
|
||||||
|
in
|
||||||
|
(constants_r, ops_r ++ [Opdup, Opgetfield (fromIntegral fieldIndex), Opsipush 1, Opiadd, Opdup_x1, Opputfield (fromIntegral fieldIndex)], lvars)
|
||||||
|
something_else -> error ("expected TypedExpression, but got: " ++ show something_else)
|
||||||
|
|
||||||
assembleStatementExpression
|
assembleStatementExpression
|
||||||
(constants, ops, lvars)
|
(constants, ops, lvars)
|
||||||
(TypedStatementExpression _ (PreIncrement (TypedExpression dtype (LocalVariable name)))) = let
|
(TypedStatementExpression _ (PreDecrement (TypedExpression dtype receiver))) = let
|
||||||
localIndex = findIndex ((==) name) lvars
|
target = resolveNameChain (TypedExpression dtype receiver)
|
||||||
expr = (TypedExpression dtype (LocalVariable name))
|
in case target of
|
||||||
(exprConstants, exprOps, _) = assembleExpression (constants, ops, lvars) expr
|
(TypedExpression dtype (LocalVariable name)) -> let
|
||||||
incrOps = exprOps ++ [Opsipush 1, Opiadd, Opdup_x1]
|
localIndex = findIndex ((==) name) lvars
|
||||||
in case localIndex of
|
expr = (TypedExpression dtype (LocalVariable name))
|
||||||
Just index -> (exprConstants, incrOps ++ [Opistore (fromIntegral index)], lvars)
|
(exprConstants, exprOps, _) = assembleExpression (constants, ops, lvars) expr
|
||||||
Nothing -> error("No such local variable found in local variable pool: " ++ name)
|
in case localIndex of
|
||||||
|
Just index -> (exprConstants, exprOps ++ [Opsipush 1, Opisub, Opdup_x1, Opistore (fromIntegral index)], lvars)
|
||||||
|
Nothing -> error("No such local variable found in local variable pool: " ++ name)
|
||||||
|
(TypedExpression dtype (FieldVariable name)) -> let
|
||||||
|
owner = resolveNameChainOwner (TypedExpression dtype receiver)
|
||||||
|
in case owner of
|
||||||
|
(TypedExpression otype _) -> let
|
||||||
|
(constants_f, fieldIndex) = getFieldIndex constants (otype, name, datatypeDescriptor dtype)
|
||||||
|
(constants_r, ops_r, _) = assembleNameChain (constants_f, ops, lvars) (TypedExpression dtype receiver)
|
||||||
|
in
|
||||||
|
(constants_r, ops_r ++ [Opdup, Opgetfield (fromIntegral fieldIndex), Opsipush 1, Opisub, Opdup_x1, Opputfield (fromIntegral fieldIndex)], lvars)
|
||||||
|
something_else -> error ("expected TypedExpression, but got: " ++ show something_else)
|
||||||
|
|
||||||
assembleStatementExpression
|
assembleStatementExpression
|
||||||
(constants, ops, lvars)
|
(constants, ops, lvars)
|
||||||
(TypedStatementExpression _ (PostIncrement (TypedExpression dtype (LocalVariable name)))) = let
|
(TypedStatementExpression _ (PostIncrement (TypedExpression dtype receiver))) = let
|
||||||
localIndex = findIndex ((==) name) lvars
|
target = resolveNameChain (TypedExpression dtype receiver)
|
||||||
expr = (TypedExpression dtype (LocalVariable name))
|
in case target of
|
||||||
(exprConstants, exprOps, _) = assembleExpression (constants, ops, lvars) expr
|
(TypedExpression dtype (LocalVariable name)) -> let
|
||||||
incrOps = exprOps ++ [Opdup, Opsipush 1, Opiadd]
|
localIndex = findIndex ((==) name) lvars
|
||||||
in case localIndex of
|
expr = (TypedExpression dtype (LocalVariable name))
|
||||||
Just index -> (exprConstants, incrOps ++ [Opistore (fromIntegral index)], lvars)
|
(exprConstants, exprOps, _) = assembleExpression (constants, ops, lvars) expr
|
||||||
Nothing -> error("No such local variable found in local variable pool: " ++ name)
|
in case localIndex of
|
||||||
|
Just index -> (exprConstants, exprOps ++ [Opdup_x1, Opsipush 1, Opiadd, Opistore (fromIntegral index)], lvars)
|
||||||
|
Nothing -> error("No such local variable found in local variable pool: " ++ name)
|
||||||
|
(TypedExpression dtype (FieldVariable name)) -> let
|
||||||
|
owner = resolveNameChainOwner (TypedExpression dtype receiver)
|
||||||
|
in case owner of
|
||||||
|
(TypedExpression otype _) -> let
|
||||||
|
(constants_f, fieldIndex) = getFieldIndex constants (otype, name, datatypeDescriptor dtype)
|
||||||
|
(constants_r, ops_r, _) = assembleNameChain (constants_f, ops, lvars) (TypedExpression dtype receiver)
|
||||||
|
in
|
||||||
|
(constants_r, ops_r ++ [Opdup, Opgetfield (fromIntegral fieldIndex), Opdup_x1, Opsipush 1, Opiadd, Opputfield (fromIntegral fieldIndex)], lvars)
|
||||||
|
something_else -> error ("expected TypedExpression, but got: " ++ show something_else)
|
||||||
|
|
||||||
assembleStatementExpression
|
assembleStatementExpression
|
||||||
(constants, ops, lvars)
|
(constants, ops, lvars)
|
||||||
(TypedStatementExpression _ (PreDecrement (TypedExpression dtype (LocalVariable name)))) = let
|
(TypedStatementExpression _ (PostDecrement (TypedExpression dtype receiver))) = let
|
||||||
localIndex = findIndex ((==) name) lvars
|
target = resolveNameChain (TypedExpression dtype receiver)
|
||||||
expr = (TypedExpression dtype (LocalVariable name))
|
in case target of
|
||||||
(exprConstants, exprOps, _) = assembleExpression (constants, ops, lvars) expr
|
(TypedExpression dtype (LocalVariable name)) -> let
|
||||||
incrOps = exprOps ++ [Opsipush 1, Opisub, Opdup_x1]
|
localIndex = findIndex ((==) name) lvars
|
||||||
in case localIndex of
|
expr = (TypedExpression dtype (LocalVariable name))
|
||||||
Just index -> (exprConstants, incrOps ++ [Opistore (fromIntegral index)], lvars)
|
(exprConstants, exprOps, _) = assembleExpression (constants, ops, lvars) expr
|
||||||
Nothing -> error("No such local variable found in local variable pool: " ++ name)
|
in case localIndex of
|
||||||
|
Just index -> (exprConstants, exprOps ++ [Opdup_x1, Opsipush 1, Opisub, Opistore (fromIntegral index)], lvars)
|
||||||
assembleStatementExpression
|
Nothing -> error("No such local variable found in local variable pool: " ++ name)
|
||||||
(constants, ops, lvars)
|
(TypedExpression dtype (FieldVariable name)) -> let
|
||||||
(TypedStatementExpression _ (PostDecrement (TypedExpression dtype (LocalVariable name)))) = let
|
owner = resolveNameChainOwner (TypedExpression dtype receiver)
|
||||||
localIndex = findIndex ((==) name) lvars
|
in case owner of
|
||||||
expr = (TypedExpression dtype (LocalVariable name))
|
(TypedExpression otype _) -> let
|
||||||
(exprConstants, exprOps, _) = assembleExpression (constants, ops, lvars) expr
|
(constants_f, fieldIndex) = getFieldIndex constants (otype, name, datatypeDescriptor dtype)
|
||||||
incrOps = exprOps ++ [Opdup, Opsipush 1, Opisub]
|
(constants_r, ops_r, _) = assembleNameChain (constants_f, ops, lvars) (TypedExpression dtype receiver)
|
||||||
in case localIndex of
|
in
|
||||||
Just index -> (exprConstants, incrOps ++ [Opistore (fromIntegral index)], lvars)
|
(constants_r, ops_r ++ [Opdup, Opgetfield (fromIntegral fieldIndex), Opdup_x1, Opsipush 1, Opisub, Opputfield (fromIntegral fieldIndex)], lvars)
|
||||||
Nothing -> error("No such local variable found in local variable pool: " ++ name)
|
something_else -> error ("expected TypedExpression, but got: " ++ show something_else)
|
||||||
|
|
||||||
assembleStatementExpression
|
|
||||||
(constants, ops, lvars)
|
|
||||||
(TypedStatementExpression _ (PreIncrement (TypedExpression dtype (FieldVariable name)))) = let
|
|
||||||
fieldIndex = findFieldIndex constants name
|
|
||||||
expr = (TypedExpression dtype (FieldVariable name))
|
|
||||||
(exprConstants, exprOps, _) = assembleExpression (constants, ops ++ [Opaload 0], lvars) expr
|
|
||||||
incrOps = exprOps ++ [Opsipush 1, Opiadd, Opdup_x1]
|
|
||||||
in case fieldIndex of
|
|
||||||
Just index -> (exprConstants, incrOps ++ [Opputfield (fromIntegral index)], lvars)
|
|
||||||
Nothing -> error("No such field variable found in field variable pool: " ++ name)
|
|
||||||
|
|
||||||
assembleStatementExpression
|
|
||||||
(constants, ops, lvars)
|
|
||||||
(TypedStatementExpression _ (PostIncrement (TypedExpression dtype (FieldVariable name)))) = let
|
|
||||||
fieldIndex = findFieldIndex constants name
|
|
||||||
expr = (TypedExpression dtype (FieldVariable name))
|
|
||||||
(exprConstants, exprOps, _) = assembleExpression (constants, ops ++ [Opaload 0], lvars) expr
|
|
||||||
incrOps = exprOps ++ [Opdup_x1, Opsipush 1, Opiadd]
|
|
||||||
in case fieldIndex of
|
|
||||||
Just index -> (exprConstants, incrOps ++ [Opputfield (fromIntegral index)], lvars)
|
|
||||||
Nothing -> error("No such field variable found in field variable pool: " ++ name)
|
|
||||||
|
|
||||||
assembleStatementExpression
|
|
||||||
(constants, ops, lvars)
|
|
||||||
(TypedStatementExpression _ (PreDecrement (TypedExpression dtype (FieldVariable name)))) = let
|
|
||||||
fieldIndex = findFieldIndex constants name
|
|
||||||
expr = (TypedExpression dtype (FieldVariable name))
|
|
||||||
(exprConstants, exprOps, _) = assembleExpression (constants, ops ++ [Opaload 0], lvars) expr
|
|
||||||
incrOps = exprOps ++ [Opsipush 1, Opisub, Opdup_x1]
|
|
||||||
in case fieldIndex of
|
|
||||||
Just index -> (exprConstants, incrOps ++ [Opputfield (fromIntegral index)], lvars)
|
|
||||||
Nothing -> error("No such field variable found in field variable pool: " ++ name)
|
|
||||||
|
|
||||||
assembleStatementExpression
|
|
||||||
(constants, ops, lvars)
|
|
||||||
(TypedStatementExpression _ (PostDecrement (TypedExpression dtype (FieldVariable name)))) = let
|
|
||||||
fieldIndex = findFieldIndex constants name
|
|
||||||
expr = (TypedExpression dtype (FieldVariable name))
|
|
||||||
(exprConstants, exprOps, _) = assembleExpression (constants, ops ++ [Opaload 0], lvars) expr
|
|
||||||
incrOps = exprOps ++ [Opdup_x1, Opsipush 1, Opisub]
|
|
||||||
in case fieldIndex of
|
|
||||||
Just index -> (exprConstants, incrOps ++ [Opputfield (fromIntegral index)], lvars)
|
|
||||||
Nothing -> error("No such field variable found in field variable pool: " ++ name)
|
|
||||||
|
|
||||||
assembleStatementExpression
|
assembleStatementExpression
|
||||||
(constants, ops, lvars)
|
(constants, ops, lvars)
|
||||||
|
Loading…
Reference in New Issue
Block a user