Compiler internal error

Discussion about the open-source Phalanger [?] project.

Compiler internal error

Postby nagraj@codeplex » September 22nd, 2006, 1:30 pm

When i compiled through Phalanger Beta 2V, i got
Compiler internal error:
System.NullReferenceException: Object reference not set to an instance of an
ect.
at PHP.Core.AST.DirectVarUse.EmitNodeWriteAssign(CodeGenerator codeGenerat

at PHP.Core.AST.DirectVarUse.EmitAssign(CodeGenerator codeGenerator)
at PHP.Core.AST.ValueAssignEx.Emit(CodeGenerator codeGenerator)
at PHP.Core.AST.ExpressionStmt.Emit(CodeGenerator codeGenerator)
at PHP.Core.CodeGenerator.EmitArgfullOverloadBody(PhpRoutine routine, List
body, Position position)
at PHP.Core.AST.MethodDecl.Emit(CodeGenerator codeGenerator)
at PHP.Core.AST.TypeDecl.EmitDefinition(CodeGenerator codeGenerator)
at PHP.Core.AST.TypeDecl.Emit(CodeGenerator codeGenerator)
at PHP.Core.AST.GlobalCode.Emit(CodeGenerator codeGenerator)
at PHP.Core.Reflection.SourceUnit.Emit(CodeGenerator codeGen)
at PHP.Core.Reflection.PureCompilationUnit.Compile(PureAssemblyBuilder ass
lyBuilder, CompilationContext context)
at PHP.Core.Emit.PureAssemblyBuilder.Build(List`1 sourceFiles, Compilation
text context)
at PHP.Core.ApplicationCompiler.Compile(CompilerConfiguration config, ICol
tion`1 sourcePaths, ICollection`1 sourceDirs, IEnumerable`1 fileExtensions, F
Path outPath, FullPath docPath, FullPath entryPoint, Targets target, Boolean
e, Version version, StrongNameKeyPair key, Win32IconResource icon, ICollectio
resourcePaths, ErrorSink errorSink)
at PHP.Core.PhpNetCompiler.Main(String[] args)
nagraj@codeplex
 
Posts: 24
Joined: January 7th, 2012, 8:55 pm

RE: Compiler internal error

Postby Lada Prosek » September 22nd, 2006, 1:54 pm

Beta 2 or the latest nightly build? Could you please post the code that causes this error? Thanks!
Lada Prosek
 
Posts: 47
Joined: January 7th, 2012, 8:52 pm

RE: Compiler internal error

Postby nagraj@codeplex » September 25th, 2006, 7:25 am

/*******************Sample.php
<?php
import namespace System;
import namespace System:::Windows:::Forms;
import namespace System:::Drawing;
import namespace System:::ComponentModel;
class A extends ApplicationContext {

public function __construct() {
$this->Init();}
private function Init() {
$this->comp = new Container();
$this->lNotifyIcon = new NotifyIcon($this->components);
$this->lNotifyIconContextMenu = new ContextMenu();
$this->showContextMenuItem = new MenuItem();
$this->exitContextMenuItem = new MenuItem();
$this->mainForm = new Form;
$this->lNotifyIcon->ContextMenu = $this->lNotifyIconContextMenu;
$this->lNotifyIcon->DoubleClick += new EventHandler($this->lNotifyIcon_DoubleClick);
$this->lNotifyIcon->Icon = new Icon("c:/sample.ico");
$this->lxNotifyIcon->Visible = true;
//$this->lNotifyIconContextMenu->MenuItems->AddRange(new MenuItem array { $showContextMenuItem, $exitContextMenuItem });
$this->showContextMenuItem->Index = 0;
$this->showContextMenuItem->Text = "&L";
$this->showContextMenuItem->DefaultItem = true;
$this->showContextMenuItem->Click += new EventHandler($this->showContextMenuItem_Click);
$this->exitContextMenuItem->Index = 1;
$this->exitContextMenuItem->Text = "&Exit";
$this->exitContextMenuItem->Click += new EventHandler($this->exitContextMenuItem_Click); }

private function showContextMenuItem_Click() {
$this->ShowForm();}

private function exitContextMenuItem_Click() {
$this->ExitThread();}

private function lNotifyIcon_DoubleClick(){
$this->ShowForm();}

private function mainForm_Closed () {
$mainForm = null;}

protected function ExitThreadCore(){
if ($mainForm != null) {
$mainForm->Close();}
$this->ExitThreadCore ();
}

private function ShowForm() {
if ($mainForm == null) {
$mainForm = new B();
$mainForm->Show();
$mainForm->Closed +=new EventHandler($this->mainForm_Closed()); }
else
{$mainForm->Activate();
}
}
}

//************Sample1.php
<?php

import namespace System;
import namespace System:::Drawing;
import namespace System:::Collections;
import namespace System:::ComponentModel;
import namespace System:::Windows:::Forms;
import namespace System:::Data;
import namespace System:::Diagnostics;
import namespace Phalanger;

namespace Phalanger{

class main1{
public static function Main(){
$appli = new A;
Application::Run($appli);
}
}
}


class B extends Form
{
public function __construct(){
$this->InitializeComponent();
//$this->Text = "- " + DateTime.Now.ToLongDateString();
}

private function InitializeComponent(){
$this->tabControl1 = new TabControl();
$this->tabPage1 = new TabPage();
$this->linkLabel1 = new LinkLabel();
// $this->pictureBox1 = new PictureBox();
$this->tabPage2 = new TabPage();
$this->linkLabel2 = new LinkLabel();
$this->linkLabel3 = new LinkLabel();
$this->tabControl1->SuspendLayout();
$this->tabPage1->SuspendLayout();
//(ISupportInitialize($this->pictureBox1)).BeginInit();
$this->SuspendLayout();

$this->tabControl1->Controls->Add($this->tabPage1);
$this->tabControl1->Controls->Add($this->tabPage2);
$this->tabControl1->Location = new Point(-1, -2);
$this->tabControl1->Name = "L";
$this->tabControl1->SelectedIndex = 0;
$this->tabControl1->Size = new Size(395, 377);
$this->tabControl1->TabIndex = 0;

//$this->tabPage1->BackColor = InactiveBorder;
$this->tabPage1->Controls->Add($this->linkLabel3);
$this->tabPage1->Controls->Add($this->linkLabel2);
$this->tabPage1->Controls->Add($this->linkLabel1);
$this->tabPage1->Controls->Add($this->pictureBox1);
//$this->tabPage1->ForeColor = FromArgb(byte(0), byte(0), byte(64));
$this->tabPage1->Location = new Point(4, 22);
$this->tabPage1->Name = "tabPage1";
$this->tabPage1->Padding = new Padding(3);
$this->tabPage1->Size = new Size(387, 351);
$this->tabPage1->TabIndex = 0;
$this->tabPage1->Text = "L";

$this->linkLabel1->AutoSize = true;
//$this->linkLabel1->Font = new Font("Times New Roman", 18, Bold, Point, byte(0));
//$this->linkLabel1->LinkColor = Blue;
$this->linkLabel1->Location = new Point(145, 219);
$this->linkLabel1->Name = "linkLabel1";
$this->linkLabel1->Size = new Size(81, 26);
$this->linkLabel1->TabIndex = 2;
$this->linkLabel1->TabStop = true;
$this->linkLabel1->Text = "L";
$this->linkLabel1->LinkClicked += new LinkLabelLinkClickedEventHandler($this->linkLabel1_LinkClicked);

/*$this->pictureBox1->Image = new Image("c:/flash.Image");
$this->pictureBox1->Location = new Point(79, 44);
$this->pictureBox1->MaximumSize = new Size(400, 400);
$this->pictureBox1->MinimumSize = new Size(100, 100);
$this->pictureBox1->Name = "pictureBox1";
$this->pictureBox1->Size = new Size(219, 138);
$this->pictureBox1->TabIndex = 0;
$this->pictureBox1->TabStop = false;
*/
$this->tabPage2->Location = new Point(4, 22);
$this->tabPage2->Name = "tabPage2";
$this->tabPage2->Padding = new Padding(3);
$this->tabPage2->Size = new Size(387, 351);
$this->tabPage2->TabIndex = 1;
$this->tabPage2->Text = "L";
$this->tabPage2->UseVisualStyleBackColor = true;

$this->linkLabel2->AutoSize = true;
// $this->linkLabel2->Font = new Font("Times New Roman", 14, Bold, Point, byte(0));
//$this->linkLabel2->LinkColor = FromArgb(byte(0), byte(192), byte(0));
$this->linkLabel2->Location = new Point(142, 257);
$this->linkLabel2->Name = "linkLabel2";
$this->linkLabel2->Size = new Size(84, 22);
$this->linkLabel2->TabIndex = 3;
$this->linkLabel2->TabStop = true;
$this->linkLabel2->Text = "L";
$this->linkLabel2->LinkClicked += new LinkLabelLinkClickedEventHandler($this->linkLabel2_LinkClicked);

$this->linkLabel3->AutoSize = true;
//$this->linkLabel3->Font = new Font("Times New Roman", 14, Bold, Point, byte(0));
$this->linkLabel3->Location = new Point(157, 293);
$this->linkLabel3->Name = "linkLabel3";
$this->linkLabel3->Size = new Size(48, 22);
$this->linkLabel3->TabIndex = 4;
$this->linkLabel3->TabStop = true;
$this->linkLabel3->Text = "Help";
$this->linkLabel3->LinkClicked += new LinkLabelLinkClickedEventHandler($this->linkLabel3_LinkClicked);

$this->AutoScaleBaseSize = new Size(5, 13);
// $this->BackColor = FromArgb(byte(128), byte(128), byte(255));
$this->ClientSize = new Size(392, 373);
$this->Controls->Add($this->tabControl1);
$this->MaximizeBox = false;
$this->MaximumSize = new Size(648, 648);
$this->MinimumSize = new Size(100, 100);
$this->Name = "LForm";
$this->Text = "L";
$this->SizeChanged += new EventHandler($this->L_SizeChanged);
$this->tabControl1->ResumeLayout(false);
$this->tabPage1->ResumeLayout(false);
$this->tabPage1->PerformLayout();
// ISupportInitialize($this->pictureBox1).EndInit();
$this->ResumeLayout(false);

}
private function l_SizeChanged()
{
if ($this->WindowState == FormWindowState::Minimized)
{
$this->Close();
}
}

private function linkLabel1_LinkClicked()
{
$x = new Process();
$x->Start("c:/Program Files/Internet Explorer/IExplore.exe", "www.google.com");
}

private function linkLabel2_LinkClicked()
{
$x1 = new Process();
$x1->Start("c:/Program Files/Internet Explorer/IExplore.exe", "http://test.com");
}

private function linkLabel3_LinkClicked()
{
$x2 = new Process();
$x2->Start("c:/Program Files/Internet Explorer/IExplore.exe", "http://sample.com");

}

}


/****************build.cmd
phpc /target:winexe /pure /lang:clr sample1.php sample.php
nagraj@codeplex
 
Posts: 24
Joined: January 7th, 2012, 8:55 pm

RE: Compiler internal error

Postby Lada Prosek » September 25th, 2006, 9:34 am

The problem is in the way you subsribe to events.

This does not work:
$this->SizeChanged += new EventHandler($this->L_SizeChanged);

Subscribe to events using this syntax:
$this->SizeChanged->Add(new EventHandler(array($this, "L_SizeChanged")));

You can omit the event type, which makes the code a bit more readable:
$this->SizeChanged->Add(array($this, "L_SizeChanged"));

The behavior of assignment to an event is still undefined and hence the internal error. Sorry about that and thanks for reporting the issue!
Lada Prosek
 
Posts: 47
Joined: January 7th, 2012, 8:52 pm

RE: Compiler internal error

Postby Lada Prosek » September 25th, 2006, 9:36 am

This discussion has been copied to Work Item 3674. You may wish to continue further discussion there.
Lada Prosek
 
Posts: 47
Joined: January 7th, 2012, 8:52 pm

RE: Compiler internal error

Postby nagraj@codeplex » September 25th, 2006, 11:01 am

Thanks for your reply and your solution.
Now the code is working fine.
nagraj@codeplex
 
Posts: 24
Joined: January 7th, 2012, 8:55 pm


Return to Phalanger project

Who is online

Users browsing this forum: No registered users and 22 guests

cron

User Control Panel

Login

Who is online

In total there are 22 users online :: 0 registered, 0 hidden and 22 guests (based on users active over the past 5 minutes)
Most users ever online was 330 on April 19th, 2024, 1:35 am

Users browsing this forum: No registered users and 22 guests