mirror of
https://github.com/twiglet/cs2j.git
synced 2025-01-18 13:15:17 +01:00
support ref params in lambda expressions, and support short cut assignment operators for ref params
This commit is contained in:
parent
f9e6716aaa
commit
ec95442ac2
@ -1659,9 +1659,16 @@ assignment
|
|||||||
if (isLocalVar) {
|
if (isLocalVar) {
|
||||||
// Is this a wrapped parameter?
|
// Is this a wrapped parameter?
|
||||||
if (lhsType.IsWrapped) {
|
if (lhsType.IsWrapped) {
|
||||||
|
CommonTree newRhsExp = rhsTree;
|
||||||
|
if (assignmentOp.Token.Type != ASSIGN) {
|
||||||
|
Dictionary<string,CommonTree> rhsMap = new Dictionary<string,CommonTree>();
|
||||||
|
rhsMap["this"] = wrapExpression($i.tree, $i.tree.Token);
|
||||||
|
CommonTree rhsPropTree = mkJavaWrapper("${this}.getValue()", rhsMap, assignmentOp.Token);
|
||||||
|
newRhsExp = mkOpExp(mkOpExp(assignmentOp), rhsPropTree, rhsTree);
|
||||||
|
}
|
||||||
Dictionary<string,CommonTree> myMap = new Dictionary<string,CommonTree>();
|
Dictionary<string,CommonTree> myMap = new Dictionary<string,CommonTree>();
|
||||||
myMap["this"] = wrapExpression($i.tree, $i.tree.Token);
|
myMap["this"] = wrapExpression($i.tree, $i.tree.Token);
|
||||||
myMap["value"] = wrapExpression(rhsTree, rhsTree.Token);
|
myMap["value"] = wrapExpression(newRhsExp, rhsTree.Token);
|
||||||
ret = mkJavaWrapper("${this}.setValue(${value})", myMap, $i.tree.Token);
|
ret = mkJavaWrapper("${this}.setValue(${value})", myMap, $i.tree.Token);
|
||||||
}
|
}
|
||||||
// a simple variable assignment
|
// a simple variable assignment
|
||||||
@ -2080,7 +2087,7 @@ anonymous_function_signature[TypeRepTemplate typeCtxt] returns [bool isTypedPara
|
|||||||
if (ret != null)
|
if (ret != null)
|
||||||
$anonymous_function_signature.tree = ret;
|
$anonymous_function_signature.tree = ret;
|
||||||
}:
|
}:
|
||||||
^(PARAMS (parameter_modifier? type identifier)+)
|
^(PARAMS fixed_parameter+)
|
||||||
| ^(p=PARAMS_TYPELESS (identifier { ids.Add($identifier.tree); })+)
|
| ^(p=PARAMS_TYPELESS (identifier { ids.Add($identifier.tree); })+)
|
||||||
{
|
{
|
||||||
if ($typeCtxt != null && $typeCtxt is DelegateRepTemplate && ids.Count == ((DelegateRepTemplate)$typeCtxt).Invoke.Params.Count) {
|
if ($typeCtxt != null && $typeCtxt is DelegateRepTemplate && ids.Count == ((DelegateRepTemplate)$typeCtxt).Invoke.Params.Count) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user