mirror of
https://github.com/irmen/prog8.git
synced 2025-01-26 19:30:59 +00:00
slight tweaks related to builtin functions in the ast
This commit is contained in:
parent
7aa807ec7f
commit
41fece4643
@ -61,7 +61,7 @@ class StatementOptimizer(private val program: Program,
|
||||
}
|
||||
|
||||
override fun after(functionCallStatement: FunctionCallStatement, parent: Node): Iterable<IAstModification> {
|
||||
if(functionCallStatement.target.targetStatement(program) is BuiltinFunctionPlaceholder) {
|
||||
if(functionCallStatement.target.nameInSource.size==1) {
|
||||
val functionName = functionCallStatement.target.nameInSource[0]
|
||||
if (functionName in functions.purefunctionNames) {
|
||||
errors.warn("statement has no effect (function return value is discarded)", functionCallStatement.position)
|
||||
|
@ -49,6 +49,8 @@ sealed class Statement : Node {
|
||||
}
|
||||
|
||||
|
||||
// this class is only created as temporary result from looking up the target for a builtin function call.
|
||||
// this node is never actually part of the Ast.
|
||||
class BuiltinFunctionPlaceholder(val name: String, override val position: Position, override var parent: Node) : Statement() {
|
||||
override fun linkParents(parent: Node) {}
|
||||
override fun accept(visitor: IAstVisitor) = throw FatalAstException("should not iterate over this node")
|
||||
|
@ -131,7 +131,6 @@ abstract class AstWalker {
|
||||
open fun after(branch: ConditionalBranch, parent: Node): Iterable<IAstModification> = noModifications
|
||||
open fun after(breakStmt: Break, parent: Node): Iterable<IAstModification> = noModifications
|
||||
open fun after(containment: ContainmentCheck, parent: Node): Iterable<IAstModification> = noModifications
|
||||
open fun after(builtinFunctionPlaceholder: BuiltinFunctionPlaceholder, parent: Node): Iterable<IAstModification> = noModifications
|
||||
open fun after(decl: VarDecl, parent: Node): Iterable<IAstModification> = noModifications
|
||||
open fun after(directive: Directive, parent: Node): Iterable<IAstModification> = noModifications
|
||||
open fun after(expr: BinaryExpression, parent: Node): Iterable<IAstModification> = noModifications
|
||||
|
@ -5,6 +5,9 @@ For next release
|
||||
^^^^^^^^^^^^^^^^
|
||||
- attempt to rework registerArgsViaStackEvaluation() to use tempvars or push()/pop() instead of evalstack based evaluation
|
||||
actually, all function call asmgen code should use the same routine to pass arguments (replaceCallAsmSubStatementWithGosub ?)
|
||||
- If all regular function calls (both expression + statement) are then replaced by a GoSub node,
|
||||
the only reason the old FunctionCall[stmt/expression] nodes are still present is because they're for a builtin function call.
|
||||
-> at this time make those a new Node type for the codegenerator
|
||||
|
||||
|
||||
Need help with
|
||||
|
Loading…
x
Reference in New Issue
Block a user