исправлена ошибка компиляции: Seq(1,2,3).print

This commit is contained in:
Бондарев Иван 2015-09-28 21:28:12 +02:00
parent 8644f3eff4
commit c65df901ee
6 changed files with 212 additions and 96 deletions

View file

@ -256,23 +256,23 @@ begin
if Self.Rank = 1 then
for var i := 0 to Self.Length - 1 do
begin
write(Self.GetValue(i));
PABCSystem.write(Self.GetValue(i));
if i < Self.Length - 1 then
write(delimiter);
PABCSystem.write(delimiter);
end
else if Self.Rank = 2 then
for var i := 0 to Self.GetLength(0) - 1 do
begin
for var j := 0 to Self.GetLength(1) - 1 do
write(Self.GetValue(i, j), delimiter);
writeln;
PABCSystem.write(Self.GetValue(i, j), delimiter);
PABCSystem.writeln;
end;
end;
procedure &Array.Writeln(delimiter: string);
begin
Self.Write(delimiter);
writeln;
PABCSystem.writeln;
end;
end.

View file

@ -116,6 +116,35 @@ function ReadPNode: PNode;
/// Âîçâðàùàåò ââåäåííîå çíà÷åíèå òèïà Node
function ReadNode: Node;
/// Âîçâðàùàåò ââåäåííîå çíà÷åíèå òèïà integer
function ReadlnInteger: integer;
/// Âîçâðàùàåò ââåäåííîå çíà÷åíèå òèïà real
function ReadlnReal: real;
/// Âîçâðàùàåò ââåäåííîå çíà÷åíèå òèïà char
function ReadlnChar: char;
/// Âîçâðàùàåò ââåäåííîå çíà÷åíèå òèïà string
function ReadlnString: string;
/// Âîçâðàùàåò ââåäåííîå çíà÷åíèå òèïà boolean
function ReadlnBoolean: boolean;
/// Âîçâðàùàåò ââåäåííîå çíà÷åíèå òèïà PNode
function ReadlnPNode: PNode;
/// Âîçâðàùàåò ââåäåííîå çíà÷åíèå òèïà Node
function ReadlnNode: Node;
/// Âîçâðàùàåò ìàññèâ èç n öåëûõ, ââåäåííûõ ñ êëàâèàòóðû
function ReadArrInteger(n: integer): array of integer;
/// Âîçâðàùàåò ìàññèâ èç n âåùåñòâåííûõ, ââåäåííûõ ñ êëàâèàòóðû
function ReadArrReal(n: integer): array of real;
/// Âîçâðàùàåò ìàññèâ èç n ñòðîê, ââåäåííûõ ñ êëàâèàòóðû
function ReadArrString(n: integer): array of string;
/// Âîçâðàùàåò ïîñëåäîâàòåëüíîñòü èç n öåëûõ, ââåäåííûõ ñ êëàâèàòóðû
function ReadSeqInteger(n: integer): sequence of integer;
/// Âîçâðàùàåò ïîñëåäîâàòåëüíîñòü èç n âåùåñòâåííûõ, ââåäåííûõ ñ êëàâèàòóðû
function ReadSeqReal(n: integer): sequence of real;
/// Âîçâðàùàåò ïîñëåäîâàòåëüíîñòü èç n ñòðîê, ââåäåííûõ ñ êëàâèàòóðû
function ReadSeqString(n: integer): sequence of string;
procedure GetR(var param: real);
procedure GetN(var param: integer);
@ -870,6 +899,77 @@ begin
Result := GetNode;
end;
function ReadlnInteger: integer;
begin
Result := GetInt;
end;
function ReadlnReal: real;
begin
Result := GetReal;
end;
function ReadlnChar: char;
begin
Result := GetChar;
end;
function ReadlnString: string;
begin
Result := GetString;
end;
function ReadlnBoolean: boolean;
begin
Result := GetBool;
end;
function ReadlnPNode: PNode;
begin
Result := GetPNode;
end;
function ReadlnNode: Node;
begin
Result := GetNode;
end;
function ReadArrInteger(n: integer): array of integer;
begin
Result := new integer[n];
for var i:=0 to Result.Length-1 do
Result[i] := ReadInteger;
end;
function ReadArrReal(n: integer): array of real;
begin
Result := new real[n];
for var i:=0 to Result.Length-1 do
Result[i] := ReadReal;
end;
function ReadArrString(n: integer): array of string;
begin
Result := new string[n];
for var i:=0 to Result.Length-1 do
Result[i] := ReadString;
end;
function ReadSeqInteger(n: integer): sequence of integer;
begin
Result := Range(1,n).Select(i->ReadInteger());
end;
function ReadSeqReal(n: integer): sequence of real;
begin
Result := Range(1,n).Select(i->ReadReal());
end;
function ReadSeqString(n: integer): sequence of string;
begin
Result := Range(1,n).Select(i->ReadString());
end;
// -----------------------------------------------------
// Ïðîöåäóðû Put
// -----------------------------------------------------

View file

@ -1341,7 +1341,15 @@ namespace PascalABCCompiler.NetHelper
si = temp;
}
}
Type nested_t = t.GetNestedType(name);
Type nested_t = null;
foreach (Type nt in t.GetNestedTypes())
{
if (string.Compare(nt.Name, name, true) == 0)
{
nested_t = nt;
break;
}
}
if (nested_t != null)
{
SymbolInfo temp = new SymbolInfo(compiled_type_node.get_type_node(nested_t));
@ -1405,7 +1413,15 @@ namespace PascalABCCompiler.NetHelper
si = temp;
}
}
Type nested_t = t.GetNestedType(name);
Type nested_t = null;
foreach (Type nt in t.GetNestedTypes())
{
if (string.Compare(nt.Name,name, true) == 0)
{
nested_t = nt;
break;
}
}
if (nested_t != null)
{
SymbolInfo temp = new SymbolInfo(compiled_type_node.get_type_node(nested_t));
@ -1882,11 +1898,11 @@ namespace PascalABCCompiler.NetHelper
TypeInfo ti = (TypeInfo)types[name];
if (ti != null /*&& cur_used_assemblies.ContainsKey(t.Assembly)*/) return ti.type;
//ivan added - runtime types adding
Type t = Type.GetType(name);
Type t = Type.GetType(name, false, true);
if (t == null)
foreach (Assembly a in assemblies.Values)
{
t = a.GetType(name);
t = a.GetType(name, false, true);
if (t != null) break;
}
if (t != null)

View file

@ -4,98 +4,98 @@ using System;
namespace SymbolTable
{
/// <summary>
/// Äèíàìè÷åñêàÿ õåø òàáëèöà ñòðîê
/// </summary>
public class DSHashTable
{
private int count;
private int hash_size
{
get
{
return hash_arr.Length;
}
}
public HashTableNode[] hash_arr;
private int HashFunc(string s)
{
int n=0;
for (int i=0;i<s.Length;i++)
n=127*n+s[i]*7;//137
return Math.Abs(n % hash_size);
}
private System.Collections.Hashtable ht = new System.Collections.Hashtable();
private int GetHash(string s)
{
int hash=HashFunc(s);
int i=1;
ht.Clear();
while (hash_arr[hash]!=null)
{
if (hash_arr[hash].Name==s) return hash;
i=i*11;
hash=Math.Abs((hash + i)%hash_size);
if (ht[hash] != null)
Resize(hash_size*2);
else
ht[hash]=ht;
}
return hash;
}
private void Resize(int new_size)
{
HashTableNode[] ha=new HashTableNode[new_size];
for (int i=0;i<new_size;i++) ha[i]=null;
count=0;
HashTableNode[] hat=hash_arr;
hash_arr=ha;
if (hat.Length>new_size) return;
for (int i=0;i<hat.Length;i++)
if (hat[i]!=null) Add(hat[i]);
}
/// <summary>
/// Äèíàìè÷åñêàÿ õåø òàáëèöà ñòðîê
/// </summary>
public class DSHashTable
{
private int count;
private int hash_size
{
get
{
return hash_arr.Length;
}
}
public HashTableNode[] hash_arr;
public DSHashTable(int start_size)
{
hash_arr=new HashTableNode[start_size];
ClearTable();
}
public void ClearTable()
{
private int HashFunc(string s)
{
int n = 0;
for (int i = 0; i < s.Length; i++)
n = 127 * n + s[i] * 7;//137
return Math.Abs(n % hash_size);
}
private System.Collections.Hashtable ht = new System.Collections.Hashtable();
private int GetHash(string s)
{
int hash = HashFunc(s);
int i = 1;
ht.Clear();
while (hash_arr[hash] != null)
{
if (hash_arr[hash].Name == s) return hash;
i = i * 11;
hash = Math.Abs((hash + i) % hash_size);
if (ht[hash] != null)
Resize(hash_size * 2);
else
ht[hash] = ht;
}
return hash;
}
private void Resize(int new_size)
{
HashTableNode[] ha = new HashTableNode[new_size];
for (int i = 0; i < new_size; i++) ha[i] = null;
count = 0;
for (int i=0;i<hash_size;i++)
hash_arr[i]=null;
}
HashTableNode[] hat = hash_arr;
hash_arr = ha;
if (hat.Length > new_size) return;
for (int i = 0; i < hat.Length; i++)
if (hat[i] != null) Add(hat[i]);
}
public int Add(HashTableNode node)
{
if (count/hash_size*100>SymbolTableConstants.HashTable_StartResise)
Resize(hash_size+hash_size/100*SymbolTableConstants.HashTable_ProcResize);
int tn=GetHash(node.Name);
public DSHashTable(int start_size)
{
hash_arr = new HashTableNode[start_size];
ClearTable();
}
public void ClearTable()
{
count = 0;
for (int i = 0; i < hash_size; i++)
hash_arr[i] = null;
}
public int Add(HashTableNode node)
{
if (count / hash_size * 100 > SymbolTableConstants.HashTable_StartResise)
Resize(hash_size + hash_size / 100 * SymbolTableConstants.HashTable_ProcResize);
int tn = GetHash(node.Name);
if (hash_arr[tn] == null)
{
hash_arr[tn] = node;
count++;
}
return tn;
}
return tn;
}
public int Find(string name)
{
int h=GetHash(name);
if (hash_arr[h]!=null)
return h;
return -1;
}
public int Find(string name)
{
int h = GetHash(name);
if (hash_arr[h] != null)
return h;
return -1;
}
}
}
}

View file

@ -237,7 +237,7 @@ namespace SymbolTable
public class DotNETScope:Scope
{
public DotNETScope(DSSymbolTable vSymbolTable):base(vSymbolTable,null,true)
public DotNETScope(DSSymbolTable vSymbolTable):base(vSymbolTable,null,false)
{
}

View file

@ -256,23 +256,23 @@ begin
if Self.Rank = 1 then
for var i := 0 to Self.Length - 1 do
begin
write(Self.GetValue(i));
PABCSystem.write(Self.GetValue(i));
if i < Self.Length - 1 then
write(delimiter);
PABCSystem.write(delimiter);
end
else if Self.Rank = 2 then
for var i := 0 to Self.GetLength(0) - 1 do
begin
for var j := 0 to Self.GetLength(1) - 1 do
write(Self.GetValue(i, j), delimiter);
writeln;
PABCSystem.write(Self.GetValue(i, j), delimiter);
PABCSystem.writeln;
end;
end;
procedure &Array.Writeln(delimiter: string);
begin
Self.Write(delimiter);
writeln;
PABCSystem.writeln;
end;
end.