Skip to content

Commit f424088

Browse files
committed
Use lang.ast.types.IsLiteral instead of lang.ast.Type
1 parent 1acfdd8 commit f424088

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

ChangeLog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ XP records for PHP - ChangeLog
33

44
## ?.?.? / ????-??-??
55

6+
## 1.1.1 / 2020-11-15
7+
8+
* Refactor to use more specific `lang.ast.types.IsLiteral` instead of
9+
the base class `lang.ast.Type`
10+
(@thekid)
11+
612
## 1.1.0 / 2020-10-18
713

814
* Merged PR #4: Add ability to use visibility modifiers - @thekid

src/main/php/lang/ast/syntax/php/Records.class.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php namespace lang\ast\syntax\php;
22

3+
use lang\ast\Code;
34
use lang\ast\nodes\{
45
Assignment,
56
ClassDeclaration,
@@ -13,8 +14,7 @@
1314
Variable
1415
};
1516
use lang\ast\syntax\Extension;
16-
use lang\ast\types\IsArray;
17-
use lang\ast\{Code, Type};
17+
use lang\ast\types\{IsArray, IsLiteral};
1818

1919
class Records implements Extension {
2020

@@ -89,7 +89,7 @@ public function setup($language, $emitter) {
8989
$constructor->body[]= new Assignment($r, '=', new Variable($c->name, $l), $l);
9090

9191
// Property declaration + accessor method
92-
$type= $c->variadic ? ($c->type ? new IsArray($c->type) : new Type('array')) : $c->type;
92+
$type= $c->variadic ? ($c->type ? new IsArray($c->type) : new IsLiteral('array')) : $c->type;
9393
$body[]= new Property([$modifiers], $c->name, $type, null, [], null, $l);
9494
$body[]= new Method(['public'], $c->name, new Signature([], $type), [new ReturnStatement($r, $l)]);
9595

@@ -109,13 +109,13 @@ public function setup($language, $emitter) {
109109
$body['__construct()']= $constructor;
110110

111111
// Implement lang.Value
112-
self::inject($body, 'toString', new Signature([], new Type('string')), new Code(
112+
self::inject($body, 'toString', new Signature([], new IsLiteral('string')), new Code(
113113
'"'.strtr(substr($node->name, 1), '\\', '.').'('.substr($string, 2).')"'
114114
));
115-
self::inject($body, 'hashCode', new Signature([], new Type('string')), new Code(
115+
self::inject($body, 'hashCode', new Signature([], new IsLiteral('string')), new Code(
116116
'md5(\\util\\Objects::hashOf(["'.substr($node->name, 1).'"'.$object.']))'
117117
));
118-
self::inject($body, 'compareTo', new Signature([new Parameter('value', null)], new Type('int')), new Code(
118+
self::inject($body, 'compareTo', new Signature([new Parameter('value', null)], new IsLiteral('int')), new Code(
119119
'$value instanceof self ? \\util\\Objects::compare(['.substr($object, 2).'], ['.substr($value, 2).']) : 1'
120120
));
121121

0 commit comments

Comments
 (0)