Skip to content

Commit

Permalink
Remove deprecated lang.ast.emit.GeneratedCode::lookup()
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Mar 23, 2024
1 parent 378ad38 commit 944d078
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 62 deletions.
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ XP Compiler ChangeLog

## ?.?.? / ????-??-??

## 9.0.0 / ????-??-??

* Removed deprecated *lookup()* from `lang.ast.emit.GeneratedCode`
(@thekid)

## 8.17.2 / 2024-03-23

* Fixed *implicitely nullable type* warnings for parameters with non-
Expand Down
11 changes: 0 additions & 11 deletions src/main/php/lang/ast/emit/GeneratedCode.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,4 @@ public function at($line) {
public function temp() {
return '$'.$this->codegen->symbol();
}

/**
* Looks up a given type
*
* @deprecated Use `CodeGen::lookup()` instead!
* @param string $type
* @return lang.ast.emit.Type
*/
public function lookup($type) {
return $this->codegen->lookup($type);
}
}
4 changes: 1 addition & 3 deletions src/test/php/lang/ast/unittest/ResultTest.class.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?php namespace lang\ast\unittest;

use io\streams\MemoryOutputStream;
use lang\ast\emit\{Declaration, Escaping, Reflection, Result};
use lang\ast\nodes\ClassDeclaration;
use lang\{ClassNotFoundException, Value};
use lang\ast\emit\{Result, Escaping};
use test\{Assert, Expect, Test};

class ResultTest {
Expand Down
49 changes: 1 addition & 48 deletions src/test/php/lang/ast/unittest/emit/GeneratedCodeTest.class.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<?php namespace lang\ast\unittest\emit;

use io\streams\MemoryOutputStream;
use lang\ast\emit\{Declaration, Escaping, GeneratedCode, InType, Reflection, Incomplete};
use lang\ast\nodes\ClassDeclaration;
use lang\ast\types\IsValue;
use lang\ast\emit\GeneratedCode;
use lang\{ClassNotFoundException, Value};
use test\{Assert, Expect, Test, Values};

Expand Down Expand Up @@ -44,51 +42,6 @@ public function writes_epilog_on_closing() {
Assert::equals('<?php ?>', $out->bytes());
}

#[Test]
public function lookup_self() {
$r= new GeneratedCode(new MemoryOutputStream());
$context= $r->codegen->enter(new InType(new ClassDeclaration([], new IsValue('\\T'), null, [], [], null, null, 1)));

Assert::equals(new Declaration($context->type, $r->codegen), $r->lookup('self'));
}

#[Test]
public function lookup_parent() {
$r= new GeneratedCode(new MemoryOutputStream());
$r->codegen->enter(new InType(new ClassDeclaration([], new IsValue('\\T'), new IsValue('\\lang\\Value'), [], [], null, null, 1)));

Assert::equals(new Reflection(Value::class), $r->lookup('parent'));
}

#[Test]
public function lookup_parent_without_parent() {
$r= new GeneratedCode(new MemoryOutputStream());
$r->codegen->enter(new InType(new ClassDeclaration([], new IsValue('\\T'), null, [], [], null, null, 1)));

Assert::null($r->lookup('parent'));
}

#[Test]
public function lookup_named() {
$r= new GeneratedCode(new MemoryOutputStream());
$context= $r->codegen->enter(new InType(new ClassDeclaration([], new IsValue('\\T'), null, [], [], null, null, 1)));

Assert::equals(new Declaration($context->type, $r->codegen), $r->lookup('\\T'));
}

#[Test]
public function lookup_value_interface() {
$r= new GeneratedCode(new MemoryOutputStream());

Assert::equals(new Reflection(Value::class), $r->lookup('\\lang\\Value'));
}

#[Test]
public function lookup_non_existant() {
$r= new GeneratedCode(new MemoryOutputStream());
Assert::instance(Incomplete::class, $r->lookup('\\NotFound'));
}

#[Test]
public function line_number_initially_1() {
$r= new GeneratedCode(new MemoryOutputStream());
Expand Down

0 comments on commit 944d078

Please sign in to comment.