Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 47 - method/null property results in unexpected AS3 code - haxe #47

Closed
issuesbot opened this issue May 28, 2013 · 1 comment
Closed

Comments

@issuesbot
Copy link

[Google Issue #47 : https://code.google.com/p/haxe/issues/detail?id=47]
by pimmhoge...@gmail.com, at 18/01/2010, 16:58:47
The following haXe class:
package;

class Main {
    public static function main():Void {
        new Main();
    }
    private var property(getProperty, null):Int;
    public function new():Void {
        property = 4;
    }
    private function getProperty():Int {
        return 0;
    }
}

Results in the following AS3 code (when compiled targeting AS3):

package  {
    import flash.Boot;
    public class Main {
        public function Main() : void { if( !flash.Boot.skip_constructor ) {
                this.property = 4;
            }}
        protected function get property() : int { return getProperty(); }
        protected var $property : int;
        public function getProperty() : int {
            return 0;
        }
        static public function main() : void {
            new Main();
        }
    }
}

Note the line in the constructor:
this.property = 4;
This does not work, as there is no property field. It could have been this:
this.$property = 4;

I'm using haXe compiler 2.05.

Workarounds for this problem include:
Manually adding the sigil ($) character.
Defining a setter, instead of using null.

Label suggestions: Type-Defect, Priority-Low, Platform-AS3.

@issuesbot
Copy link
Author

[comment from ncanna...@gmail.com, published at 24/01/2010, 14:43:09]
This is a bit difficult to directly set $property so instead we added a protected
setter which just do the assignment.

Simn added a commit that referenced this issue Jun 3, 2017
* add eval target (new interpreter)

* install findlib packages

* typo

* don't add trailing slashes if your name is remove_trailing_slash

* add rope and ptmap to merlin again

* fix timers

* support enum to expr conversion (#43)

* fix no-arg enum values (#44)

* make Md5 faster on `eval` (#45)

* implement Md5 natively

* add -D interp-times

* fix incr ops

* lose IO dependency

* ignore Japan (?)

* 64 bits

* implement FPHelper natively for more accuracy

* allow floats in place of int because apparently that happens sometimes

* print value kind in case of unexpected value

* make other interp's create functions compatible

* add more hxmls for mandelbrot benchmark

* optimize enum index access

* optimize enum construction

* return empty array for Reflect.fields(null) (#46)

* sort timers by time

* print parent % too

* add eval.vm.Gc

* deal with different OCaml versions

* optimize decrement ops

* avoid raising Return exceptions at the end of a function's control flow

* don't catch RunTimeException in two places

* Improve macro context api: add haxe.macro.Context.storeExpr (#47)

* optimize `while (a >= const)`

* use DynArray instead of Stack for environment stacks

* avoid Return exception wrapping if there's no nonfinal return

* don't record stack traces in non-debug mode, unless -D interp-stack

* throw "Unbound variable" instead of asserting

* keep a default environment and re-use it if possible

* specialize any calls

* fix closure jitting

* memoize proto functions on call

* avoid hitting the write barrier on envs so much

* show context of local functions for times (#48)

* avoid more write barrier by storing 3 ints instead of 1 pos

* make envs a bit smaller

* make constructor calls a bit less slow

* move env info creating to a function

* allow adding useless breakpoints because why not

* keep variable names around so we can print them

* move JitContext to its own file

* implement some parts of the hxcpp-debugger CLI

* detect uncaught exceptions when debugging

* make caught-type detection more accurate

* catch Not_found if a breakpoint file doesn't exist

* don't mess up blocks if we're debugging

* support captured variables

* use intermediate functions instead of print_endline so they can be modified

* restructure a bit

* rework debug representation to support up/down/frame

* adjust to vshaxe-debug requirements

* always print prompt

* match hxcpp-debugger output more accurately

* minor

* hook up names

* keep variable types around

* fix var info lookup

* fix breakpoint pattern parsing

* fixes

* support `print obj.field`

* automatically reset to real env instead of complaining about it

* print values in a way the debugger accepts it

* lose var type information

* more hxcpp-debugger sync

* quote string values

* unify set/print

* resolve idents to prototypes

* support more identifier resolution

* return real paths

* support column breakpoints

* readjust to picky debugger

* support socket connections via -D interp-debugger-socket=host:port

* actuall call recv

* asdfg

* output some json

* consistency

* send data length

* add value_to_json

* output breakpoint setting result as int

* sync breakpoint names

* thread debug experiment

* don't ctx.eval() so much

* keep main thread separate

* fix some threading

* remove Thread implementation, at lest for now

* branching is faster

* avoid unnecessary function call

* use macro call position if that's all we have

* rename interp- stuff to eval- stuff

* add test (closes #5155)

* add tests (closes #5160) (closes #6145)

* maybe fix timer accumulation

* fix call stack handling if record_stack is false

* small opt

* optimize null checks

* improve int equality check

* fix flag implications

* close env timers in case of exceptions

* remove check because bools don't trigger the write barrier

* guard against failing C#/php test

* fix timers, again

* make StringMap implementation faster

* emit breakpoint_stop event

* output some info about the exception

* command for getting scopes and vars within scope

* some hackery

* revert stack (so the frame with id=0 comes first), output response to move_frame commands

* don't skip, but mark artifical frames

* make "frame" accept ids returned by "w"

* can now use zero-based scope numbers

* wip on scope variable output

* add 'structured' flag for the var output

* wip

* flat var repr

* show object internals

* display arrays the same way as objects

* some value display improvements

* have instance_fields fields, next to object_fields

* more wip on var introspection

* support array access in expr_to_value

* improve enum printing, fix array printing order

* support enum value introspection

* output "access" field so we don't have to do the magic on the adapter side to know how to access subvars

* wip on setting vars

* use native crc32 implementation for Crc32.make

* skip empty scopes in "scopes" request

* swap argument order for jit_expr

* optimize method calls a little

* optimize calls to singly-implemented interface fields

* some minor cleanup

* don't make pointless vnull assignments when declaring variables without init

* use some `[@@inline]` to restructure call code

* don't mess up override calls

* check if 4.02.3 accepts this

* Revert "check if 4.02.3 accepts this"

This reverts commit e20311c.

* add position info to scope

* rename vars_scope to simply vars, rename vars_inner to structure

* remove `[@@inline]` for now

* ctrl s

* make fastCodeAt a bit faster

* don't use the default env if we want to record a stack

* Bring back VArray and VString (#49)

* bring back VString

* bring back VArray too

* change stack trace output

* reset ctx.curapi after call_path

* implement Haxe serialization algorithm and use it for Context.signature

* use full enum path (see #6273)

* set error state on eval context

* start separating connection from EvalDebug, since we want two different connection interfaces

* add EvalDebugSocket module which is the main goal to complete right now

* select connection based on whether there's a socket (do it the ugly way for now)

* rework EvalDebugSocket to a json-rpc protocol

* camelcase

* don't care about `id` structure, just return it as is

* conform to jsonrpc spec better by always supplying `id` for errors (should be null if there's no id)

* minor

* clean up EvalDebugCLI from the json socket stuff

* remove unused value_string

* add a method to replace all breakpoints within file

* make sure we actually compare the same enums (closes #6273)

* remove "created socket" print

* add eval.vm.Context.breakHere

* play it safe with compare/equals

* don't comment out what you want to test

* optimize int/enum switches

* get exception message _before_ resetting the context

* reset caught_types within catch blocks

* catch exception on recv

* re-work function argument handling

* add rev_file_hash

* [debug] don't stop at field access expressions

* let prototypes keep a reference to their own value

* rely on physical equality for equals

* [eval] initial vector implementation (#51)

* [eval] initial vector implementation

* [eval] add missing Vector key

* optimize Vector.get/set

* use native Vector.map

* optimize new Vector a bit

* improve Vector/Array.map

* [eval] vector should use ocaml implementations

* implement Vector.join natively and improve Array.join

* [eval] add special cases in jit to improve vector performance, add array access to eval.Vector to detect them, bugfixing

* fix Vector warnings

* remove unused eval.Vector.get/set

* compare prototypes by path (see #6308)

* check for uncaught haxe.macro.Error exceptions (closes #53)

* fix env_captures initialization

* always initialize vars

because nadako doesn't

* Revert "fix env_captures initialization"

This reverts commit cfc4fe2.

* [eval] add missing VVector handling in various places (#52)

* [eval] add missing VVector handling in various places

* [eval] handle vector.length like array.length, but don't support write access

* [eval] don't expose set and get of eval.Vector, we only handle array access

* add eval.vm.Context.loadPlugin

* expose decode_expr again

* expose encode_expr as well so we can do macros \o/

* expose encode_ctype

* add decode_type

* More work on cppiaast

* [lua] get rid of unused variable (and warning)

* Add cppiaast define to test unified cppia generation

* deal with `if (throw)` situations (closes #6315)

* Normalize class names in cppia-ast

* save locals in typing_timer

* subdate upmodule

* add back dynlink

* fix Uncompress
nadako pushed a commit to nadako/haxe that referenced this issue Apr 26, 2019
This isn't 100% correct but at least it's faster.

see HaxeFoundation#47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant