Skip to content

Commit dcce098

Browse files
authored
Improved Mamba code generator
1 parent f2a0631 commit dcce098

2 files changed

Lines changed: 48 additions & 21 deletions

File tree

cg/cgMamba.cstl

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ UnaryExpression::
143143

144144
!_1 |-->(_1)[0]
145145

146-
_1->log() |-->Domain.MambaHelper.Log(_1)
147-
_1->log10() |-->Domain.MambaHelper.Log10(_1)
148-
_1->exp() |-->Math.Pow(2.718281828, _1)
146+
_1->log() |-->Domain.AgileUML.Ocl.Log(_1)
147+
_1->log10() |-->Domain.AgileUML.Ocl.Log10(_1)
148+
_1->exp() |-->CommonLib.Math.Pow(2.718281828, _1)
149149

150150
/* _1 in OCL is radians, convert radians to degrees: */
151151
_1->sin() |-->CommonLib.Math.Sin(_1 * (180.0 / CommonLib.Math.Pi()))
@@ -167,13 +167,10 @@ _1->abs() |-->CommonLib.Math.Abs(_1)
167167

168168
_1->size() |-->_1.Length
169169

170-
_1->toInteger() |-->int.Parse(_1)<when> _1 String
171-
_1->toInteger() |-->int.Parse(_1.ToString())
172-
_1->toLong() |-->long.Parse(_1)<when> _1 String
173-
_1->toLong() |-->long.Parse(_1.ToString())
174-
_1->toReal() |-->float.Parse(_1)<when> _1 String
175-
_1->toReal() |-->float.Parse(_1.ToString())
176-
_1->toBoolean() |-->bool.Parse(_1.ToString())
170+
_1->toInteger() |-->int.Parse(_1 + "")
171+
_1->toLong() |-->long.Parse(_1 + "")
172+
_1->toReal() |-->float.Parse(_1 + "")
173+
_1->toBoolean() |-->bool.Parse(_1 + "")
177174

178175
_1->char2byte() |-->Domain.MambaHelper.Char2byte(_1)
179176
_1->byte2char() |-->Domain.MambaHelper.Byte2char(_1)
@@ -302,12 +299,11 @@ _1 div _2 |-->(int.Parse((_1 / _2).ToString()))
302299

303300
/* _1 |-> _2 |-->(new OclMaplet(_1,_2)) */
304301

305-
/* $$$ _1->compareTo(_2) |-->((Comparable) _1).compareTo(_2)<when> _1 object */
306302
_1->compareTo(_2) |-->string.Compare(_1, _2)<when> _1 String
307303
_1->compareTo(_2) |-->((_1 < _2) ? -1 : ((_1 > _2) ? 1 : 0 ))
308304

309305
_1->pow(_2) |-->CommonLib.Math.Pow(_1, _2)
310-
_1->gcd(_2) |-->Domain.MambaHelper.Gcd(_1,_2)
306+
_1->gcd(_2) |-->Domain.AgileUML.Ocl.Gcd(_1,_2)
311307

312308
_1->truncateTo(_2) |-->((_1) as int)<when> _2 0
313309

@@ -319,7 +315,7 @@ _1^_2 |-->_1.Concat(_2)
319315
_1->concatenate(_2) |-->_1.Concat(_2)
320316

321317
_1->union(_2) |-->Domain.MambaHelper.UnionMap(_1,_2)<when> _1 Map
322-
_1->union(_2) |-->_1.AddRange(_2).Distinct()<when> _1 Set
318+
_1->union(_2) |-->_1.Concat(_2).Distinct()<when> _1 Set
323319
_1->union(_2) |-->_1.Concat(_2)
324320

325321
_1->unionAll(_2|_3) |-->Domain.MambaHelper.UnionAll(_1,(_2)->{return _3;})
@@ -388,7 +384,8 @@ _1->exists(_2 | _3) |-->_1.Any(_2 => _3)
388384
_1->exists1(_2 | _3) |-->Domain.AgileUML.Ocl.Exists1(_1.GetAll(), _2 => _3)<when> _1 classId
389385
_1->exists1(_2 | _3) |-->Domain.AgileUML.Ocl.Exists1(_1, _2 => _3)
390386

391-
_1->isUnique(_2 | _3) |-->
387+
_1->isUnique(_2 | _3) |-->(_1.GetAll().Select(_2 => _3).Distinct().Length == _1.GetAll().Length)<when> _1 classId
388+
_1->isUnique(_2 | _3) |-->(_1.Select(_2 => _3).Distinct().Length == _1.Length)
392389

393390
_1 : _2 |-->_2.Contains(_1)
394391
_1 <: _2 |-->_1.All(x => _2.Contains(x))
@@ -399,13 +396,14 @@ _1->includesAll(_2) |-->_2.All(x => _1.Contains(x))
399396
_1->excludes(_2) |-->!(_1.Contains(_2))
400397
_1->excludesAll(_2) |-->_1.All(x => !(_1.Contains(x)))
401398

402-
_1->including(_2) |-->Domain.MambaHelper.IncludingSet(_1,_2)<when> _1 Set
403-
_1->including(_2) |-->Domain.MambaHelper.IncludingSequence(_1,_2)<when> _1 Sequence
404-
_1->prepend(_2) |-->Domain.MambaHelper.Prepend(_1,_2)
405-
_1->append(_2) |-->Domain.MambaHelper.Append(_1,_2)
406-
_1->excluding(_2) |-->Domain.MambaHelper.ExcludingSet(_1,_2)<when> _1 Set
407-
_1->excluding(_2) |-->Domain.MambaHelper.ExcludingSequence(_1,_2)<when> _1 Sequence
408-
_1->excludingAt(_2) |-->Domain.MambaHelper.RemoveAt(_1,_2)
399+
_1->including(_2) |-->_1.Concat({_2}).Distinct()<when> _1 Set
400+
_1->including(_2) |-->_1.Concat({_2})
401+
402+
_1->prepend(_2) |-->({_1}).Concat(_2)
403+
_1->append(_2) |-->_1.Concat({_2})
404+
405+
_1->excluding(_2) |-->_1.Except({_2})
406+
_1->excludingAt(_2) |-->_1.Take(_2-1).Concat(_1.Skip(_2))
409407
_1->excludingFirst(_2) |-->Domain.MambaHelper.RemoveFirst(_1,_2)
410408

411409
_1->hasPrefix(_2) |-->_1.StartsWith(_2)

cg/vbFunctions.cstl

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,29 @@ unlockStmt::
444444
_* |-->
445445

446446

447+
type_::
448+
_1 |-->_1
449+
_1 ( ) |-->Sequence(_1)
450+
451+
complexType::
452+
Double |-->double
453+
Decimal |-->double
454+
Currency |-->double
455+
Integer |-->int
456+
Long |-->int
457+
LongLong |-->long
458+
LongPtr |-->long
459+
Object |-->OclAny
460+
Variant |-->OclAny
461+
Byte |-->int
462+
Single |-->double
463+
Collection |-->Sequence(Map(String,OclAny))
464+
Dictionary |-->Map(String,OclAny)
465+
Range |-->Sequence(Sequence(OclAny))
466+
Date |-->OclDate
467+
_1 |-->_1
468+
_1 . _2 |-->_1._2
469+
447470

448471
sequenceType::
449472
% |-->: Sequence(int)
@@ -461,6 +484,12 @@ As New _1 |-->: Sequence(_1)
461484
As _1 _2 |-->: Sequence(_1)
462485

463486

487+
asTypeClause::
488+
AS _1 |-->: _1
489+
AS NEW _1 |-->: _1
490+
AS _1 _2 |-->: _1
491+
492+
464493
asTypeType::
465494
AS _1 |-->_1`VB2UML
466495
AS NEW _1 |-->_1`VB2UML

0 commit comments

Comments
 (0)