mirror of
https://github.com/mikpe/pdp10-tools.git
synced 2026-01-24 03:18:22 +00:00
as: handle .pushsection as a special case of .section
This commit is contained in:
parent
14184eb4cd
commit
8d2b402d69
@ -92,7 +92,6 @@ pass1_stmt(Location, Ctx, Stmt) ->
|
||||
#s_dot_data{} -> dot_data(Location, Ctx, Stmt);
|
||||
#s_dot_popsection{} -> dot_popsection(Location, Ctx, Stmt);
|
||||
#s_dot_previous{} -> dot_previous(Location, Ctx, Stmt);
|
||||
#s_dot_pushsection{} -> dot_pushsection(Location, Ctx, Stmt);
|
||||
#s_dot_section{} -> dot_section(Location, Ctx, Stmt);
|
||||
#s_dot_subsection{} -> dot_subsection(Location, Ctx, Stmt);
|
||||
#s_dot_text{} -> dot_text(Location, Ctx, Stmt);
|
||||
@ -114,10 +113,6 @@ dot_previous(Location, Ctx0, #s_dot_previous{}) ->
|
||||
false -> fmterr(Location, ".previous with empty section stack", [])
|
||||
end.
|
||||
|
||||
dot_pushsection(Location, Ctx,
|
||||
#s_dot_pushsection{name = SectionName, nr = SubsectionNr}) ->
|
||||
ctx_pushsection(Ctx, Location, SectionName, SubsectionNr).
|
||||
|
||||
dot_section(Location, Ctx, Stmt) ->
|
||||
#s_dot_section{ name = SectionName
|
||||
, nr = SubsectionNrOpt
|
||||
@ -194,24 +189,6 @@ ctx_try_previous(Ctx0) -> % implements .previous
|
||||
}}
|
||||
end.
|
||||
|
||||
ctx_pushsection(Ctx0, Location, SectionName, SubsectionNr) -> % implements .pushsection
|
||||
Ctx = ctx_flush(Ctx0),
|
||||
#ctx{ sections_map = SectionsMap0
|
||||
, stack = Stack
|
||||
, current = Current
|
||||
, previous = Previous
|
||||
} = Ctx,
|
||||
case enter_section(Location, SectionName, SubsectionNr, SectionsMap0) of
|
||||
{ok, {Stmts, SectionsMap}} ->
|
||||
{ok, Ctx#ctx{ sections_map = SectionsMap
|
||||
, stack = [{Current, Previous} | Stack]
|
||||
, current = {SectionName, SubsectionNr}
|
||||
, previous = Current
|
||||
, stmts = Stmts
|
||||
}};
|
||||
{error, _Reason} = Error -> Error
|
||||
end.
|
||||
|
||||
ctx_section(Ctx0, Location, SectionName, SubsectionNrOpt,
|
||||
ShFlags, ShType, ShEntSize) ->
|
||||
{IsPushsection, SubsectionNr} =
|
||||
|
||||
@ -372,33 +372,6 @@ dot_previous(ScanState, Location) ->
|
||||
ScanRes -> badtok("junk after .previous", ScanRes)
|
||||
end.
|
||||
|
||||
%% For now only accepts ".pushsection <name> [, <nr>]". TODO: extend
|
||||
dot_pushsection(ScanState, Location) ->
|
||||
case scan:token(ScanState) of
|
||||
{ok, {_Location, {?T_STRING, Name}}} -> dot_pushsection(ScanState, Location, Name);
|
||||
{ok, {_Location, {?T_SYMBOL, Name}}} -> dot_pushsection(ScanState, Location, Name);
|
||||
%% TODO: do we need a general mapping from reserved to plain symbols?
|
||||
{ok, {_Location, ?T_DOT_DATA}} -> dot_pushsection(ScanState, Location, _Name = ".data");
|
||||
{ok, {_Location, ?T_DOT_TEXT}} -> dot_pushsection(ScanState, Location, _Name = ".text");
|
||||
ScanRes -> badtok("junk after .pushsection", ScanRes)
|
||||
end.
|
||||
|
||||
%% Seen ".pushsection <name>", expects "[, <nr>]".
|
||||
dot_pushsection(ScanState, Location, Name) ->
|
||||
case scan:token(ScanState) of
|
||||
{ok, {_Location1, ?T_NEWLINE}} -> {ok, {Location, #s_dot_pushsection{name = Name, nr = 0}}};
|
||||
{ok, {_Location1, ?T_COMMA}} ->
|
||||
case scan:token(ScanState) of
|
||||
{ok, {_Location2, {?T_UINTEGER, Nr}}} ->
|
||||
case scan:token(ScanState) of
|
||||
{ok, {_Location3, ?T_NEWLINE}} -> {ok, {Location, #s_dot_pushsection{name = Name, nr = Nr}}};
|
||||
ScanRes -> badtok("junk after .pushsection <name>, <nr>", ScanRes)
|
||||
end;
|
||||
ScanRes -> badtok("junk after .pushsection <name>,", ScanRes)
|
||||
end;
|
||||
ScanRes -> badtok("junk after .pushsection <name>", ScanRes)
|
||||
end.
|
||||
|
||||
dot_short(ScanState, Location) ->
|
||||
dot_short(ScanState, Location, ".short").
|
||||
|
||||
@ -504,6 +477,9 @@ dot_word(ScanState, Location) ->
|
||||
dot_section(ScanState, Location) ->
|
||||
dot_section_name(ScanState, Location, _IsPushsection = false).
|
||||
|
||||
dot_pushsection(ScanState, Location) ->
|
||||
dot_section_name(ScanState, Location, _IsPushsection = true).
|
||||
|
||||
dot_section_name(ScanState, Location, IsPushsection) ->
|
||||
case section_name(ScanState) of
|
||||
{ok, Name} -> dot_section_subsection(ScanState, Location, Name, IsPushsection);
|
||||
|
||||
@ -63,9 +63,6 @@
|
||||
%% .previous
|
||||
-record(s_dot_previous, {}).
|
||||
|
||||
%% .pushsection name [, nr] (TODO: extend)
|
||||
-record(s_dot_pushsection, {name :: string(), nr :: non_neg_integer()}).
|
||||
|
||||
%% .section name, "flags", @type, ...
|
||||
%% .pushsection name, [, nr], "flags", @type, ...
|
||||
%% TODO: add support for G and ? flags and ,<group>,<linkage>
|
||||
@ -114,7 +111,6 @@
|
||||
| #s_dot_long{}
|
||||
| #s_dot_popsection{}
|
||||
| #s_dot_previous{}
|
||||
| #s_dot_pushsection{}
|
||||
| #s_dot_section{}
|
||||
| #s_dot_size{}
|
||||
| #s_dot_subsection{}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user